Showing results for 
Search instead for 
Did you mean: 

How to integrate an SPI encoder for position control in MC Workbench

Associate II

In your last webinar about the 6.2 release of the STM32 Motor Control SDK I asked about this and I got the next reply:

No native support is planned for SPI encoders. However, we have many customers doing this very thing. The FOC Scheme needs position data once every PWM Period. Getting that data into the algorithm as close to the mid point in the PWM period would be the key. You can work back your timing from there to take propagation delay into account. You want to remove as much jitter as possible

Can you please elaborate a little more how to achieve this? I guess I have to select a quadrature encoder in order to generate the code, and then what functions should I override?”

I´m successfully reading the encoder value with interrupts. Should I use a timer to  sync this readings? The maximum sample rate of this encoder is 18ksps so I think I can have fresh position data every PWM period.