I am building a RPM measurement unit using 8051 micro controller. I want to measure RPM of AC motor. I have connected proximity sensor to get the pulse for each turn.

I have connected the proximity sensor output to the counter of micro controller. And I am calculating the 1 sec delay using Timer.

For each second I am calculating the RPM = pulse count[counter value] * 60.

Ex: If pulse count = 16, I am getting RPM = 960 r/m If Pulse count = 17, RPM = 1020 r/m.

Here I am getting difference of 60 r/m.

Using the above method, I can't measure RPM of 1000 r/m. Since pulse count * 60 will not be 1000 at any given point of time.

Please advise me how I can measure RPM in precision manner.

Thanks Umesh


3 Answers 3


You would have to measure

  • either the duration between the last pulse and the end of your 1-second measurement period (and calculate that into your formula as a fraction of a pulse)
  • or (preferably) the duration between two pulses (ditching the 1-second period and using the inverse of the pulse duration to calculate the pulse frequency).

To implement this, you just need to reverse your current measuring principle: Instead of counting pulses per second, you would count milli- or microseconds1 per pulse.

1: or whatever fraction of a second you can easily obtain from a timer

Additionally, you might want to compute a sliding window average of your measurements to reduce their fluctuation.

  • \$\begingroup\$ How Can I measure duration between last pulse and end of 1- second period. \$\endgroup\$ May 4, 2014 at 8:27
  • \$\begingroup\$ @user2507991 Either the way I wrote above, or by storing the value of your 1-second timer (for which you're probably using a counter that increments up to a certain value n at a frequency of n Hz) on every pulse and using the last stored value when the second has passed. \$\endgroup\$
    – n.st
    May 4, 2014 at 12:30
  • 1
    \$\begingroup\$ Of course measuring time between each tick is the best solution. To get more help, read this first tinyurl.com/mpqjy6v \$\endgroup\$
    – RawBean
    May 5, 2014 at 6:47

You could use multiple proximity sensors to get several pulses per rev. If you are using an inductive probe you could use several small pieces of protruding iron on the rotating part that generate several pulses per rev also.

Another way is to use a small gear box to increase the revs seen by the sensor.

These are all non software methods but I'd consider an answer that used software methods first because it costs only your time to develop. I'd be thinking along the lines of using a high speed clock/counter and counting these clocks between consecutive pulses received from the sensor.


I think measuring the time between pulses and averaging is probably a good solution. But if you want to continue counting pulses per second then you just need to average the measurement over several seconds. For example, at 1000 RPM if you measure counts per second for three consecutive seconds then you might get 17, 16, and 17 counts, which averages out to 1000 RPM.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.