2
\$\begingroup\$

on my STM32F103, I use a timer to read rotary encoder

  • Prescaler = 71
  • Period = 20
  • Clock = 72MHz
  • Rotary encoder: 2000 ppr

Given the formula:

  • TIMUpdateFrequency(Hz)=Clock/((PSC−1)∗(Period−1))

I obtain an update every 54'135Hz Each update, I read the encoder value and compare to the previous one. Very stupid question: how can I get à RPM figure with that?

asked May 23, 2018 at 13:50
\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Your sample frequency is let's say 50 Hz. Calculatel the difference of the encoder values. Than divide by 2000 (ppr). This means you get this many of revolutions in 50 Hz (or 1/50 = 0.02s).

As calculation

 RotationSpeed = (EncoderValue_Last - EncoderValue_Previous) / 2000 ppr) * Freq [Hz]

Assuming the previous encoder value was 30,000, the current 80,000, ppr is 2,000 and using 50 Hz (sample encoder data each 0.02 s):

 = (80000 - 30000) / 2000 * 50 = 1,250 RPM

In this article ppr and cpr are explained in more detail.

answered May 23, 2018 at 13:55
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.