Measure the speed rotation by using TIM in encoder mode
hello, I ask for the following clarification: I am using a two-channel encoder, A and B, and I want to estimate the rotation speed of the encoder shaft as precisely as possible. I started setting the TIM2 in encoder mode.
My encoder generates 1200 pulses per revolution.
I called the function:
HAL_TIM_Encoder_Start_IT(&htim2, TIM_CHANNEL_ALL);
and :
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
counter = __HAL_TIM_GET_COUNTER(htim);
}
which increases the counter variable every time a channel A (and B) get a variation (rising/falling edge settable from CUBE IDE).
At one full revolution of the encoder, with my settings of frequency = 160 MHz, Ps =0 and ARR = 4800, the counter variable starts at zero and goes to the value 4800 at each full revolution, then goes back to zero, and so on (all visible via serial on my laptop by using Putty software). My question is: how can I estimate the rotation speed? I have read a lot of information about this but I am still confused. Any advice?
