DIY Tachometer for Your Mill or Lathe

Sunday, July 27, 2014

One of the new features in the upcoming version of TouchDRO app is tachometer readout. The beta version of the application had full tachometer support for some time now. Over the last few weeks I added directional tachometer support to all four controllers. In this post I will try to give you some ideas on how to build a tachometer for your mill or lathe using commonly available parts. Your setup will vary, of course, but the main principle will be the same, so you shouldn't have too much trouble to adapt these designs to your particular needs.

The Basics

The working principle of an average tachometer is very simple: it counts the number of revolution per some period of time using some sort of switch that is toggled as the axis rotates. This can be literally a mechanical switch that is actuated by a notched wheel or something similar. More commonly, though, tachometers use an encoder wheel in conjunction with one or two solid state optical or magnetic sensors. In fact a tachometer is nothing more that a coarse incremental rotary encoder that resets the count after a preset time period.

Optical rotary encoder/tachometer example

When a single switch is used the tachometer can only count pulses, but using two sensors a tachometer can sense the direction as well. This is done by placing the second sensor a certain distance away from the first one. As long as that distance is different from the distance between the marks on the encoder disk, as the disk rotates, one of the sensors will always be triggered before the other.

Under the hood TouchDRO works pretty much like any other tachometer. The controller monitors the state of the pin to which the input "A" is connected. As the pin state changes from low to high the microcontroller checks the state of input "B". If the latter is low, the count is incremented; if both pins are high, the count is decremented. Twice per second the controller sends the count to the tablet and starts counting from 0 again. On the tablet the app simply converts the counts per half-second to rotations per minute using basic arithmetics.

Do-It-Yourself Tachometer Implementation

For the purposes of the DRO project there are three viable options:

  • Use HAL effect sensor and a disk with one or more embedded magnets
  • Use an infrared emitter and receiver with a reflective disk or cylinder
  • Use an infrared emitter and received with a perforated/transparent disk

I will leave the first option for some other time; in this post let's concentrate on the remaining two options, since they require almost identical electronics. The circuit is very simple. It uses an infrared LED (transmitter) and a photo transistor (receiver/detector). The current that passes through the latter is proportional to the amount of infrared light that strikes it. In other words, as more light reaches the transistor, the voltage on it's output pin (emitter) increases. With some conditioning these voltage fluctuations are converted to on and off signals for the microcontroller.

The difference between option two and three is in the way the IR emitter/received couple is mounted.

In case with the reflective disk, emitter and receiver are mounted side-by-side and the disk is split into sectors with different reflectively. As it rotates with the axis, the amount of reflected IR light varies, depending on which sector is in front of the IR pair.

The version that uses perforated disk uses an IR pair that is mounted on the opposite sides of the disk. The disk can be either made of solid material with holes or slots cut out around the circumference, or transparent material with opaque sectors. As it spins, the opaque sections block the infrared light, creating the pulses.

It's up to you which design you chose, but I prefer to use a solid disk with slots or holes along the circumference. This design is much more robust than one using a reflective disk. First of all, the delta between high and low outputs will be stronger, so your signal-to-noise ratio will be much better. Second, as the reflective disk gets dirty, the readings will "drift" and the tachometer might get unreliable, whereas it's highly unlikely that a slot can be covered with dirt.

The main benefit of a reflective design is that you might now need to make an encoder disk at all. For example. you can paint matte black stripes on and exposed section of a spindle and use it as the encoder.

Circuit Details

Now that we got the basics covered, let's look at the actual circuit. As I said earlier, it's pretty basic, and requires 10 parts:

  • Two infrared LEDs
  • Two phototransistors
  • Four resistors
  • Two trim potentiometers
  • One comparator
  • One proto board

*If you don't care about the direction of the rotation, you will need only one emitter/receiver set, resistor and trim pot.

Basic tachometer circuit using an IR LED/Receiver couple

The schematic above shows only half of the circuit (for channel A), since channel B is pretty much identical. The circuit works as follows.

On the left you can see the LED with it's current limiting resistor. The resistor is required, since most LEDs can handle only about 20 milliamps, but will try to suck as much current as the power source will provide and will will burn out in seconds. Using a resistor in 150-220 Ohm range will limit the current to a more manageable level.

In the next "column" is the phototransistor (receiver) connected to the Vcc (positive power supply) and the ground via a 10 Kohm resistor R2. As I mentioned earlier, the current at the emitter (where the transistor is connected to the resistor and U1 comparator) will be proportional to the amount of light reaching the receiver. Theoretically, when the path to the LED is restricted, the voltage should be 0V, since R2 pulls it to the group, and when the LED shines right at the transistor, the voltage should be close to Vcc. In practice things are a bit messier, so we will be using a LM339 comparator to "square" the signal. By adding the potentiometer to the positive lead we will be able to set any arbitrary voltage between 0V and Vcc as the reference. This way, as the when the negative input is lower than the reference voltage, comparator output will be low and will go to high when the input is higher than the reference.

The circuit above should work pretty well if the output from the phototransistor is relatively clean, but if there is significant amount of noise, we might run into some problems. As the output approaches the reference voltage, the comparator might start seeing short spikes that are higher than the reference voltage and will start switching the output to high state, thus creating extra (unwanted) pulses, as shown in the graph below.

Depending on the nature for your noise, rise time etc, this might not be an issuse, since the comparator doesn't work instanteniously. In other words, is the noise period is shorted than the comparators response time, it will effectively smooth it out. To be on the safe side, we can add another simple feature to the circuit - hysteresis. This requires two additional resistors as shown below. 1V or hysteresis is a good starting point. It can be achieved by choosing R4 and R5 so their ratio is around 1:5, 10Kohm and 47Kohm.

Tachometer circuit with hysteresis


The purpose of this post was to give you an idea of what's involved in adding a potentiometer to a DIY DRO setup. More details and build instructions will be included in the second part of this post (coming in a few days).


  1. How about using a photointerrupter like this one and run a disk with slots or holes in the gap? Looks easier to mount than two discreet tiny items. Every scrap printer has at leastone or two inside them as well (for reuse in this project)...

  2. Sorry, it didn't like my link....

  3. I just wanted to mention you can buy the tach sensor circuit for a reflective disc setup very cheaply on Amazon. It's already mounted on a small circuit board which makes installation and packaging much easier. It turns out they're frequently used to keep robot cars on a path.

    Here is the single sensor model:

    And the double sensor model:

    1. Well, it appears these modules top out at about 1,000 RPM. Back to the drawing board...

    2. Well, it appears I was wrong. Again.

      The modules will work just fine. It turns out there is some sort of bug in the sketch I used which caused the tach to read 20-40 times too low. After trying a different sketch the tach immediately started working.

      However, I ended up going with a Hall effect sensor instead of an optical sensor simply because it seemed to work more accurately.

  4. Hello,
    I discovered this great DRO project, while browsing through the Android world...
    I'm just about to build a lathe tachometer and revolution/turns counter with an Arduino Nano and an LCD to use my lathe for making coils and transformers.

    I've already installed a perforated disk (20 holes/rev) on my lathe spindle and two IR detectors in a 90° arrangement to have an quadrature output signal...

    But now, with an quadrature input at the TI launch pad and the RPM feature in the Android DRO it would by far easier to have the rev counter as an additional feature in the Android DRO app.

    Is this possible in a future release?

    LG Kassen

  5. I was just wondering if you could incorporate the tachometer from the LMS/Hi-Torque mini mill in your project. There is already a tachometer output on the mill, and information about the output available.

    1. Josh,
      It doesn't look too difficult to add a custom circuit to translate the tachometer. I don't have an SX mill or mini lathe to test this with, but if I find a way to get the controller board somewhere I'll definitely do it.

    2. I was planning on building the basic launchpad controller fairly soon, and I'd be willing to help out as much as I can with my mill. There was some rough code posted on reading the tach here: if that's at all useful.

    3. I just bought a mini lathe and are wondering if there is any updates on this? This would be an awesome feature if it was implemented.


    4. The tachometer port protocol can be read out with a Arduino for display. See here-
      Lots of the small Chinese mills and lathes use the same brushless motor driver electronics.


  6. Hello there,

    first very nice project thanks a lot for this effort,
    however I have a problem with the tachometer application, I have built up an infrared system and I can see on the oscilloscope the correct pulses and with some hand calculation I can see the right RPS´s. The tablet is not show the correct value, it show 19 rpms at 1000 rpms spindle speed. Any idea, can someone help me here?


    1. Peter,
      Make sure to download the latest version of the firmware. That was a bug that I fixed some months ago.
      Thank you

    2. DigitalRead out Universal V0.3 is also updated?
      I have some difficulty with the tachometer in a Mixed Scale Firmware for MSP430 LaunchPad.

      The display for revolcuiones around 600 RPM marks 9

      Thank you very much

  7. Hello Yuriy

    thanks for your response, I am using the MSP430 LaunchPad Quadrature DRO Controller and there is only one release 1.0 form July 13, 2015 which has the problem. I have seen that you did a new release for MSP430 LaunchPad Quadrature DRO Controller which has the fix, can you may do also do MSP430 LaunchPad Quadrature DRO Controller which has the bug fix for the tacho?

    Thanks a lot


  8. Hello Yuriy,

    sorry to bother you again, but now I flashed the Basic DRO Firmware for MSP430 LaunchPad 1.31release on my MSP430 to test the tacho but unfortunately now the display is showing me 21000 rpm by a spindle speed from 620, so I guess there is also a bug.
    Just to let you may pick up system is done with a CNY70 and when I count the pluses and do some math I see that the system is picking up the right speed.

    Is there a way to contact you via email?


  9. Yuriy,

    I tried a hamlin 55110 3 wire hall effect sensor +5v to VCC and 0v to grounded, single wire to Tach A on the TI MSP430. This seem to work for speed control, not sure how accurate it is. I tried it with a magnet on a drill and my range was from 60rpm to 1680rpm, but did notice it read increments of 60. I directly connect the single wire from the hall sensor to the msp430 with a voltage of 3.57v at idle an 3.25 running. on your scales, you advised to keep the voltage about 3v for the z,x,y inputs. is this the case for the tach sensor input.

  10. Hi! Im newbie to this! How to properly connect a hall effect tach sensor to the board? It uses 12v supply.

  11. Yuriy,
    I built two of the controllers for my magnetic scales and all are working okay. Where is Part 2 of the Tachometer Posts and where is a post on the attachment of a probe to the controller hardware.

    many Thanks