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
| |
|
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:
sumantaoo
on:
08 Jul 2010 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
thank you sir for your help
now if i keep a reflecting object the red LED is glowing and when i remove it its not thats working fine as per your earlier reply.
but when i connect the 14,13 pin of mc to 3 , 7 pin respectively of 1st and 2nd lm358 and hold SW1 the lcd displays ". o 0 and ends with x" .and no rpm is displayed in both the line ie avg and max
i have oriented my IR led towards the white disk which is connected to a 300 rpm motor but still nothing works plzz help now .
sugest some future steps.
regards sumanta roy
|
|
|
|
 |
Posted
by:
uttam
on:
01 Jul 2010 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting sumantaoo: thank you i have done the same as u said and the LCD is working perfectly .
but my transmitter and reciever are not working .i have rechecked the connection , also i have read the article on IR proximity detector in this site .but i am unable to figure out the possible way to see that tran. and reci. are working or not
help me how should i check the IR transmission and reception ckt .and plzz tell how did you do it. also should the red led on the receptor ckt should always glow ???
regards sumanta |
No red LED will not glow always, keep some reflecting object infront of transmitter and receiver circuit and adjust the preset/Pot (10 K POT of receiver circuit) with patience ... if there is no any hardware mistake then it will work ! one thing -- try to understand how lm358 woking here as voltage comparator , You will get confidence to make it work, I made this circuit and it worked without any hardware modification. ! Regards, Uttam
|
|
|
|
 |
Posted
by:
ikalogic
on:
01 Jul 2010 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
If the RED led on the receiver Ir circuit is always glowing, then you're in saturation. try playing with the potentiometer to change the sensitivity.
the red led should only glow when IR is reflected to the sensor.
|
|
|
|
Posted
by:
sumantaoo
on:
01 Jul 2010 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
thank you i have done the same as u said and the LCD is working perfectly .
but my transmitter and reciever are not working .i have rechecked the connection , also i have read the article on IR proximity detector in this site .but i am unable to figure out the possible way to see that tran. and reci. are working or not
help me how should i check the IR transmission and reception ckt .and plzz tell how did you do it. also should the red led on the receptor ckt should always glow ???
regards sumanta
|
|
|
|
Posted
by:
uttam
on:
01 Jul 2010 |
|
|
Posted
by:
uttam
on:
30 Jun 2010 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
| Quoting sumantaoo: can some one explain me how to make the LCD connections with the port 0 pins on the bread board ??? |
You have to solder single strand wire with LCD terminal (be careful with LCD pin numbers) and then other side of the wire to be connected in breadboard ... if I understand your question, in fact it is very comfortable to work in breadboard regards, Uttam Dutta
|
|
|
|
 |
 |
 |
Posted
by:
uttam
on:
16 Jun 2010 |
99 000 RPM Contact-Less Digital Tachometer |
|
 |
Finally it works, I am sorry to say that it was my blunder mistake of identifying LCD pin numbers, somehow it was in my mind that LCD pin starts from left side (keeping pins bottom side)and every time I was doing same mistake keeping other things ok. After normalizing the LCD connection it starts working ( program works without any modification) I am really sorry you spend enough time for me and It was my fault. circuit works perfectly, I am sending you some pics. by email.
I take out the blades from table fan and put a fully black colored CD with 1 inch by 1 inch white reflector, when rotates giving RPM but when I lowering the speed( by electronic fan regulator) display shows more rpm ( and when stopped rotation showing 0 rpm - it is ok) means in higher rpm it is giving steady and reliable rpm, but in lower speed why rpm showing more and very fluctuating also. Thanks and regards, Uttam Dutta
|
|
|
|
 |
 |
Posted
by:
uttam
on:
13 Jun 2010 |
99 000 RPM Contact-Less Digital Tachometer |
|
 |
I have used a very stable DC power supply.(http://jnaudin.free.fr/html/s_30vdc.htm), input is 220 , output variable DC, 1.2 to 30 V, I set it in 5V for this project. I dismantle the complete hardware and assembled it again but problem became the same , only bot. line of LCD flashing like before !(all 5 X 7 dot matrix unit of the line become prominent and flashing), if width of "ena" is increased then flashing frequency decreased only. Checked the voltage in pin 2 of LCD it is 4.99 V. Again I checked the each and every point of hard ware, they are as per your schematic and no shorting / connection problem found,( this time I removed sensor i.e. the pin connection of 13 and 14 of micro) probably there is no hardware problem, I do not understand the software completely but it should work as you made it work. Then where .....the problem... (I also put little delay with ini sequence and increased the width of ene -- but not worked) I know you are busy with other project, but do you kindly give little time with my problem and suggest some solution. Regards, Uttam Dutta
|
|
|
|
 |
Posted
by:
ikalogic
on:
11 Jun 2010 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting uttam: Thank you for giving confidence and valuable guidence.. I increased the pulse width of "ena" as you told
like this ena(){ P2_7 = 1; [u][b]delay (50000); // delay (5);-- original P2_7 = 0; } There was significant change in blinking pattern of LCD bot line, (blinking frequency become slow enough) but there was no character or any thing else in LCD two more thing I want to tell you 1) there was voaltage change in pin 39 to 32(7 to 14 of LCD) of micro from 4.99 to 1.96 V(by multimeter)but no reflection in LCD. 2)there is always a 4.9V available in sensor's "ctrl" terminal and it is working without pressing the button connected with pin 21 of micro and ground.
Please tell me what should I do next Regards, Uttam Dutta |
hmm... if the micro is working, and the software is the same.. there must be an issue in the hardware somewhere.. i assume you already double checked all the connections, and made sure there are no short circuits anywhere..
by the way, what do you mean by blinking? you mean a cursor (like this "_" ?)
your reset pin of the micro controller has a pull up? (you never know, maybe the micro is always resarting...)
what kind of power supply you are using? what is the voltage on pin 2 of the LCD? (i know it should be 5V, but again, there may be a wiring error, this happened to me before..)
|
|
|
|
 |
Posted
by:
uttam
on:
10 Jun 2010 |
99 000 RPM Contact-Less Digital Tachometer |
|
 |
Thank you for giving confidence and valuable guidence.. I increased the pulse width of "ena" as you told
like this ena(){ P2_7 = 1; [u][b]delay (50000); // delay (5);-- original P2_7 = 0; } There was significant change in blinking pattern of LCD bot line, (blinking frequency become slow enough) but there was no character or any thing else in LCD two more thing I want to tell you 1) there was voaltage change in pin 39 to 32(7 to 14 of LCD) of micro from 4.99 to 1.96 V(by multimeter)but no reflection in LCD. 2)there is always a 4.9V available in sensor's "ctrl" terminal and it is working without pressing the button connected with pin 21 of micro and ground.
Please tell me what should I do next Regards, Uttam Dutta
|
|
|
|
 |
Posted
by:
ikalogic
on:
10 Jun 2010 |
Re: 99 000 RPM Contact-Less Digital Tachometer |
|
 |
Quoting uttam: This is what I got from LCD provider "Standard 16x2 Character LCD Module with green backlight. These modules are based on standard HD44780 controller. Easy to connect with MCUs. Supports 4 or 8 bit data transfer. Can display 2 lines of 16 characters. " Yes - I am confirming that 1k ohm pull up resitaces are properly connected (only thing I did not use netwaork resitance but separate 10 nos. of 1 k Ohm resitances -one terminal shoted with + ve bar and other connected with Micro pin 39, 38, 37, 36, 35, 34, 33 and 32.
and rest two are connected with pin 27 and 28. I changed the crystal also, no difference, then again I checked the micro pin of different port by LEDBLINK program, they are working What should I do next, Please suggest . Regards, Uttam Dutta |
we're gonna make it work... next think i would suggest one more try on the source code: Can you add delays in the ena() function, to increase the pusle width of the ENABLE input?
|
|
|
|
 |
You have
to be a member to post replies. |
|
|
|