cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the quadratic encoder in 2x mode under MotorControl?

apexyz
Associate II

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:

apexyz_0-1727772553277.png

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?

 

2 REPLIES 2
cedric H
ST Employee

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

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?