Introduction
Tachometer is a device that gives you the information about the rotational speed of any shaft or disc. It usually measures the speed in revolutions per minute (RPM). Today we are going to make a simple tachometer that could measure the rotation speed of a disk without making any physical contact (that's why it is contact less) with the rotating object. The range of this tachometer is 0 - 9999 RPM and displays the RPM on a multiplexed 4-digit seven-segment display. Of course, we are going to do this project on our usual PIC16F628A development board.
Infrared sensor
Contact-less measurement of RPM will be achieved through an IR sensor. An IR diode will send a beam of infrared towards the rotating disc, and any reflected pulse will be received by a photo diode. The resistance of a photo diode drops drastically when exposed to infrared. An infrared is reflected by a white surface and absorbed by the dark ones. The test disc for this project is shown below. You can see the disc is black and will absorb any infrared falling upon it. A small piece of white paper sticked to the disc as shown is just enough to reflect the infrared back. This will give one reflected IR pulse per rotation which is sensed by the photo diode.
The IR transmitter and receiver circuit is very simple. The IR sensor module built for this purpose is shown below followed by the circuit diagram.
Tachometer is a device that gives you the information about the rotational speed of any shaft or disc. It usually measures the speed in revolutions per minute (RPM). Today we are going to make a simple tachometer that could measure the rotation speed of a disk without making any physical contact (that's why it is contact less) with the rotating object. The range of this tachometer is 0 - 9999 RPM and displays the RPM on a multiplexed 4-digit seven-segment display. Of course, we are going to do this project on our usual PIC16F628A development board.
Infrared sensor
Contact-less measurement of RPM will be achieved through an IR sensor. An IR diode will send a beam of infrared towards the rotating disc, and any reflected pulse will be received by a photo diode. The resistance of a photo diode drops drastically when exposed to infrared. An infrared is reflected by a white surface and absorbed by the dark ones. The test disc for this project is shown below. You can see the disc is black and will absorb any infrared falling upon it. A small piece of white paper sticked to the disc as shown is just enough to reflect the infrared back. This will give one reflected IR pulse per rotation which is sensed by the photo diode.
The IR transmitter and receiver circuit is very simple. The IR sensor module built for this purpose is shown below followed by the circuit diagram.
IR Tx is the control signal to turn On and Off the IR transmission. The PIC16F628A microcontroller will turn the IR diode on for 1 sec, and will count the reflected pulse during this interval through IR Rx Pulse output. During normal condition, the photo diode (IR Rx diode) offers high impedance (tens of K) and so the voltage across it will make the BC557 transistor in the receiver part (right) cut off. The IR Rx Pulse will be at logic low. When there is a reflected pulse, the resistance of the photo diode (IR Rx diode) will drop down and allow BC557 transistor to saturate. This gives a logic high at IR Rx Pulse output. The PIC 16F628A will count the pulses within the 1 sec interval to determine the RPM of the disc. Actually, it takes 3 samples of RPM and gives the average. So, the measuring time is 3 sec. The pulses will be counted by Timer0 counter.
Microcontroller Circuit
I suggest to see the circuit diagram of the development board (PIC16F628A Dev Board) first and then follow the instructions below.
- Seven segment displays used are common cathode type. The seven segments (a-g) are driven through RB0-RB6 respectively. The 4 common cathodes are controlled by RA0 (units digit) through RA3 (thousands digit).
- IR Tx is connected to RB7
- IR Rx Pulse is connected to RA4/T0CKI
Software
Compile this code with mikroC. I am using 4.0MHz external crystal for clock and MCLR is enabled.
/*
* Project name: Contact less digital tachometer
* Copyright:
(c) Rajendra Bhatt, October, 2010.
* Test configuration:
MCU: PIC16F628A runs @ 4.0 MHz external crystal oscillator
The common cathodes of the four seven segment dispalys are
controlled by RA0, RA1, RA2 and RA3
*/
//-------------- Function to Return mask for common cathode 7-seg. display
unsigned short mask(unsigned short num) {
switch (num) {
case 0 : return 0x3F;
case 1 : return 0x06;
case 2 : return 0x5B;
case 3 : return 0x4F;
case 4 : return 0x66;
case 5 : return 0x6D;
case 6 : return 0x7D;
case 7 : return 0x07;
case 8 : return 0x7F;
case 9 : return 0x6F;
} //case end
}
sbit IR_Tx at RB7_bit;
sbit DD0_Set at RA0_bit;
sbit DD1_Set at RA1_bit;
sbit DD2_Set at RA2_bit;
sbit DD3_Set at RA3_bit;
unsigned short i, DD0, DD1, DD2, DD3;
unsigned int Sample1, Sample2, Sample3, RPM;
void main() {
TRISB = 0b00000000; // Set PORTB direction to be output
TRISA = 0b00110000; // Set PORTA direction to be output
PORTB = 0x00; // Turn OFF LEDs on PORTB
CMCON = 7 ; // Disable comparators
RPM = 0; // Initial Value of Counter
OPTION_REG = 0b00111000; // TOCS=1 for Counter mode, PSA=1 for 1:1
IR_Tx = 0; // Turn OFF IR
do {
DD0 = RPM%10;
DD0 = mask(DD0);
DD1 = (RPM/10)%10;
DD1 = mask(DD1);
DD2 = (RPM/100)%10;
DD2 = mask(DD2);
DD3 = (RPM/1000);
DD3 = mask(DD3);
for (i = 0; i<=100; i++) {
PORTB = DD0;
DD0_Set = 1;
DD1_Set = 0;
DD2_Set = 0;
DD3_Set = 0;
delay_ms(5);
PORTB = DD1;
DD0_Set = 0;
DD1_Set = 1;
DD2_Set = 0;
DD3_Set = 0;
delay_ms(5);
PORTB = DD2;
DD0_Set = 0;
DD1_Set = 0;
DD2_Set = 1;
DD3_Set = 0;
delay_ms(5);
PORTB = DD3;
DD0_Set = 0;
DD1_Set = 0;
DD2_Set = 0;
DD3_Set = 1;
delay_ms(5);
}
DD3_Set = 0;
// First Sample
TMR0=0;
IR_Tx = 1;
Delay_ms(1000); // Delay 1 Sec
IR_Tx = 0;
Sample1 = TMR0*60;
// Second Sample
TMR0=0;
IR_Tx = 1;
Delay_ms(1000); // Delay 1 Sec
IR_Tx = 0;
Sample2 = TMR0*60;
// Third Sample
TMR0=0;
IR_Tx = 1;
Delay_ms(1000); // Delay 1 Sec
IR_Tx = 0;
Sample3 = TMR0*60;
RPM = Sample1 + Sample2 + Sample3;
RPM = RPM/3;
} while(1); // endless loop
}
Output
The tachometer is tested for various speeds of the rotating disc. The speed is varied by varying the voltage across the motor driving the disc. I got this motor-disc assembly from my old broken printer.
Setup
Slow speed
Fast speed
i am doing same project & my microcontroller is not getting desired pulse & giving me high amount of rps
ReplyDeletegive me sol.
Say more detail about the problem? Are you trying to exactly replicate this project? Or what PIC are you using, do you have your circuit diagram and code?
ReplyDeletePlease,how can you be of help to me,i need the circuit diagram probably posted to my email address. i will be glad if this request of mine is granted. am proposing to have for my final year project.
ReplyDeleteWhat is your email address? And what circuit diagram you are talking about?
ReplyDeletesir in your development board you use 7 segment display-commom cathode for contactless tachometer and your software you use commom anode.Please send me HEX code for 7 segment display- common cathode. Thanks. my email add poss_ray2005@yahoo.com
ReplyDeleteSorry, that statement in the code was a mistake. This program is actually for common cathode. You can compile it with MikroC Pro for PIC. It will work.
ReplyDeleteThank you for your immediate response. Sir I made a parallel port pic programmer (tait,7407(driver)+pnp transistors) and load/program the compiled HEX CODE (165 bytes) to pic 16f628a using WIN PIC software. Result is success no error but when I connect it to the circuit of contactless tachometer it did not work. Please advice.
ReplyDeleteHave you tried your programmer with a simpler project to see if it works? You can do that by testing with a simple LED flashing example. If you confirm that your programmer successfully program the PIC, then what are your configuration bit settings? If you have enabled MCLR, you need to pull the MCLR pin to +5V. You can check the configuration settings by clicking on Project->Edit Project on MikroC project editor.
ReplyDeletegood, thx for your ideas!!
ReplyDeletethe whole circuit diagram for the design of contactless Tachometer and the design calcultion.haryurmide@googlemail.com
ReplyDeletesir i have compiled several times the code of your contactless tachometer using micro c pro for PIC which i have downloaded just thesame the HEX files ( 179 bytes only) when program using PICKIT 2 programmer is success but still my project is not working. Sir can you please send the complete HEX file to my e-mail address Poss_ray2005@yahoo.com . The configuration Register- Config: $2007:0X216A
ReplyDeletePoss_Ray,
ReplyDeleteWhat is actually happening when you power your circuit? Do you see any display on seven segment? Even if the IR part didn't work, you should at least see the display values (all zeros) on seven segments. Can you send me your circuit diagram at rajbex at gmail dot com?
Sir NO display values (all zeros) on seven segments when I supply power on my project even 5VDC is present in pin#5(-) and pin#14(+). I will send to your e-mail the circuit diagram and picture of PICKIT-2 apllication window loaded w/ my compiled HEX files. My suspect something is lacking on my compiled HEX file (179 bytes)because when I program PIC16F628a with HEX files (2 KB) of Tachometer-II by Josefino.com it is working. Thanks again for your immediate response sir.
ReplyDeletehy can you email the full project cz mine is quite the same
ReplyDeleteakram_muharam@yahoo.com
Good day Sir.can you send me the complete diagram of the system.I am looking for reliable tachometer circuit, my 8051-based failed.please email it to me
ReplyDeletedeonelenevld@gmail.com
my deepest gratitude.thanks.
Hi !
ReplyDeleteThis project is very good.
But the measurement isn’t very accurate because if you have let’s say 5 and a half pulses you will get only 300 RPM instead of 330 RPM.
Regards George.
George,
ReplyDeleteI agree with you. For lower speed the error % is high. So, instead of counting pulses, the time duration between two pulses should be measured to improve accuracy.
sir im trying 5 digit contactless techometer please give me the circuit discription and all thing regarding the project...my email id is adityak103@gmail.com
ReplyDeletehi everybody . . . i want to build 0-50 dc voltmeter using pic16f628a with 7segments display. please help me !
ReplyDeleteHi Raj! Why do you multiply by 60 TMR0 ?
ReplyDeletethank you!
marC:)
Raj... i connected the tachometer and all the display are indicating 0000 and i tested it with my bike, no result, can you help?
ReplyDeletewould be greatly appreciate!
thanks!
marC:)
sir,
ReplyDeletemy project is microcontroller based tachometer please give me some idea how to proceed the project.
Hi! I have built this circuit and yes I am having my 7 segment display 0000 but the thing is I cant read any rpm!!!! can u plz help me on this!!!! Plzzzzzz
ReplyDeletePlz I want a quick help! I have tried to throw some IR using my Remote Control and the flashing/ blinking of 7 segment actually stops momentarily after being done with it........ it seems like transmitter and receiver are working!!! What do u say???
ReplyDeletei need file hex , thanks
ReplyDeleteletuanvinh449@gmail.com
Such detailed information about the Tachometers. Click here for detailed information on Tachometer
ReplyDeleteHI I WANT TO WRITE A CODE FOR CALCULATION OF RPM I HAVE WRITTEN MOST SETS BUT I WAT A ACCURACY OF 1HZ TO 500HZ USING CCP6 IN PIC18F87K22
ReplyDeletePLS SEND ME THAT LOGIC CALC OF UR TO THE COVERSION OF CCP TMR BITS TO RPM..
THANKS FOR THE HELP
AND MY MAIL Is shivadreams8@gmail.com..
HI I WANT TO WRITE A CODE FOR CALCULATION OF RPM I HAVE WRITTEN MOST SETS BUT I WAT A ACCURACY OF 1HZ TO 500HZ USING CCP6 IN PIC18F87K22
ReplyDeletePLS SEND ME THAT LOGIC CALC OF UR TO THE COVERSION OF CCP TMR BITS TO RPM..
THANKS FOR THE HELP
AND MY MAIL Is shivadreams8@gmail.com..
pls pls its urgent..
thx for your efforts
ReplyDeleteplease i need all the details related to this project for my final project in univ.
email amer_khwa@yahoo.com
Will you plz post the code and the schematics for LCD display and rpm up to 99,000 Using PIC16f628a
ReplyDeleteCan u plz specify components used in this project. I'm confused about which components should I select. I'm using pic18f4550 micro controller
ReplyDeletehello
ReplyDeletecould you send the shcematic of this circuit to my email?
thanks for your good project.
email: kaboy1@gmail.com