2024-07-31 04:20 PM
I am using two quadrature encoders through the STM32F411CEU6 timer encoder mode. Here is the graph for one of their CNT values:
As you can see, it takes about 400ms to update the value, but when it does, it seems accurate. How can I make it so that it doesn't do this? Timer settings (the same for both):
The PLL is at 98 MHz and it says the peripheral clocks are at 48 MHz, although I'm not sure if that's the right number to read. I've tried changing:
- Encoder Mode
- Input Filter
- Some values of the Trigger Output Parameters, although not all of them
I am positive that the encoders are hooked up correctly and I took a look with the oscilloscope and the signal looks good. I'm simply plotting htim3.Instance->CNT to make this chart.
Solved! Go to Solution.
2024-07-31 07:28 PM
Wow, I was using if (HAL_GetTick() % 50 == 0) to try to print every 50ms, but it turns out that doesn't work? I'm not sure why because I know the loop is running at much higher than 1000Hz but now that I switched to properly printing it works!
2024-07-31 06:42 PM
The encoder is a hardware state machine. Its architecture precludes the possibility of a large delay. More likely to be an issue with your data transfer.
> I'm simply plotting htim3.Instance->CNT to make this chart.
How are you obtaining the values of TIM3->CNT? Why do the values jump? Perhaps you are using UART and the values are getting buffered/lost.
2024-07-31 07:28 PM
Wow, I was using if (HAL_GetTick() % 50 == 0) to try to print every 50ms, but it turns out that doesn't work? I'm not sure why because I know the loop is running at much higher than 1000Hz but now that I switched to properly printing it works!