IKA-TACH
IKALOGIC's D.I.Y. contactless
Tachometer KIT
Last update:
2/9/10
After our previous
tachometer project, which had - to be honest - a lot of limitations,
we decided to invest some time into this brand new compact
tachometer KIT!
This new contactless tachometer project is based on an ATMEGA48
AVR micro controller, and is able to measure very high RPMs,
as well as very low ones. It is based on an IR (Infra Red)
opto-couple to detect shaft rotation.
As you can see in the short video above, the sensor is located
at the back, next to a red narrow-beam LED that glows to help
you point the invisible IR sensor beam to the target shaft. |
New!
The latest firmware
loaded in IKA-TACH has automatic contrast regulation,
that will adapt the contrast of the LCD display to your
battery level! |
1.
Principle of operation
 |
A
tachometer is a device used to measure the number of revolutions
per minute of a rotating shaft (see wikipedia's definition).
It is mainly used to measure the speed of motors in planes,
cars, motor bikes or even bicycles.
The heart of this tachometer is an IR sensor, also called
opto couple, which is a diode and photo diode in one package.
This opto-couple will send IR beam on the shaft to detect
it's rotation. For that purpose, a small reflective sticker
is added on the shaft, so that each rotation of the shaft
will cause a "pulse" of IR light to be reflected.
Figure 1.a shows a beam or IR light being sent to a rotating
shaft having a reflective sticker on it.
The sensor that was used is the TCND-5000 from VISHAY
SEMICONDUCTOR. after testing various equivalent products,
we decided to you this one for some factors, the most
relevant being :
- The packaging takes care of the optical isolation between
the sender and the receiver.
- The Emitter LED can sustain relatively high currents,
and thus, can allow detection of rotating shafts ant bigger
ranges.
So, to recap, using that opto couple we can count the
time taken by the shaft to execute a complete revolution.
Then, when you have that time information (let's call
it T and let's assume T's using is seconds), the RPM is
simply calculated as [60/T]. |
Figure 1.a

Figure 1 .b (source Farnell.com) |
2.
Getting
useful data from the IR Opto-couple
 |
To reduce cost and hardware complexity, and to
increase system flexibility, we decided to connect the IR sensor
directly to the ATMEGA micro controller, and let it do all the
signal processing. This was difficult because the signals coming
from the photo-diode are very noisy, and are constantly biased
by the ambient light. So the challenge was to build a system that
would automatically adapt to ambient light and also adapt to the
distance from the shaft being measured.
Figure 2.a shows an example of the analog signals we could read
from the senor. All the noise around each high/low transition
is
Figure 2.a
|
Beside the fact that the signal is noisy, at each
transition between ON and OFF (ON being when the shaft rotates
and the sensor "sees" the reflective sticker), a huge
amount of oscillation occur causing the controller to be totally
confused!
We wanted to use the comparator that is integrated in the ATMEGA48,
but due to all those factors, it was not possible, we needed to
process the analog signals before even trying to count the cycles.
The solution we found was to constantly estimate the average intensity,
based on the MAX and MIN intensities retrieved from the sensor,
then "create" a hysteresis around that average intensity.
This hysteresis will be used to prevent multiple cycles counts
during noisy High/Low transitions.
Figure 2.a |
Here is how it works in more details: when the
noisy signal is raising from a low state (no IR reflection) to
a high state (IR re flexion), the algorithm will only consider
the signal to be high if it crosses the "rising hysteresis"
level shown on the graph, and will only consider the signal to
be low if crosses the "falling hysteresis" level. This
will prevent most possibilities of having errors caused by the
noisy signal.
3.
Measurement algorithm.
 |
The whole is done with that simple algorithm,
which is executed on each new ADC (Analog to Digital Converter)
end of conversion:
ISR(ADC_vect)
{
//Global variables used :
// ir_value : contains the value of the intensity of IR
reflection
// ain_th_high : High threshold (rising hysteresis)
// ain_th_low : Low threshold (falling hysteresis)
// t_capture & t_postscale : reading of the time elapsed
since last detected cycle
// ir_history_b and ir_history_a: hold the last two values
of ir_value
// last_state : used to remember which hysteresis level
to use
ir_value = ADC>>2;
if ((ir_value > ain_th_high) && (last_state==0))
//a cycle is detected
{
last_state = 1; //for
next edge detection, use the falling hysteresis //
for next detection
t_capture=TCNT1;TCNT1 = 0;
t_postscale=post_scaller; post_scaller=0;
}
if
((ir_value < ain_th_low) && (last_state==1))
//a low level is detected
{
last_state = 0; //for
next edge detection, use the rising hysteresis for
//next detection
}
if
(delta(ir_history_a,ir_value) > 10)
{ //the
values having more than 10 adc //quantums
will be used to determine
ir_history_b = ir_history_a;
//average and hysteresis levels
ir_history_a = ir_value;
ir_avg = (ir_history_a+ir_history_b)/2;
ain_th_high = ir_avg + 5;
ain_th_low = ir_avg - 5;
}
}
|
4.
The
hardware
 |
The hardware is fairly simple and compact, thanks
to the small IR sensor and the battery pack at the back.
The schematic below how simple it is. Notice that there is no
potentiometer for the contrast adjustment. this would take too
much place and it is not reliable to always have to adjust it,
so instead we designed our own contrast regulation system based
on a PWM generator and a low pass filter (R3, R4 and C2). Check
the source code for me details on this part.
Also notice that there is an additional interface
(JP2) to allow the user to hook any additional sensor. JP1 is
used for ISP programming of the micro controller. JP1 can also
be used to transfer RPM data out of the device.
The main PCB is almost the same size of the LCD panel.
A button at the top right corner allow you to activate the IR
LED and start measuring RPM data. Once released, the last data
is held on screen.
5.
Some tips and tricks for the road
 |
Besides from showing you how to measure RPM of
a shaft with IR LED, this project also show you how to do many
other cool things like:
- Using an alpha numeric LCD without the need of a potentiometer
for the contrast. A simply algorithm that you can find in the
source code will adapt the contrast of the LCD according to the
batter level, to make sure you alwyas have the brightest possible
display.
- Using LCD is 4 bit mode to save some wires
- Implementing a hysteresis to enhance noise immunity of the system
6.
Get your DIY kit now!
 |
If you want to build your own Contact less tachometer,
you can
get all the components at one place! We provide the PCB with
the ATMEGA48 processor pre-soldered and pre-programmed in case
you don't have a serial programmer. There is few resistors and
connectors left to solder then you're ready to measure RPMs!
You can
buy your own kit for 35 Euros in our online store IKAMARKET!
we ship worldwide! and if you are located outside europe, we deduce
VAT!
7.
Visitors contributions
 |
This project is Open Source! (under
Creative Commons Attribution-NonCommercial
license) So i am eagerly hoping for some visitors contributions.
Just post your ideas and modifications in the forum below. It
can be just enhancing the text on the LCD, adding animations,
Backlight fade-in fade- outs, or enhancing the precision of the
measurement algorithm.
I hope this article was useful. Any comments and further questions
are welcome in the forum below.
Preview of the last 15
messages discussing this page. Messages are sorted from the newest to
the oldest. |
Posted
by:
ross_valusoft
on:
29 Jul 2010 |
Re: IKA-TACH forum |
|
 |
If there is no possibility for the pulsing light to be detected on the other side ... yes it should work.
The rest I leave to Ibrahim.
Cheers,
Ross
|
|
|
|
Posted
by:
zipdogso
on:
29 Jul 2010 |
Re: IKA-TACH forum |
|
 |
well it might work.... the fans are either side of a partition. the air flow is "pushed" through with one fan then through a number of radiators then "pulled" by the other. To ensure air only goes through the fans there is a partition around the central radiator section. it can be arranged so the sensors cannot see each directly. Would it not work like that ?
|
|
|
|
 |
Posted
by:
ross_valusoft
on:
28 Jul 2010 |
Re: IKA-TACH forum |
|
 |
Hello,
I am sure that Ibrahim will answer your specific questions ... I just wanted to warn you that this will probably not work as you wish.
The tachometer works by shining a pulsing beam of infrared light at the spinning object. It measures the received light during the pulse and when the pulse is missing. Both of these measurements must be "correct".
If you put two pulsing light sources inside a 1 metre box, each will also "see' the pulsing from the other's light beam. It is like the wife and the husband each pressing their own television remote control. Chaos and divorce are sure to follow very soon.
A solution could be to switch one tachometer on for its measurement, store and display the reading, then repeat for the other unit ... "repeat and rinse" as they say. Attempting to run both at the same time will end in tears.
Cheers,
Ross
|
|
|
|
 |
Posted
by:
zipdogso
on:
28 Jul 2010 |
Re: IKA-TACH forum |
|
 |
I only know basic electronics and know nothing about programmable chips.
I am doing a PC/TEC related project which I will put on a computer forum later this year (If I can finally build it !) and have a requirement to check the working of 2 circlation fans in a sealed case...it is not possible to observe them from outside.
I have puzzled how to do this, within my capabilites, for over a year...then I spotted the IKA-TACH.
I would be happy at assembling two of the "DIY" kits with the pre-programmed atmels but it would appear things need altering slightly.
1.) It would be powered by small PSU instead of batteries with the power turned on/off by relay controlled by a main power switch. I would leave the IKA-TECH power switch in the on position. - Easy, I can do that....
2.)There would be no need for the "display" button....would it possible to just bridge this ? The display would then just constantly update whilst powered ? Yes ? If you agree it will work then Easy i can do that.....
3.) I plan to mount the 2 displays directly one above the other at the front of the unit meaning 1 fan would be about 350mm - 400mm from the display the other fan would be further back about 750mm from the display. Is it possible to mount the sensor on a seperate miniboard appropriately fixed to read the fan, with trailing wires to the correct connections on the main board ? bearing in mind the lengths I have stated. I don't really want to use a diferent sensor and have to reprog the atmel, or will the resistance of the trailing wires screw it anyway ? If I can fit trailing wires then I can do that....
If it would work OK with these adjustments then I will be very happy indeed.
My final problem I dont see solving......but it is only cosmetic...
the 2 displays are mounted 1 above the other. I am very happy to display IKA-TACH at the top of the top display but would prefer it not to appear on the lower one. I trust this is an atmel programming job
|
|
|
|
 |
Posted
by:
ikalogic
on:
22 Jul 2010 |
Re: IKA-TACH forum |
|
 |
Impressive reverse engineering!
Yes, R5 is quite high, 1MOhm actually.
Again, i am impressed 
Quoting ross_valusoft: Hello Ibrahim.
I have just noticed on the data sheet that the detector only produces 110 nanoamps current. This would mean that your R5 must be very large in value ... maybe 10 megohms to get enough voltage to be measured by the AVR's ADC. Then the ADC input impedance would load the signal. Did you find this? What value did you use for R5?
Thanks,
Ross |
|
|
|
|
Posted
by:
ross_valusoft
on:
22 Jul 2010 |
Re: IKA-TACH forum |
|
 |
Hello Ibrahim.
I have just noticed on the data sheet that the detector only produces 110 nanoamps current. This would mean that your R5 must be very large in value ... maybe 10 megohms to get enough voltage to be measured by the AVR's ADC. Then the ADC input impedance would load the signal. Did you find this? What value did you use for R5?
Thanks,
Ross
|
|
|
|
Posted
by:
ikalogic
on:
21 Jul 2010 |
Re: IKA-TACH forum |
|
 |
Quoting ross_valusoft: Hello Ibrahim,
Interesting idea. How much current are you pushing through the emitter side of the sensor? Or another way ... what is the value of R8 in your circuit? I see that the performance in the Vishay datahseet talks of 50 milliamps. Is this what you are using also?
Best wishes,
Ross |
Yup, i'm injecting 45mA via a 100 Ohm resistor but have been working with 60 ohm resistors as well without any issues (although it's not in the specs....)
|
|
|
|
Posted
by:
ross_valusoft
on:
21 Jul 2010 |
Re: IKA-TACH forum |
|
 |
Hello Ibrahim,
Interesting idea. How much current are you pushing through the emitter side of the sensor? Or another way ... what is the value of R8 in your circuit? I see that the performance in the Vishay datahseet talks of 50 milliamps. Is this what you are using also?
Best wishes,
Ross
|
|
|
|
Posted
by:
ikalogic
on:
21 Jul 2010 |
Re: IKA-TACH forum |
|
 |
| Quoting vudiepdh1: Hi ika ! Have you ever test it with high or low speed ? Max speed did this tacho measured = ? |
Hello!
Well, the slowest spinning shaft i have is about 2 rpm, but there is no reason it wouldn't go below 1 rpm!
As for the high limit, i've tested at 15 000 rpm maximum, but in my calculations, the maximum is about 35000 rpm (this is mainly limited by the speed of the ADC) !
Thanks!
|
|
|
|
Posted
by:
vudiepdh1
on:
21 Jul 2010 |
IKA-TACH forum |
|
 |
Hi ika ! Have you ever test it with high or low speed ? Max speed did this tacho measured = ?
|
|
|
|
Posted
by:
rohan
on:
17 Jul 2010 |
IKA-TACH forum |
|
 |
Mr.Ika,
Can this tachometer be done using a 89C51 microcontroller?
|
|
|
|
Posted
by:
ikalogic
on:
16 Jul 2010 |
Re: IKA-TACH forum |
|
 |
Quoting uttam: Mr. Ika,
Thank you for reply, You have used 32 pin atmega48 TQFP vesion, whereas 32 pin PDIP vesion for Atmega48-- I am not getting at least in datasheet. I am not enough confident to change the code suitably in atmega32, and also hardware I need to try and also dont' know will able to finally make it or not. Thanks and regards
Uttam Dutta |
Uttam,
the difference in pins between the TQFP and PDIP packages of the M48 wont cause any troubles. The TQFP has more pins for ADC inputs and VCC and AGND connection, they are simply not used in the PDIP package, so just ignore them!
|
|
|
|
You have
to be a member to post replies. |
|
|
|