Author Topic: Convert encoder 1Vpp to UVW  (Read 873 times)

0 Members and 1 Guest are viewing this topic.

Offline thewho333Topic starter

  • Newbie
  • Posts: 2
  • Country: fi
Convert encoder 1Vpp to UVW
« on: March 08, 2022, 07:42:25 am »
Hello everyone!

I need to convert my encoders 1Vpp sine/cosine differential output to UVW that my servo drive can use for rotor position.
So far I have combined and amplified the differential signal with a LM358 op-amp.
And my plan is to use a microcontroller for the sine/cosine calculation and subsequent conversion to rotor angle > electrical angle(div by pole count) > UVW commutation signals.
I think that the servo drive only uses UVW to get the initial position and then reverts back to counting the incremental encoder signals. But I'm not sure, so to be safe I'd like to get the conversion fast enough to not loose sync at 3000rpm. (And 8000rpm for the spindle motor)

So to the question:
How do I combine and convert sine and cosine (0-1023) to an angle (0-359) fast enough? Where "fast enough" is 8000rpm / 60 = 134Hz * 8 poles * 6 uvw = 6432Hz. In other words, the loop needs to run at least 6432 times a second.
I did some research and I probably want to use a sine lookup table?
(I'll attach an example image that shows the signals)
 
Programming is really not my strong suite so I would like to do it with an arduino compatible mcu 😅 stm32f103 maybe?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12864
Re: Convert encoder 1Vpp to UVW
« Reply #1 on: March 08, 2022, 08:16:10 am »
No, you don't want a sine lookup table as if you had one you'd have to do two reverse lookups to get the angle then a bunch of comparisons to get U,V and W. 

How fast do you want?  Throw a large enough ROM lookup table at the problem and you can generate U,V & W signals as fast as you can read two channels via the ADC.   Just concatenate the two ADC results with some of the low bits sliced off and use them as the address in the lookup table.   The table stores precomputed U,V W and an error bit in a nibble.   The error bit is set for addresses that aren't close enough to the expected sine/cosine circle from the encoder, and indicate an encoder fault.  To save memory, pack the table two nibbles to a byte and slice off one bit of the combined address to select which nibble to return.

Throw hardware at the problem e.g. two Flash ADCs, a fast ROM and a sample clock generator, and you could update U, V & W at well over 10MHz!
 

Offline thewho333Topic starter

  • Newbie
  • Posts: 2
  • Country: fi
Re: Convert encoder 1Vpp to UVW
« Reply #2 on: March 08, 2022, 10:01:56 am »
Thank you!
That is obviously the smarter way to do it  :-+
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf