Username:    Password: Remember me
Follow us:

NEW: IKA-TACH, the new version of this tachometer! More accuracy, more compact design, AVR based!

99 000 RPM Contact-Less Digital Tachometer
Featuring LCD display and automatic DATA hold function
By Ibrahim Kamal
Last update: 14/7/10

Overview
This article describes how to build a contact -less tachometer (device used to count the revolutions per minute of a rotating shaft) using a 8051 microcontroller and a proximity sensor.

As the name implies, what makes this device special, is that it can very accurately measure the rotational speed of a shaft without even touching it. This is very interesting when making direct contact with the rotating shaft is not an option or will reduce the velocity of the shaft, giving faulty readings.

This device is built on an AT89S52 (or AT89C52) microcontroller, an alpha-numeric LCD module and and a proximity sensor to detect the rotation of the shaft whose speed is being measured.

A 600 mA.h Ni-Cd battery provides months of regular use of this device before it needs to be recharged.


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]

Discussion (Last 15 posts preview...)
Preview of the last 15 messages discussing this page. Messages are sorted from the newest to the oldest.
Posted by:
uttam
on: 30 Jan 2012
Re: 99 000 RPM Contact-Less Digital Tachometer
['Quote ]

Quoting arunsaifi: hello sir,
i had run the code using kiel. but a problem occuring in hardware and it not getting inturrept from sensor, so counter on lcd showing oooo value. off time sensor output voltage is 3.5v and on time voltage is 4.8. i think both is logic one i had used another circuit for sensor. but problem is due to sensor on command. i m trying to swich the sensor using transistor. is it not working if we provide ground to emmiter directly.


arun yadav



M/S Arun,
Then try the hexcode provided by Ika in his site, the check the hardware in each point. hope you get the fault. I made it , it works!
regards- Uttam
Posted by:
arunsaifi
on: 30 Jan 2012
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
hello sir,
i had run the code using kiel. but a problem occuring in hardware and it not getting inturrept from sensor, so counter on lcd showing oooo value. off time sensor output voltage is 3.5v and on time voltage is 4.8. i think both is logic one i had used another circuit for sensor. but problem is due to sensor on command. i m trying to swich the sensor using transistor. is it not working if we provide ground to emmiter directly.


arun yadav
Posted by:
yptrio1
on: 15 Jan 2012
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
What change
Posted by:
vinuchandran.a.v
on: 06 Jan 2012
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
Please upload the code and schematic again..
Posted by:
joefliz
on: 15 Dec 2011
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
for "The modified IR proximity sensor" image, u use IR LED for sender, and also another IR LED for receiver. correct me if im wrong. what type of emitting diode u use at receiver which is D3? just to make sure before buying the component, ty
Posted by:
cm rangan
on: 10 Dec 2011
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
can u give a complete code that also included the display on lcd code?
Posted by:
cm rangan
on: 10 Dec 2011
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
cant actaully open the attachement? just said its corrupted? whats goin on here
Posted by:
salleh
on: 07 Dec 2011
Re: 99 000 RPM Contact-Less Digital Tachometer
['Quote ]
sir can u give me the specific name of keil sofware that u used in this project?for the information i has download the keil version 2 but i did't know how to instal it,,
Posted by:
uttam
on: 06 Dec 2011
Re: 99 000 RPM Contact-Less Digital Tachometer
['Quote ]

Quoting joefliz: can u give a complete code that also included the display on lcd code?


Joefliz,
every thing is readymade available in the relevent topic, please download relevent Zip file and compile, for compilation see the basic topic available in this site (Home page)
or readymade .file , only this you need to download, please patiently go through the different pages of this site , you get evey thing you are asking for, now question of understanding the code, you need C programming knowledge.
Regards,
Uttam
Posted by:
joefliz
on: 06 Dec 2011
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
can u give a complete code that also included the display on lcd code?
Posted by:
salleh
on: 05 Dec 2011
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
hello sir,may i ask u about the coding that u post in this discussion,,why i cant run the coding,,i try it many time but iit alway give an error like this,,"C:\MCC18\lkr\project3.c:1:Error [1027] unable to locate 'REGX51.h' ",,,may i know the name of software that u use to run the program?or can u give to me the software,,,
Posted by:
salleh
on: 05 Dec 2011
Re: 99 000 RPM Contact-Less Digital Tachometer
['Quote ]
hello sir,i'm student and have many question to ask u,,,
firstly may i get overall coding of this project ?
2.where do u compile the coding that u write in this project?i had write the half coding that u gave and i try build the coding at mplab but there has some error,,,the error about REG,,,

i need this answer urgently because i had take ur project to be my final year project,,and i'm sory because i take ur project to be my project,,,this semester i have to submit the hardware of this project,,,i'm very appreciate if u can help me,,, tq
Posted by:
herodientu1
on: 03 Nov 2011
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
[size=150>I wonder because I did not complete in C problem should only do what has to. but when writing to 89c51 programming error, the program too much programming data from the memory of the IC. I'm very in parcel and would not have solutions to experienced guidance or replaced with an IC containing a complete program. thank[/size>
Posted by:
uttam
on: 16 Oct 2011
Re: 99 000 RPM Contact-Less Digital Tachometer
['Quote ]

Quoting aurelio: sir, good morning. i work a project about wind speed monitoring and it seems so hard to build a hall switching device...can a proximity sensor is fit to change that? and i used pic16f84a micro controller. is it ok to load your source code in mplab 8.50 and to program in icd2?

i am very appreciated your answers and reply...
more power.

Hello Aurelio,
Same source code will not work for PIC16f84a, you need to develop completely separate source code for PIC micro, otherwise better to use atmel micro as mentioned, but I will suggest you to build "IKA-TACH: Our new contact less tachometer project" as per sensor part , I want to know how you are going to make your project for measurement of wind speed, I had some experience to work with hall sensor, it works flawlessly, but I want to know your project details.
regards,
Uttam Dutta
Posted by:
aurelio
on: 15 Oct 2011
99 000 RPM Contact-Less Digital Tachometer
['Quote ]
sir, good morning. i work a project about wind speed monitoring and it seems so hard to build a hall switching device...can a proximity sensor is fit to change that? and i used pic16f84a micro controller. is it ok to load your source code in mplab 8.50 and to program in icd2?

i am very appreciated your answers and reply...
more power.
You have to be a member to post replies.
Username: Remember me
Register now! it only takes an instant.
Forgot your password?
ikalogic.com: Electronics and Robotics related projects.
All content on this site is provided as is and without any guarantee of any kind. We cannot be held responsible for any errors, omissions, or damages arising out of use of information available on this web site.
Creative Commons License
IMPORTANT COPYRIGHT NOTE: Electronics and Robotics Articles by Ibrahim KAMAL are licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.