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