Our Logic Analyzers allow faster debugging for electronics professionals & serious hobbyists!


This new contact less 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. It is designed to allow many modifications to me made buy the users like adding additional sensors.

[youtube R1qmK6vhzPg nolink]

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.

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.

figure 1.A

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.B

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

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 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.

Measurement algorithm

The whole is done with that simple algorithm, which is executed on each new ADC (Analog to Digital Converter) end of conversion:

//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;

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.

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 always have the brightest possible display.
  • Using LCD is four bit mode to save some wires.
  • Implementing a hysteresis to enhance noise immunity of the system.

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!

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 form below.


Comments ( 6 )

  • Roger Angell says:

    Questions about the IKA-Tach kit:
    1) You state that the maximum RPM is 120,000. What is the minimum RPM? In my application it can of course be zero, for stopped, but may also be as low as 1 pulse per minute (or less, but less than one can be considered zero). As shown in one of your photos, I would also want a fractional speed to display, such as 2.5, but what determines the number of decimal digits?
    2) Assuming the above is possible, can I request (for an additional fee) that you make some minor changes to the text on the display, and have you burn that into the chip for me?

    • Ibrahim KAMAL says:

      Hi, thank you for your interest.

      1) There is no minimum RPM, the only thing you have to keep in mind is that the value will be updated only when a pulse is received. The fractional value come from the fact that the device does not wait for 1 minute to display an RPM. It measures the time between two pulses and then do the math. (Of course the full algorithm does some filtering and averaging to have a stable, readable value).

      2) no additional fees, just let us know when you order that you want another text :)

    • Richard Bauman says:

      I would like three modifications:
      1) I would like the momentary button replaced with an On/Off toggle switch
      2) The batteries will drain, so I want PC power plug (with accompanying male) installed next to the batteries so when I plug the male whic I will put on a US AC to DC 5v source the batteries are disconnected.
      3) I need the IR module removed from the circuit board and placed on a small board with a wire bundle from it to a connecter for the JP2 plug.
      The spot where I need to put Opti sensor will not let me see the display. This way I can build a little stand for the sensor and put an opaque tube around the sensor to cut down on stray light/heat. The display can be mounted in a place where it can be easily viewed. I will probably get two project boxes I am going to order two kits, One unmodified standard kit and hopefully a modified kit so I do not lose any fingers.
      How are with fiber optic circuits? I have a simple circuit I need that I think may have broad appeal.

  • Pranay says:

    Or,,,, AT mega 8535 ,

  • Pranay says:

    is it possible to convert this circuit and code for AVR AT Tiny 2313 ,, if possible pls help me

  • Ibrahim KAMAL says:

    It is possible, via a connector on the board, to connect another “deported” sensor. OF course, the intial sensor have to be removed for that trick to work.

Leave A Comment

Your email address will not be published. Required fields are marked *