Author Topic: Emulating quadrature encoder interface for a motor controller  (Read 1044 times)

0 Members and 1 Guest are viewing this topic.

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Hello,

I have a sensor that I can read from an exact (or accumulated) angle of rotation in digital form.

How could I emulate an encoder interface (for a motor controller) based on the position information in digital form?

That means I need the number of quadrature pulses generated to match the exact position obtained in a digital form. Also the frequency of the pulses generated should match as closely as possible the actual rate of change of the position information.

I am familiar with the concept of an angle tracking observer on an encoder input (a PLL loop designed to match the speed based on the angle of rotation received). But I am not sure how to make this work "backwards".

Obviously, I need a continuously variable frequency generator, that I will somehow lock in a feedback loop to the position I am reading from the sensor.

How would one implement this? I think the variable frequency generator could be solved using a DDS principle (without using a DAC, just using the MSB of the phase accumulator).  But I am not sure how to design the feedback loop around this.

It seems to me that a PSD (or just) PS controller would do, taking the difference between sensor read position and number of generated pulses as the error input. Output would feed the frequency tuning word.

Now thinking about it, this is also a PLL loop (exactly what I wanted), as the phase accumulator in the DDS is in fact the integrator in the loop that forms the PLL together with the PS controller.

I am currently learning VHDL and toying with FPGAs, so this seems a good opportunity to make something more useful than a blinkelight and learn a lot from it.
 

Offline thatguy1988

  • Newbie
  • Posts: 6
  • Country: il
Re: Emulating quadrature encoder interface for a motor controller
« Reply #1 on: April 16, 2020, 05:15:32 am »
Can you not just add a quadrature encoder? that seems the simplest solution given that almost all encoders provide Emulating quadrature outputs.

If for whatever ever reason you can not add a quadrature encoder, I would simply read the the digital encoder using an Arduino and program it to calculate and output a quadrature output. You might struggle at high RPMs though.
 

Offline YansiTopic starter

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Emulating quadrature encoder interface for a motor controller
« Reply #2 on: April 16, 2020, 07:49:00 am »
There seems to be a lot of misunderstanding on your side.  Neither is it possible to modify the current mechanics and sensors, nor could you emulate anything with an evil arduino.  You couldn't even talk to the sensor with it to begin with. (10Mbps RS485).

There is no way you could emulate a single encoder at any speed above very very low speed, yet I need to cover six axis and full speed. You would have a very hard time doing this task even with much more faster 32bit microcontroller.  This is exactly a job where FPGA is a suitable solution.



It seems that producing variable frequency quadrature (2-bit gray code) is really straightforward in an FPGA, using a DDS principle with an phase accumulator and then decoding the output from the two MSBs fo the phase accumulator. 



But that is the easy part. The loop has to benow  closed with a PS regulator. That is the stuff I have never done in an FPGA before.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf