help for rpm meter

Thread Starter


Joined Jun 3, 2009
first of all i want to apologise for my bad english
i'm newbie in mikrokontroller, i want to make a RPM meter using 89s51,
the pulse i want to count is too slow, about 0.5 second until 2 seconds, i had a trouble when i want to get a reading in every view second,could anyone help me to find out the solution,

thanks a lot before
Last edited:


Joined Aug 3, 2008
I happen to make an rpm on PIC right now. I measure pulses from 10 up to 40 Hz, easier than yours.

But anyway

There are 2 basically ways to measure. 1 fits for fast signals, is the way you try to do it. Bad selection.
The other fits you like glove. Instead of measuring the pules per seccond, make a timer (for example 100Hz for you) and measure how many pulses from your timer are counted in each period of your input signal. Then you need to do a division to find the number, as this method will provide smaller numbers of pulses as your measuring signal increases the hertzes, the oposite you do right now.

The 2nd video shows (at the end for a couple of seconds) an rpm counter, the one i described you before. At the end of this week, i will have it ready. Maybe this weekend we will prepare a demo and upload the project. I will have the code listing also. It's based on a PIC micro and will control (according to 2 temperatures) and measure rpm for 4 fans (with 3 wires) on 20x4 LCD . I do not know if this fits your needs.
The fans generate 2 pulses per rev. Min 300rpm => 10Hz max 1200=>40Hz.... That's why i told you before 10 to 40 Hz.
Last edited:

Thread Starter


Joined Jun 3, 2009
at the moment i plan to measure pulse 10 to 150 hz,i create a counter that counts from 0 to ffff hex with basic clock 1 mS, when i got pulse 30 hz,my counter counts 2000 mS.
to convert to real reading i use a formula, 60000 ms(6 second) divide by pulse of my counter ( 2000 mS),then i will get a number 30.
but i dont have idea to write that into codes, because of range of the number,89s51 just 8 bit uC,so the max number is 255.
correct me if im wrong or missunderstand.
can you guide me,please

thx a lot


Joined Jan 9, 2009
Just capture the pulse on an interrupt pin and calculate the RPM each interrupt based on another value which is incremented in a timer interrupt service routine. You can then clear the timer counter in the pulse service routine and have your higher level software just read out the RPM value whenever it wants to.

Take MUTEX into account and consider bumping the calculation of 'speed' out to the higher level software loop. The idea is to get in and out of an interrupt service routine as fast as possible.

This is probably a bit heavy if you are a beginner so maybe you just want to focus on something easier?

Thread Starter


Joined Jun 3, 2009
my great thanks for all of your replys
yes i think this is quite heavy for me,but im trying beginner in uC,i started with 89s51,do you have suggestion for me wich is better for me to start,89s51 or avr or another else.?
2. can 89s51 solved this calculation ,1000 divided by 10, how..?
3. according to your experience,do you have suggestion for me to learn uC faster?