The application of optical sensor and magnetic sensor is analyzed
Leave a message
The sensor provides a window for the microprocessing system to detect the surrounding environmental conditions. The light sensor and the magnetic sensor are widely used in the field of measuring the appearance, departure and movement of objects. This paper introduces the basic types, applications and interfaces of optical sensor and magnetic sensor with microprocessor.
Slot light sensor switch, a light emitting diode (LED) is placed in the plastic seat facing the phototransistor, there is a gap between the light emitting diode and the phototransistor. If the object passes through this gap, it will block the light path between the LED and the phototransistor. Slot switches detect engine speed by placing a slotted wheel on the engine shaft. As the axis rotates, it alternately blocks the light path. Slot switches are also used to indicate the opening or closing of a door or cover. When the door is closed, the sign on the door will fall into the slot and block the light path.
The working principle of the reflection sensor is similar. The phototransistor on the reflection sensor intercepts the light reflected anywhere in the front of the switch. Most reflection sensors have a focal length, which is the best distance to detect the object being placed, usually between 0.1 and 0.5 inches. Reflection sensors typically detect engine movement by tinting or anodizing the engine shaft to blackening it, and then placing a ribbon made of reflective material on the shaft. Because the axis is rotating, the sensor does not receive a reflection from the black part of the axis, but receives a strong reflection from the reflective band. Slot or reflected light sensors have the same circuit character. In system design, we should pay attention to the common characteristics of the two types of sensors.
Current transfer rate (CTR)
The gain of LED and phototransistor pairs is usually less than 1. For a given LED current, the current generated by the phototransistor collector is called the current transfer rate (CTR). Usually the CTR of the trough switch is 0.1, so a current of 10mA in the LED will generate a current of 1mA in the collector. Sometimes the CTR describes the relationship between the collector current and the LED current in the form of a ratio or grid. CTR depends on the characteristics of leds and phototransistors, and varies greatly from light sensor to light sensor.
When it comes to interfacing an optical sensor with a processor, the current transfer rate has several implications. First, as shown in Figure 2, if the switch is connected directly to the digital input, the transistor output value will oscillate between the effective logic levels. To ensure saturation of the phototransistor, it is necessary to limit the value of the pull-up resistance. For example, if the LED is driven with 10mA and the CTR has a minimum value of 0.1, the pull-up resistance has a value of about 5kΩ.
The lower the resistance value, the better the immunity and the faster the operation speed, but it is not suitable for all light sensors. The transistor must absorb enough current to ensure an effective logic low level. If you want to use a smaller pull-up resistance, you can use a light sensor switch with a higher CTR or an LED with a larger drive current. Light sensor switches have a Darlington crystal switch output form, which typically have a higher CTR than Figure 1, but typically they also have only 20% of the output speed of a single transistor and a higher saturation voltage.
Reflection sensors can also be evaluated using CTR. Since the sensor depends on the reflected light, the CTR depends on the surface type and the distance between the reflecting surface and the sensor. The CTR of a reflection sensor depends on a standard reflective surface that is placed in focus at a specific distance from the sensor.
The CTR of a reflection sensor varies by device and application. If the sensor is facing a surface that switches between gray and black, the CTR will not be the same as the CTR measured on the white reference surface used by the manufacturer. The design must be adapted to the actual CTR resulting from the sensor application. One way to determine the CTR range is to measure the CTR for the specific application and then compare the same sensor with the CTR measured by the sensor manufacturer with a white reference surface, which will give the desired CTR reference range.
Due to the large CTR range of the optical sensor, it may be necessary to interface the output of the sensor to an analog-to-digital converter (ADC), so that software can be used to find changes in the output level, rather than depending on the ability of the component generating the digital logic level. Of course, this comes at the cost of adding an ADC and requiring more time for ADC sampling.
Detection speed
The speed of the phototransistor in any light sensor is quite slow, which limits the maximum speed of detection. Typical values for switching times are 8 ms and 50ms. If the driver LED in the sensor is controlled by software, this software must take into account the on and off delay when reading the sensor output.
Mechanical instability
Mechanical jitter causes the reflection sensor to be abnormal. For example, a reflection sensor can measure the number of rotations by looking at a glowing band on a flat black engine shaft, and the output of this sensor current produces an interrupt signal. Sometimes the engine stops when the light band is in the sensor's detection area. Machine vibration causes the processor to generate a large number of interrupt signals, effectively shutting down the engine.
One can imagine a situation similar to that of a trough sensor, if the marker blocking the light path only makes the phototransistor partially obscure, thus making the phototransistor perform poorly, resulting in an uncertain output. Therefore, the delay principle of comparator circuit can be applied in hardware design to solve this problem.
Reflection sensors have some additional considerations. Reflection sensors are often used to sense different types of surfaces. A typical example is the sorting of paper by high-speed sorters. Paper quality, color and reflection characteristics are different. Sensing systems must be designed to handle a variety of materials. What happens when an oil film covers the flat black element of the shaft in an engine speed measurement application? What is the effect on the efficiency of sensors that detect rotation?
In some cases, hardware or software (or both) may be added to detect anomalies. In this example, when the reflection sensor generates too many interrupt signals, the software has a timer that records the interrupt time. If the sensor interrupt service program is exited and re-entered immediately, the interrupt service program may disable the interrupt and set a flag to inform the rest of the system that there is now a fault.






