| 99
000 RPM Contact-Less Digital Tachometer
Featuring LCD display
and automatic DATA hold function
By
Ibrahim Kamal
Last update:
4/4/08
| |
|
Key Features:
Measures up to 99 000 RPM
Instantaneous measurement
Automatic DATA Hold Function
LCD display
Ni-Cad Rechargeable battery |
Important:
this tachometer uses a proximity sensor. In case you don't
know how to make a proximity sensors, and/or how to operate
them, please refer to this
article first. |
Contact
less tachometer principle of operation
The idea behind
most digital counting device, frequency meters and tachometers,
is a micro-controller, used to count the pulses coming from
a sensor or any other electronic device.
In the case of this tachometer, the counted pluses will
come from proximity sensor, which will detect any reflective
element passing infront of it, and thus, will give an output
pulse for each and every rotation of the shaft, as show
in the picture. Those pulses will be fed to the microcontroller
and counted.
To understand how a micro |
 |
controller counts pulses, and deduce the frequency
of those pulse, please refer to this
tutorial about building a frequency meter, that elaborates
the process of frequency counting.
The main difference between this tutorial about
tachometer and frequency meters, is that we need the reading in
pulses per minutes (to count revolutions per minutes), but in
the same time, we don't want to wait a whole minute before getting
a correct reading. Thus we need some additional processing to
predict the number of revolutions per minute in less than a second.
Instantaneous
measurement algorithm
To
be able to deduce an RPM reading in less than second, while constantly
refining the reading's accuracy, a simple algorithm have been
developed, where a counter and a timer are used. Counter and timers
are part of the internal features of a micro-controller, (like
the AT89C52 used in this project) and they can be easily configured
through programming.
The schematic below, shows how the timer and the
counter are used for this task; The counter is connected i such
a way to count pulses coming from the proximity sensor, while
the timer is used to precisely feed the counted value to the microcontroller every filth of a second, and
reset
the counter to 0. The microcontroller can now take an
average of the last 3 readings (saved in C1, C2 and C3)
and calculate the average numbers of pulses per fifth
second, then multiply this value by 5, to get the number
of pulses per second, then multiply this value by 60 to
get the number of pulses per minute, which represents
the measured RPM. The only purpose of calculating an average
reading is that it will allow to get more |

C1, C2 and C3 are used to store the last 3 reading |
stable reading and prevent display flickering.
The
electronic Circuits
This device is composed of 2 electronic circuits: the
Sensor, which is a slightly modified proximity
sensor, and the microcontroller board, which analyses pulses
coming from the sensor, process them and display the result on
the LCD display.
The microcontroller board:
Circuit explanation:
The LCD connections
in the green shading is a standard for most of
alpha numeric LCDs, the only feature I added is to be able to
control the back light via the 80c52 microcontroller. The LCD
protocol can seem complicated to some of you, and an article should
be released soon to explain it.
The part in the blue shading
is also standard in any 8051 microcontroller circuit, which includes
the reset circuitry along with the crystal resonator that generates
the clock pulses required.
The power supply, shaded in light
red, regulates a 9V rechargeable Ni-CD battery
and also provides a very simple battery monitor, with a green
and a red LED, showing whether the battery need to be recharged
or not.
The switch SW1, shown in the upper yellow circle, is used to enable/disable
the measurement or the counting process. When the switch is pressed,
the device measures the RPM of the shaft under test, and constantly
updates the reading on the LCD, when the switch is released, the
last reading is held unchanged on the display, as long as the
device stays on. When the switch is pressed again the old reading
is replaced by the new one.
The wire connection P1, which is connected to
the output of the sensor, is connected to the pin 3.4 of the microcontroller, this pin has a dual function which is to count incoming
pulses and increment a 8, 13, or 16 bit register according to
the configuration of the timer T0.
As you may have noticed, this schematics misses tow important
items to be called a tachometer: The C code loaded into the microcontroller, which will be discussed later, and the proximity sensor,
which will feed the pulses to be counted.
The modified IR proximity sensor:
This schematic show the slight modification over
the one proposed in this tutorial,
which is the fact that the emitter LED uses a current limiting
resistor of a higher value, to allow it to be turned on for a
long period of time, because in this specific application, we
need to turn the IR emissions on or off, but we don't need to
inject high currents to reach high ranges... I recommend the reading
of this article that fully covers
all the aspects of this sensor.
The CTRL line, is an input coming from the microcontroller (at
the wire connection: P4), turning the IR emissions ON and
OFF, and the OUT line, is the output of the sensor, which is fed
to the microcontroller (at the wire connection: P1).
After analyzing both the main board holding the microcontroller
and the sensor, here is a simple
diagram
showing how they are connected together. You will have
to refer to the above schematics to see where P1, P2,
P3 and P4 goes in the main board, as well as the other
lines concerning the sensor.
|
|
 |
This
picture also shows what is meant by the connection of
the sensor to the main board. The reason for separating
the sensor from the main board, is to allow better performance
sensors, or even other types of sensors to be connected
to the device. In general, modular designs cost more,
but is more useful in the prototyping phase... |
The
software
Here are only small relevant parts
of the full C program, that was loaded into the microcontroller
after being compiled to a HEX file. Those part of the code were
selected as the ones that emphasize the main purpose of a microcontroller in such an application. For examples, function dealing
with the LCD operation are not included in this description. Comments
in green explains the program. The full code is available in the
Project folder, downloadable at the bottom of this article
.
#include
<REGX51.h>
#include <math.h>
unsigned
int clk_tmp,clk_tmp2,clk_sec,clk_sec2;
unsigned intex_pulses,rps,rps_tmp,temp,rps_avg,rps_max;
unsigned int rps_his[5];
char a,b,c,d,e;
unsigned char count1,count2;
unsigned char scale = 4;
delay(y){ // A function to make software
delays
unsigned int i;
for(i=0;i<y;i++){;}
} setup_interrupts(){
// This function initialises the
TIMER and the COUNTER to
EA = 1; //
be used in in the trachometre
ET0 = 1; //set
the Timer/counter 0
TR0 = 1; //Enable
Timer/counter 0 to count
TMOD = 0X25; //counter 0 in
mode 1 (16 bit counter),
//timer
1 in mode 2 (auto reload from TH1)
TH1 = 0; //start
counter from 0
ET1 = 1; //enable
timer 1
TR1 = 1; //Enable
Timer/counter 1 to count
PT0 = 1; //Setup
the priorities of timer 1 and timer 0, a 0 gives a
PT1 = 0; //higher
priority.
}
void int_to_digits(unsigned int number){ //store
the 5 digits of an integer
float itd_a,itd_b; //number
in the variable a,b,c,d,e
itd_a = number / 10.0;
e = floor((modf(itd_a,&itd_b)* 10)+0.5);
itd_a = itd_b / 10.0;
d = floor((modf(itd_a,&itd_b)* 10)+0.5);
itd_a = itd_b / 10.0;
c = floor((modf(itd_a,&itd_b)* 10)+0.5);
itd_a = itd_b / 10.0;
b = floor((modf(itd_a,&itd_b)* 10)+0.5);
itd_a = itd_b / 10.0;
a = floor((modf(itd_a,&itd_b)* 10)+0.5);
}
clk() interrupt 3 //timer
1 interrupt
{
clk_tmp++; //Software
counter for the timing of the tachometer readings
clk_tmp2++; //Software
counter for the display refresh rate
if (clk_tmp2 > (1236)){ //
update display
clk_tmp2 = 0;
rps_avg = floor(((rps_his[0] + rps_his[1] + rps_his[2]
+ rps_his[3] + ___
___rps_his[4])/5)*60);
}
if
(clk_tmp > (6584/scale)){ //
update the measured RPM
clk_tmp = 0;
if (P2_0 == 0){
rps = TL0;
temp = TH0;
temp = temp * 256;
rps = (rps + temp)* scale;
rps_his[4] = rps_his[3];
rps_his[3] = rps_his[2];
rps_his[2] = rps_his[1];
rps_his[1] = rps_his[0];
rps_his[0] = rps;
}
TL0 = 0;
TH0 = 0;
}
}
count_pulses() interrupt 1 //counter
0 interrupt
{
if (scale < 10) //
If the pulses are so fast that the internal counter
scale++; //
overflows, increase the variable 'scale' so that
} //
so that readings are recorded at a higher rate
void main(){
scale = 10 ;
P3_3 = 0; // ini
proximity sensor, OFF
P3_4 = 1; // ini
sensor input
P1_1 = 0; //turn
LCD backlight ON
P2_0 = 1; //ini
count/hold button
ini_lcd(); //
ini the LCD
setup_interrupts();
while(1){
P3_3 = ~P2_0;
if
(P2_0 == 1){
scale=
4;
}
}
}
|
To understand the functioning of this source code, you must have
some basic microcontroller and C language skills.
The variable scale is used to control
the rate at which the tachometer reads and resets the counter.
The
housing of the tachometer
For the housing, an old floppy disk drive case is used,
where the tachometer and the battery fits perfectly. Here,
those few pictures are worth a thousands words.
(click on a picture to enlarge)
Download
the zip file for the project.
containing the PCB, Schematic and Example
8051 C51 code.
[note: i use ExpressPCB(FREEWARE)
to design the schematics and the PCB]
|
Preview of the last 15
messages discussing this page. Messages are sorted from the newest to
the oldest. |
 |
Posted
by:
ikalogic
on:
22 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting Valentino_Resi: assalamualaikum ika.. I'v build you tachometer, but till today my devices didn't work yet. it just show 0000rpm. i use at89s52 on mikro. i'v check the cable, sensor and it work well. my sensor give 2,88volt at the output when reflect from the object & 0 volt when free. then i use ac adaptor as a pulse at input to the mikro. i start from 3volt-9volt & there's no respon from the mikro. then please your suggest to solve my problem?? onemore question, what the function of lm358 on power supply(red shading)?
please for your help thanks...
Wassalamualaikum.. |
Alikom el salam,
1- it's not normal that the sensor outputs 2.8 v, it should output more than 4V 2- I don't understand what you did with the AC adaptor...??! 3-9 Volts?! what is all that about?
|
|
|
|
 |
Posted
by:
valentino_resi
on:
22 Jul 2008 |
99 000 RPM Contact-Less Digital Tachometer |
|
 |
assalamualaikum ika.. I'v build you tachometer, but till today my devices didn't work yet. it just show 0000rpm. i use at89s52 on mikro. i'v check the cable, sensor and it work well. my sensor give 2,88volt at the output when reflect from the object & 0 volt when free. then i use ac adaptor as a pulse at input to the mikro. i start from 3volt-9volt & there's no respon from the mikro. then please your suggest to solve my problem?? onemore question, what the function of lm358 on power supply(red shading)?
please for your help thanks...
Wassalamualaikum..
|
|
|
|
 |
 |
 |
Posted
by:
marcello
on:
17 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting ikalogic: Pardon me for the misunderstanding!
About the amplifiers, i'll be the first one that will need help in that issue, as i need to build a good one for my car's home-made MP3 player...... it's a long story! lol
Ok, so to get started on your side, do you at least have to material needed to program a 89S52 ? i can send you the codes, when i get time to do them, but can you download them to the uC ? |
Hello again Ibrahim and please don't worry it is just a misunderstanding.
Concerning the amplifiers you can ask me anything you want, it's really a great pleasure for me.
Concerning the 89S52 as I told you in my previous mail I am not organised to manage with microntrollers but if you do me the favor to send me the codes I can let a friend download it and transfer them to the uC and then according to your diagram I will make the rest to realised the device. This sound ok for you? Please let me know also if I will need any special program or special tools to manage this. Please take your time I am not hurry, and in case that you may need any more inforamtion please let me know.... All the best...Marcello.
|
|
|
|
 |
Posted
by:
ikalogic
on:
17 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Pardon me for the misunderstanding!
About the amplifiers, i'll be the first one that will need help in that issue, as i need to build a good one for my car's home-made MP3 player...... it's a long story! lol
Ok, so to get started on your side, do you at least have to material needed to program a 89S52 ? i can send you the codes, when i get time to do them, but can you download them to the uC ?
|
|
|
|
 |
Posted
by:
marcello
on:
17 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting ikalogic: I think - keeping in mind you're level of experience in 8051 - that it would be much better for you to start with the 89S52 (which is equivalent to the 89C52 but can be programmed with our easy to build ISP programmer).
The code is compatible without any changes with the 89S52.
you can start by understanding the principles of 8051 and C programming with this tutorial:
http://www.ikalogic.com/tut_8051_1.php
 |
Dear Ibrahim,
Maybe there is a misunderstanding in all of this, my intent was only to modified your original project in order to let the device works in an other way,and just to allow me to calibrate certain instruments and that is all. I don't need to make projects or to study PIC's not because PIC's are not interesting but simply because my field is different, my hand made Class A amplifiers are playing around the world in the best recording studio's and thanks God I am proud of this. By the way in case that any one in this forum need any help on this field I will be happy to do all my best for free.
My best wishes, Marcello.
|
|
|
|
 |
Posted
by:
ikalogic
on:
16 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
I think - keeping in mind you're level of experience in 8051 - that it would be much better for you to start with the 89S52 (which is equivalent to the 89C52 but can be programmed with our easy to build ISP programmer).
The code is compatible without any changes with the 89S52.
you can start by understanding the principles of 8051 and C programming with this tutorial:
http://www.ikalogic.com/tut_8051_1.php
|
|
|
|
 |
Posted
by:
marcello
on:
16 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting ikalogic: Nice...
my response:
1) very good, you're one step from mastering the electronics .. microcontroller are not difficult..
2) If you want smaller ones, you can stay in the 8051 world, with very litle modifications by using the 89C2051
3) so far so good!
I think you should get sarted by getting your hands dirty in the microcontroller part, this is where it will get the most messy for you!
waiting for your questions. |
Thanks for your replay,
I can stay in the 8051 no problem but sincerly I have no idea on how I will let this microcontroller works as I need.... so I will appreciate very much any kind of help....
|
|
|
|
 |
Posted
by:
ikalogic
on:
16 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Nice...
my response:
1) very good, you're one step from mastering the electronics .. microcontroller are not difficult..
2) If you want smaller ones, you can stay in the 8051 world, with very litle modifications by using the 89C2051
3) so far so good!
I think you should get sarted by getting your hands dirty in the microcontroller part, this is where it will get the most messy for you!
waiting for your questions.
|
|
|
|
 |
Posted
by:
marcello
on:
16 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting ikalogic: ok..
seems pretty easy and very much doable!
do you have C programming skills?
microcontroller skills?
which uC are going to use, the same 8051?
do you have the magnetic sensor and the beeper/vibration transducer ? |
Excellent!!! so here my response to your questions.
1)- I don't have a good skill in c programming & microcontrollers but I have a friend who can help me on this. I can realize any kind of electronic / electromechanical project / devices included PCB but not strong enough in PLC. Excellent in Analog!!!
2)- If there is no problems can we use the same 8051? Once I have see inside a small made in China Tachometer that they have used a smaller 16F628 PIC can we use the same or a similar?
3)- Yes I have many kind of magnetic sensors and concerning the buzzer I can use a piezo operating voltage 1-12VDC or a micro vibration motor as the one used in mobile phones & pagers, operating voltage 2,3-4.0 VDC.
Thank you again....Marcello.
|
|
|
|
 |
Posted
by:
ikalogic
on:
15 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
ok..
seems pretty easy and very much doable!
do you have C programming skills?
microcontroller skills?
which uC are going to use, the same 8051?
do you have the magnetic sensor and the beeper/vibration transducer ?
|
|
|
|
 |
Posted
by:
marcello
on:
15 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting ikalogic:
Quoting Marcello: Dear Ibrahim,
First of all I would like to send you my compliments for this great work! Regarding the Tachometer I would like to ask you: are you able to help me to make some modifications concerning the output of this device?
Thank you in advance. Best wishes. Marcello. Milano- Italy.
By the way I was born in Alexandria..... |
Sure, i am ready to.
Would you, on your side, be ready to provide pictures and schematics for your final version (when it's done), to add it here for other visitors?
best of luck, and we stay on touch
ika |
Hello again and thank you for your replay, yes I confirm you that I am able to provide pictures and schematics for any interested visitor on this site.
What I would like to realize is in the following explanation:
1) I would like to use the tachometer only through a magnetic contact sensor so I will eliminate the contact less circuit.
2) Then I would like to eliminate also the display and I would like to get the speed reading results through a beeper or through a vibrations unit, this will allow me to avoid to look continuously to the display.
3) Because the mesures ranges that I need to know are only 4 and they are quiet low, (I will use the device only for calibrations works)the layout of the device should works like the following example:
From 27.00 RPM > 28.00 RPM > output result 1 short Beep or Vibration.
From 28.10 RPM > 29.00 RPM > output result 2 short Beeps or Vibrations.
From 29.10 RPM > 30.00 RPM > output result 3 short Beeps or Vibrations.
From 30.10 RPM > 31.00RPM > output result 1 long Beep or Vibration.
Do you think it could be realized?
Thank you again....Best wishes...Marcello.
|
|
|
|
 |
Posted
by:
ikalogic
on:
15 Jul 2008 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting Marcello: Dear Ibrahim,
First of all I would like to send you my compliments for this great work! Regarding the Tachometer I would like to ask you: are you able to help me to make some modifications concerning the output of this device?
Thank you in advance. Best wishes. Marcello. Milano- Italy.
By the way I was born in Alexandria..... |
Sure, i am ready to.
Would you, on your side, be ready to provide pictures and schematics for your final version (when it's done), to add it here for other visitors?
best of luck, and we stay on touch
ika
|
|
|
|
You have
to be a member to post replies. |
|
|
|