RPM calculation from encoder value
Opened this issue · 7 comments
Hi!
Could you please help me with RPM calculation formula?
Currently, I'm able to read the raw value from the encoder. I've found two formulas to the calculation.
- https://www.vexforum.com/index.php/16114-calculating-rpms/0
- https://electronics.stackexchange.com/questions/375971/how-to-calculate-rpm-given-timer-frequency-and-counter-on-stm32
they both look similar, except divider. Which formula is suitable for us?
Thanks,
Vasyl
Hey @nemo8 :)
As for me the second links looks reasonable. @LyubomyrD please confirm my thinking :)
Hello all.
I guess that the formula moight be the following
Real_RMP_OF_WHEEL = (EncoderCurr - EncoderLast) / sampling_period / CPR / gear_ratio /encoder_correction_multiplier
*encoder_correction_multiplier depends on the setup of the timer. Commonly for stm32f4xx it is either 2 or 4
@LyubomyrD,
thank you!
encoder_correction_multiplier depends on the setup of the timer in my case = 4.
one motor rotation give me 480 pulses.
what is CPR ?
Could you please take paramenters in formula to bracket? (like (((a+b)/4)/8) ).
The CPR is counts per revolution - you can find this value in the datasheet of the encoder.
Here is the formula with brackets
Real_RMP_OF_WHEEL = (((((EncoderCurr - EncoderLast) / sampling_period)/ CPR) / gear_ratio) /encoder_correction_multiplier)
Single Output 480 Pulses Per Revolution:
Gear Ratio: 30:1
Each Loop Output Pulses: 16
30 * 16=480
reference: https://www.amazon.com/12V-DC-Geared-Motor-Encoder/dp/B073QXQW5Y
If I understand the timer settings correct, the timer in encoder mode will be incremented by 1 every rotation (when receives 480 pulses from the encoder).
So, I think we can make formula simpler just rid off gear_ratio. (gear_ratio already defined in encoder settings.) Am I correct?
I guess that You should set the value of the ARR equal to 65535 otherwise the timer might hangup every rotation. Besides, the polarity for the second chanell should be falling, I guess.
Now I can read a value of the timer, but I need to investigate more about this timer in the encoder mode...
http://d1.amobbs.com/bbs_upload782111/files_10/ourdev_265522.pdf (page 18)