2024-10-01 02:00 AM
I am using MotorControl Workbench (6.2.0) to setup BLDC position control, where Quadrature Encoder is enabled with PPR = 4096. After generating the project, TIM2 is automatically set as Encoder Mode as follows:
Now I want to double the resolution with PPR = 8192. Usually this can be done by setting Encoder Mode to be one channel and choosing polarity of that channel to be both rising and falling edges. However, in STM32CubeMX, it is not allowed to set polarity of channels to be both edges. My question is: How to double the resolution of quadratic encoder if MotorControl middleware is used?
p.s. I also set the polarity of channel 2 to be Rising Edge (the same as channel 1), but the BLDC control doesn't work anymore. Seems like only the default setting (as shown in the figure above) works. Any special reasons behind?
2024-10-01 09:29 AM
Hello @apexyz
As it is set to M1_PULSE_NBR, you do not have to change anything on MX side.
But if you look carrefully at the generated code, we use already the PPR x 4:
In parameters_conversion.
#define M1_PULSE_NBR ((4 * (M1_ENCODER_PPR)) - 1)
Regards
Cedric
2024-10-01 07:18 PM
Thank you for your quick response!
Does it mean the quadratic encoder always running under 4x mode for motor control? How does the polarity setting of channel 1 and 2 affect the resolution?
For my encoder, M1_ENCODER_PPR = 4096, which is measured by capturing the rising edge of channel 1 or 2 using oscilloscope. So theoretically, the resolution can be 2x if capturing both edges of channel 1 or 2, right?. How to make it?