Home > Control Circuits >Other Control Circuitss > How to build a simple tachometer using an infrared reflectance sensor

How to build a simple tachometer using an infrared reflectance sensor

Source: InternetPublisher:国民男神经 Keywords: DC/DC converter reflective sensor tachometer Updated: 2024/12/24

This article will describe how to use an optical reflective sensor to measure spindle speed contactlessly.

Purpose

I want to measure the spindle speed of my milling machine after replacing the motor and installing a PWM variable speed drive.

First attempt

I built a simple tachometer using an infrared reflectance sensor. Everything worked fine on a lab table. But after testing it on a milling machine, the tachometer showed fluctuating values ​​and incorrect speeds. The cause of this malfunction was a lot of electrical noise in my workshop and strange high-frequency stray currents in the ground wire. I identified part of the cause of the burr as the contactor when switching and the low-cost switching power supply. But some other aspects of the problem remained unidentified.

I tried using an LC low pass filter to suppress the high frequency glitches, but with little success.

How to solve it

I used a new tachometer to create optical isolation between the light reflectance sensor and the arduino. A DC/DC converter provides current to the sensor and amplifier stage. The signal is then transmitted to the arduino via an optocoupler.

The capacitance should be kept as low as possible between the sensor area and the Arduino area. Therefore the isolation distance should be as good as possible to avoid running the traces too close.

Tachometer

I used SFH900 as sensor. But any other reflective optical sensor like TCRT5000 (not tested yet) can also do the job. A cable salvaged from a PS2 mouse connects from the sensor to the circuit board.

I also tested the sensor ITR20001, as well as the RPR220 and ST188. All three worked well. The distance between the sensor and the reflective mark should be increased (6 to 12 mm, depending on the sensor). After fine-tuning the RV2, all three could measure speeds up to 20,000 rpm, with one white mark per revolution on the wheel.

The sensor's LED is powered by R1 of the isolated DC/DC converter. C3 provides a low impedance path to shorten possible interference on the wires. For the sensor's output, C4 and R2+RV2 implement low pass filtering from about 530Hz (RV2 is 0Ω) to 120Hz (RV2 is 10KΩ). This leaves room for measuring at least 7200RPM. The signal is amplified by PNP transistor Q6. Optocoupler U4 then transmits the signal to the D2 pin (interrupt input) of the arduino. At the input there, a 530 Hz low pass RC filter (R12-C13) eliminates the remaining oscillations. The speed is displayed on a 0.91" I2C OLED (128x32 dots).

Isolated DC/DC Converters

It revolves around Q4, Q5, C5, C6, C7 and a homemade transformer. They operate as a symmetrical oscillator at around 120kHz. The output is rectified through a Schottky diode bridge to lose as little voltage as possible.

If the output voltage is at a given value, U3 (TL431) allows current to flow through the LED of the optocoupler (U2). The optocoupler output transistor shorts the gate of Q3 to GND, which then stops powering the oscillator.

transformer

The transformer is built around a yellow + red toroid (13 x 6.6 mm - 7.2 mm hole) salvaged from an old PC power supply. The measured AL value is about 25-26 nH/N². A 2 mm thick PVC insulating wall is glued in the toroidal core with cyanoacrylate. The primary winding is wound with 2 wires. The secondary winding is then wound in the free holes. The most protruding part of the insulating wall is glued to a piece of perfboard and the wires are connected to the pins. A bit of tape can help to hold the wires in place while winding.

After soldering the wires to the pins on the perfboard, secure the copper coils with insulating varnish.

poYBAGMBlgKAdWJWAAKGBt-vsQ0110.png

Ring: Yellow + Red (13 x 6.6mm - 7.2mm hole)

Primary: 2 x 24 turns Gauge 31 (Ø 0.22mm) (≈ 16 µH)

Secondary: 70 turns size 32 (Ø 0.20mm) (≈ 138 µH)

Insulation wall: PVC sheet, 2mm thick

poYBAGMBlf2AYuB1AANgIWkUHSw026.png

poYBAGMBlfmAAl3MAAF0jGLhYVI483.png

pYYBAGMBlfWAAsRwAAMyVsWsrPQ810.png

Note that if you want to build it on perfboard, be careful to respect the insulation barrier. In my case, I milled the PCB on a CNC 3018. The MOS, bipolar transistors and optocouplers are not critical. You just need to make sure the package and pinout are the same. Note that the resistors and capacitors are almost all in 0805 SMD cases. With the exception of the tantalum capacitors, R1 and C3 are in 1206 SMD cases, leaving enough space for the tracks to run underneath. The value of the tantalum capacitors is not critical as long as the case fits the footprint. But they should be 10V if possible (6.3V minimum).

Installation on milling machine

The final mounting distance between the pulley and the SFH900 sensor should be about 2-3mm. That's why I machined a small PVC wedge to the right distance.

pYYBAGMBlfGAFHX-AAee_zf5Xhw229.png

After cleaning with acetone, the bottom of the spindle pulley is first painted with matte black paint. Give enough time to completely dry this black paint. The template is cut from self-adhesive card stock. It is positioned in the best center. The white markings are drawn through the template. Note that the black part is at least twice as long as the white markings. You have to choose whether you want one or more reflective strips per revolution.

pYYBAGMBle2APOxWAAJFJCYxV_A413.png

The correct number of reflective markers on the pulley needs to be inserted in "Tachymetre.ino" on the line "#define nbrPulsePerTurn"

Since "timeOut" is 2s, the number of reflection marks determines the minimum speed that can be displayed, for example:

1 reflective marker - 30 RPM

2 reflective markers - 15 RPM

4 reflective markers - 8 RPM

10 reflective markers — 3 RPM

But the more markers there are, the lower the maximum speed will be. For example, with 1 marker, you should be able to reach 7000 or 8000 RPM without precise settings. By using an oscilloscope to display the pulses on the arduinos pin 2 and precisely fine-tuning RV2, I was able to reach 20,0000RPM. To go higher, you have a few levers. First, use a single marker with the best reflection. Mirror-grade tape was the best I could test. Second, you can increase the current in the sensor LED (decrease the value of R1). Third, you can increase the cutoff frequency of the low-pass filtering (decrease the value of C4). Each time, set RV2 to the lowest value possible so that you get a signal at the D2 input of the arduino.

Setting up the program

With the spindle spinning slowly (100-300 rpm is good), adjust the RV2 potentiometer so that the "LED_BUILTIN" on the Arduino turns steadily on or off as the white reflective strip passes the sensor. Try turning RV2 clockwise and counterclockwise to find the limits. If you exceed the limits, the LED will flash wildly or stay on or off. Try setting it closer to the center, or counterclockwise. With this basic setup, my tachometer can measure speeds over 10,000 rpm with one reflective marker per revolution or over 2,500 rpm with 4 reflective markers per revolution.

If you have access to an oscilloscope, display the signal on arduino pin D2. At faster spindle speeds you can adjust it very precisely to measure the highest possible speeds. 20,000 - 22,000 rpm should be possible without modifying the low pass RC filter.

Possible extensions

If you need to measure higher speeds, here are some tips:

Get a more reflective strip than with white paint

Increase the current in the sensor LED by lowering R1. Be careful not to exceed the maximum rating (e.g. for the SFH900 the maximum LED current is 50mA. Keeping it below 30-40mA is safe. The recommended operating current for all sensors I have tested so far is usually 20mA)

The cutoff frequency of the RC filter can be increased by reducing the values ​​of C4 and C13.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号