2. Infrared Optical Reflective Pair Sensors on a Non-Contact Tachometer

(article continued from previous page)

The tachometer replaces the spindle cap and snaps onto the milling machine.

The tachometer replaces the spindle cap and snaps onto the milling machine.

Because the tachometer replaces the spindle cap, no alterations are necessary to attach the tach to the mill. The tachometer simply snaps in place (press fit). If necessary, the tachometer can be removed completely and the old spindle cover restored.

In this position, the tachometer circuit has an overhead view of the top of the mill’s spindle. The spindle matches the rotational speed of the cutting tool, regardless of gearing or belts. 

A white paint pen marks a portion of the black spindle top so that rotations can be measured optically.

A white paint pen marks a portion of the black spindle top so that rotations can be measured optically.

A white paint marker (available at McMaster-Carr) highlights a section of the black top of the spindle. This provides reflective contrast for the optical sensors. (Note: Because the tachometer sees the rotations without physical contact with the part, it is termed a “non-contact” tachometer.)

The circuit will see one white pulse (followed by black) for each rotation of the spindle. By counting the number of white pulses (and/or the time between pulses), the circuit can determine the speed of the spindle.

Usually, I’d make half of the optical target white and half black. However, there are notches every quarter, and I was concerned that these might appear as a black gap to the sensors. Then the tachometer might see “white, short black, white, long black” with each rotation.

But I want just one pulse per rotation. So, I painted only 1/4 of the top of the spindle white. As long as there is a reasonably long white mark, it doesn’t matter to the digital tachometer if the white and black areas are the same size.

Inside the spindle cap, an infrared LED (looks purple in this photo) reflects light off the spindle and into the phototransistor.

Inside the spindle cap, an infrared LED (looks purple in this photo) reflects light off the spindle and into the phototransistor.

Inside the tachometer spindle cap, the circuit has an infrared emitter (IR LED) and phototransistor (an amplified photodiode or photosensor) aimed down at the spindle. Light from the infrared LED reflects off the spindle surface and bounces back into the phototransistor which measures the brightness.

It is critical that an opaque cap covers the optical sensors, otherwise outside lighting and shadows would interfere with detection.

Hybrid Tachometer Algorithm

When the white-painted portion of the spindle rotates underneath the phototransistor sensor, more infrared light is reflected. The microcontroller detects this as an increase in voltage and starts a timer.

When the black portion of the spindle rotates underneath the phototransistor sensor, less infrared light is reflected. The microcontroller detects this as a decrease in voltage and notes that the first white section must have rotated away.

When the white-painted portion of the spindle rotates underneath the phototransistor sensor again, more infrared light is reflected. The microcontroller detects this as an increase in voltage and stops the timer.

Knowing the amount of time it took to complete a rotation from the start of a white area to the start of the white area again, the microcontroller can calculate how many rotations could occur in a minute (RPM). It updates the display with this value. This simple algorithm works well for slow rotations, such as under 200 RPM.

In order to display all values during faster rotations (up to 9999 RPM in this case) the microcontroller times and counts the number of rotations for up to 1/3 of a second. Then it performs the calculation and updates the display. This technique allows the tiny time-period differences in very fast rotations to accumulate. It also allows variances in the microcontroller’s workload and built-in clock to average out.

Put another way, faster RPMs are based on multiple samples, not just one.

This hybrid slow/fast RPM calculation algorithm is superior to any electronic tachometer I’ve built before. My thanks to Sarun Rattananan who pointed out the resolution flaw in my previous algorithms.

I verified the expected accuracy of my latest tachometer by comparing it to oscilloscope traces at maximum RPMs. I verified the expected precision by repeating the oscilloscope tests multiple times over the last year. I verified that the integer resolution set is complete using mathematics and experimentally by slowing increasing the RPMs on the mini-mill and looking for skipped numbers.

Now let’s take a look at the circuit board...