Username:    Password: Remember me
Follow us:
IKA-TACH
IKALOGIC's D.I.Y. contactless Tachometer KIT
Last update: 25/4/11
  

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 IKALOGICSTORE! we ship worldwide! and if you are located outside europe, we deduce VAT tax!

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.

Download project folder, containing source code (AVR studio project) and schematic.
This is Creative Commons Attribution-NonCommercial licensed .


I hope this article was useful. Any comments and further questions are welcome in the forum below.

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:
vinuchandran.a.v
on: 06 Jan 2012
IKA-TACH forum
['Quote ]
Can i use atmega16 instead of atmega48
Posted by:
edc
on: 11 Dec 2011
Re: IKA-TACH forum
['Quote ]
hi Ibrahim,
just following up again on the mini board.
thanks.
Edgar


Quoting EDC: Hi Ibrahim,
I've sent you 2 pms without luck.
I need 3 x pcs for the moment.
Shipping and billing address is :

Edgar Dela Cruz
12/10 METHVEN ST.
Mount Druitt, Sydney
NSW Australia 2770

Thanks.



Quoting ikalogic: We don't sell it right now, but sure, we can see you some, how many PCBs would you want?

please send me a PM with the quantity you want, your shipping and billing address, and i will send you the total price with shipping :)

Posted by:
User avatar
ikalogic

on: 11 Nov 2011
Re: IKA-TACH forum
['Quote ]

Quoting p0sseid0n_:

the ADC is only used to control display contrast?


no, also to read the values from the sensor!
Posted by:
p0sseid0n_
on: 17 Sep 2011
IKA-TACH forum
['Quote ]
// ADC
# define ADC_CI ADCSRA | = (1 <<ADIF);
# define ADC_START (channel) ADMUX = channel; ADCSRA = (1 <<ADEN) | (1 <<ADSC) | 2;
# define ADC_STOP ADCSRA = 0;

the ADC is only used to control display contrast? or is used for something else ..

thank you, and excuse my ignorance, I am new to development for microcontrollers.
Posted by:
User avatar
ikalogic

on: 17 Sep 2011
Re: IKA-TACH forum
['Quote ]
seems fine to me :)
Posted by:
p0sseid0n_
on: 16 Sep 2011
IKA-TACH forum
['Quote ]
hi ikalogic, this link is correct? Please take a look! thanks
follow the link below.

http://imageshack.us/photo/my-images/85 ... rcuit.png/

thanks
Posted by:
edc
on: 15 Sep 2011
Re: IKA-TACH forum
['Quote ]
Hi Ibrahim,
I've sent you 2 pms without luck.
I need 3 x pcs for the moment.
Shipping and billing address is :

Edgar Dela Cruz
12/10 METHVEN ST.
Mount Druitt, Sydney
NSW Australia 2770

Thanks.



Quoting ikalogic: We don't sell it right now, but sure, we can see you some, how many PCBs would you want?

please send me a PM with the quantity you want, your shipping and billing address, and i will send you the total price with shipping :)

Posted by:
p0sseid0n_
on: 14 Sep 2011
IKA-TACH forum
['Quote ]
I rode the circuit on a protoboard. using the transistor BC639 to TCND5000 when I press the pushbutton to start reading, it takes about 1 minut to update the display value (RPM: 0.0)
what it takes to appear, is the 0.0 and still not doing a reading or rotation. another detail is that when pushbutton and precione the tension falls because weakens the backligh display.

obs: I use the Atmega168
Posted by:
User avatar
ikalogic

on: 14 Sep 2011
Re: IKA-TACH forum
['Quote ]
what didn't work exactly...? can you explain more please.. :)
Posted by:
p0sseid0n_
on: 14 Sep 2011
IKA-TACH forum
['Quote ]
Thank you.
I was using a BC639 and was not working!
Posted by:
User avatar
ikalogic

on: 14 Sep 2011
Re: IKA-TACH forum
['Quote ]
any general purpose npn will do :)
Posted by:
p0sseid0n_
on: 14 Sep 2011
IKA-TACH forum
['Quote ]
I wonder what other transistor can use in place of BCW66G?

tanks..
Posted by:
User avatar
ikalogic

on: 23 Jun 2011
Re: IKA-TACH forum
['Quote ]
We don't sell it right now, but sure, we can see you some, how many PCBs would you want?

please send me a PM with the quantity you want, your shipping and billing address, and i will send you the total price with shipping :)
Posted by:
edc
on: 20 Jun 2011
Re: IKA-TACH forum
['Quote ]
Do you sell the miniboard Ibrahim? If not, you might consider this an option for us to buy so we don't have to spend time making the miniboard. Thanks.


Quoting ikalogic: Very sorry for my late reply. :(

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....
Not only trailing wires will not do any problem, but the IKA-TACH kit actually comes with a connector at the right side, that directly connects you to the pins related to the IR sensor part. See JP2 in the schematic![quote]
Posted by:
billyp14
on: 20 Feb 2011
Re: IKA-TACH forum
['Quote ]
Ah ok :) Thankyou very much I thought it was avr studio... It is a a quit simple circuit but its very good, im impressed with this project :/ what software would you use to create the PCB, I have circuit wizard but that doesnt have the microcontroller or lcd's etc... would you advise any software in particular to create the pcb?
You have to be a member to post replies.
Username: Remember me
Register now! it only takes an instant.
Forgot your password?
 
Unless mentioned, all content is written and designed by Ibrahim Kamal, copying is prohibited and unethical
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.