2025-12-11 7:20 PM
Hardware: EVLSERVO1 official motor evaluation board
In the "ENC Calc Angle" function, there is a step to perform bitwise AND operation 0x7ffffff on TIM ->CNT, multiply it by the unsigned 32-bit maximum value divided by the polar logarithm. Its left value is a number of type uint32/t, which can cause data overflow. I don't quite understand how it converts pulse values into electrical angles. As shown in the following figure
2025-12-17 5:34 AM
Hello @Kevin8,
According to defined values:
PulseNumber = M1_ENCODER_PPR * 4 (for ultra-high-resolution encoder can offer up to 50,000 PPR).
U32MAXdivPulseNumber = UINT32_MAX / PulseNumber = UINT32_MAX / (M1_ENCODER_PPR * 4)
Timer2 Auto-reload register is set to
M1_PULSE_NBR = ((4 * (M1_ENCODER_PPR)) - 1) (which is the maximum Counter value).
Then uwtemp1 is lower than UINT32_MAX.