cancel
Showing results for 
Search instead for 
Did you mean: 

TIM3 Quadrature Encoder Mode Strangeness

jerry2
Senior

I'm got a Nucleo-F746ZG connected to a DC motor, which I'm driving via PWM using TIM1.

I'm using TIM3 in quadrature encoder mode to read the encoder on the motor. The problem I'm encountering is the TIM3 CNT register is not incrementing fast enough. The encoder on the motor generates 500 counts per revolution of the motor, and I've verified this using an oscilloscope to look at the two encoder outputs and comparing the expected counts with the motor's RPM as measured by a tachometer connected to the output shaft.

At a measured speed of 3108 RPM, I see encoder edges every 10 microseconds, which is exactly what I expect. TIM3 is set up to count on every rising and falling transition of the two encoder outputs, so I'd expect TIM3's CNT to increase at a pretty fast rate, but I'm seeing it increase at only around 20-30 counts every 100 milliseconds, which is way too low. Occasionally the count even decreases. I'm having a hard time understanding why this is happening. The motor is spinning in only one direction, and looking at the encoder output on a scope the signals look rock solid with no glitches.

Is there any reason why TIM3 is behaving this way? On this board TIM3 is clocked at 54 MHz, so that should be fast enough to keep up with a 500 count per revolution quad encoder on a motor spinning at 3000 RPM (that's only 25,000 counts per second). This weirdness happens even when the motor is spinning much slower, say 400 RPM.

10 REPLIES 10

Thanks for coming back with the solution.

JW