I wanted to measure the spindle speed of my milling machine after replacing the motor and installing the PWM variable speed drive.
My first attemptI had built a simple tachometer with an IR reflection sensor. On the table in the laboratory everything worked fine. But after tests on the milling machine the tachometer was showing fluctuating values and incorrect speeds. The cause of this misfunction was a lot of electrical noise in my workshop and strange high frequency stray currents on the ground wire. I identified part of the the source of the glitches as being contactors while switching and low cost Chinese switching power supplies. But some parasites remained unidentified.
I have tried filtering with LC lowpasses to reject high frequency glitches. But only with little success.
How the problem could be solvedThe new tachometer is built with an optoisolation between the light reflection sensor and the arduino. A simple DC/DC converter supplies the current for the sensor and the amplifier stage. The signal is then transmitted to the arduino by an optocoupler.
Between the sensor area and the Arduino area, the parasitic capacitance should be kept as low as possible. So the isolation distance should be as good as possible and tracks proximity shall be avoided.
The tachometer itselfI've used as a sensor a SFH900. But any other reflective optical sensor like the TCRT5000 (not tested yet) can probably do the job. A cable recovered from a PS2 mouse goes from the sensor to the board. The PS2 connector was salvaged from an old Pc's motherboard...
At the request of a friend, I tested a sensor available on adafruit.com: the ITR20001. I also tested the RPR220 and ST188 reflective sensors. All three work well. The distance between the sensor and the reflective mark should be increased (6 to 12 mm depending on the sensor). After fine tuning of RV2, it was possible with all three to measure up to 20,000 rpm with one white mark per revolution on the wheel.
The sensor's LED is powered by R1 from an isolated DC/DC converter. C3 offers a low impedance path to short possible disturbances on the wires. For the sensor's output, low pass filtering is achieved by C4 and R2+RV2 at around 530Hz (RV2 at 0Ω) down to 120Hz (RV2 at 10KΩ). This leaves room to measure at least 7200RPM. The signal is amplified by the PNP transistor Q6. The optocoupler U4 then transfers the signal to the D2 pin (Interrupt input) of the arduino. At the input there, a 530 Hz low-pass RC filter (R12-C13) removes the remaining oscillations. The speed is displayed on a 0.91 inch I2C OLED (128x32 dots).
The isolated DC/DC converterIt is buit around Q4, Q5, C5, C6, C7 and and a home made transformer. They work as a symmetrical oscillator at around 120kHz. The output is rectified with a Schottky diode bridge to lose as little voltage as possible.
If the output voltage is at the given value U3 (TL431) lets the current flow through the LED of the optocoupler (U2). The optocoupler output transistor shorts the Q3 gate to GND which then stops powering the oscillator.
The transformerThe transformer is built around a yellow + red Toroid (13 x 6.6 mm - 7.2 mm hole) recovered from an old PC power supply. The measured AL value is approximately 25-26 nH/N². A 2 mm thick PVC insulation wall is glued with Cyanoacrylate in the toroid core. The primary is wound with 2 wires in hand. The secondary is then wound in the free hole. The most protruding part from the insulation wall is glued on a piece of perfboard and the wires are connected to the pins. A little tape can help hold the wires in place while winding.
After the wires are soldered to the pins in the perf board, fix the copper coils with an insulating varnish (e.g. PLASTIK 70 from Kontakt Chemie).
- Toroid: yellow + red (13 x 6.6 mm - 7.2 mm hole) (maybe an other could do the job but I have not tested)
- Primary: 2 x 24 turns gauge 31 (Ø 0.22mm) ( ≈ 16 µH)
- Secondary: 70 turns gauge 32 (Ø 0.20mm) ( ≈ 138 µH)
- Insulation wall: piece of PVC, 2mm thick
If you want to build it on a perfboard for example, be careful to respect the insulation barrier. For my part, I milled the PCB on a CNC 3018.I attach the files of the PCB at the gerber format and also in.BMP format if you want to reproduce it. There is also excel file for the Bill Of Materials. The MOS, the bipolar transistors and the optocouplers are not critical. You just need to make sure that the package and pinout are identical. Note that resistors and capacitors are almost all in 0805 SMD cases. With the exception of the tantalum capacitors (salvaged from old PC motherboards) and the R1 and C3 in 1206 SMD cases to leave enough room for a track to run underneath. The values of the tantalum capacitors are not critical as long as the case fits on the footprint. But their voltage should be 10V if possible (minimum 6.3V).
The mounting on the milling machineThe final mounting distance between the pulley and the SFH900 sensor should be approximately 2-3mm. That's why I machined a small PVC wedge to be at the right distance.
After cleaning with aceton, the bottom of the spindle pulley is first painted with matte black paint. Take enough time to fully dry this black paint. A stencil is cut from self-adhesive card stock. It is positioned at the best possible centering. The white marks are painted through the stencil.Note that the black part is at least twice the white mark. You have to choose if you need one ore mores reflective strips per revolution. See below the explanation before starting to paint !
The number of reflective marks on the pulley need to be correctly inserted in "Tachymetre.ino" in the line "#define nbrPulsePerTurn"
Because of the "timeOut" of 2s, the number of reflective marks determines the minimum speed that can be displayed e.g.:
- 1 reflective mark — 30 RPM
- 2 reflective marks — 15 RPM
- 4 reflective marks — 8 RPM
- 10 reflective marks — 3 RPM
But the more are marks there, the lower the max speed will be. For example with 1 mark you should be able to go up to 7000 or 8000 RPM with not to precise setting. By using an oscilloscope to display the pulses on arduinos pin 2 and precise triming RV2 I could reach 20, 0000RPM. To go higher, you have several levers. First, use a single mark with the best possible reflection. Mirror grade tape was the best I could test. Second, you can increase the current in the sensor's LED (decrease the value of R1). And third, you can increase the cutoff frequency of the lowpass filtering (decrease the value of C4). Each time, set RV2 to the lowest possible value to have the signal at the D2 input of the arduino.
The setting procedureWith the spindle spinning slowly (100-300 rpm would be fine), adjust the RV2 potentiometer so that the "LED_BUILTIN" on the Arduino turns on or off steadily as a white reflective strip passes over the sensor. Try to find the limit by rotating RV2 clockwise and counterclockwise. If you are out of the limit, the LED flashes like crazy or remains steady on or off. Try to set it near to the center, or maybe a little bit counterclockwise. With this basic setting my tachometer manages to measure speeds more than 10000 rpm for a reflective mark per revolution or more than 2500 rpm with 4 reflective marks per revolution (which is my case)
If you have access to an oscilloscope, show the signal on the arduino pin D2. At faster spindle speeds you can adjust it very precisely to measure as high as possible speeds. You can reach up to 20, 000 - 22, 000 rpm without modification on the low pass RC filters.
If you need to measure higher speeds, you can act on the following points:
- Get a more reflective strip than white paint
- Increase the current in the sensor's LED by lowering R1. Be careful not to exceed the maximum ratings (e.g. for SFH900 the maximum LED current is 50mA. It will be safe to stay below 30-40mA. Recommended working current is usually 20mA for all sensors I've tested until now)
- Raise the cutoff frequency of the RC filters by decreasing the values of C4 and C13.
Comments