Photoelectric encoder principle and application circuit
1. Principle of photoelectric encoder
Based on their detection principles, encoders can be classified into optical, magnetic, inductive, and capacitive types. Based on their calibration methods and signal output formats, they can be classified into incremental, absolute, and hybrid types.
1.1 Incremental Encoder
Incremental encoders directly utilize the photoelectric conversion principle to output three sets of square wave pulses, A, B, and Z phases. The A and B pulses have a 90° phase difference, and each phase outputs one pulse per revolution, used for reference point positioning. Its advantages include simple principle and construction, an average mechanical lifespan exceeding tens of thousands of hours, strong anti-interference capability, high reliability, and suitability for long-distance transmission. Its disadvantage is that it cannot output the absolute position information of the shaft rotation.
1.2 Absolute Encoder
An absolute encoder is a sensor that directly outputs digital values. Its circular code disk has several concentric tracks radially, each track consisting of alternating transparent and opaque sectors. The number of sectors in adjacent tracks is double the number of bits in its binary code. A light source is located on one side of the code disk, and a photosensitive element corresponds to each track on the other side. When the code disk is in different positions, each photosensitive element converts the light source into a corresponding voltage level signal, forming a binary number. The key feature of this type of encoder is that it does not require a counter; a fixed digital code corresponding to the position can be read from any position of the shaft. Obviously, the more tracks, the higher the resolution. For an encoder with N-bit binary resolution, its code disk must have N tracks. Currently, 16-bit absolute encoders are available in China.
Absolute encoders utilize natural binary or cyclic binary (Gray code) methods for photoelectric conversion. The difference between absolute and incremental encoders lies in the translucent and opaque lines on the code disk. Absolute encoders can have multiple codes, and the absolute position is detected by reading the codes on the code disk. The code design can employ binary code, cyclic code, binary complement code, etc. Its characteristics are:
1.2.1 The absolute value of the angular coordinates can be read directly;
1.2.2 No cumulative error;
1.2.3 Position information is not lost after power is cut off. However, the resolution is determined by the number of bits in the binary representation, meaning the precision depends on the number of bits, currently including 10-bit, 14-bit, and other types.
1.3 Hybrid Absolute Encoder
The hybrid absolute encoder outputs two sets of information: one set is used to detect the magnetic pole position and has absolute information function; the other set is exactly the same as the output information of the incremental encoder.
An optical encoder is an angle (angular velocity) detection device that converts the angle input to a shaft into corresponding electrical pulses or digital signals using the photoelectric conversion principle. It features small size, high precision, reliable operation, and a digital interface. It is widely used in CNC machine tools, rotary tables, servo drives, robots, radar, military target measurement, and other devices and equipment requiring angle detection.
2. Application circuit of photoelectric encoder
2.1 Application of EPC-755A photoelectric encoder
The EPC-755A photoelectric encoder boasts excellent performance, exhibiting strong anti-interference capabilities in angle and displacement measurements, and providing a stable and reliable output pulse signal. This pulse signal, after counting, yields the measured digital signal. Therefore, in developing a car driving simulator, we selected the EPC-755A photoelectric encoder as the sensor for measuring the steering wheel rotation angle. Its output circuit is an open-collector type, with an output resolution of 360 pulses/revolution. Considering that the car steering wheel rotates bidirectionally (clockwise and counterclockwise), phase detection of the encoder's output signal is necessary for counting. Figure 2 shows the phase detection and bidirectional counting circuit actually used in the photoelectric encoder. The phase detection circuit consists of one D flip-flop and two NAND gates, while the counting circuit uses three 74LS193 chips.
When the photoelectric encoder rotates clockwise, the output waveform of channel A leads the output waveform of channel B by 90°. The D flip-flop outputs Q (waveform W1) are high and Q (waveform W2) are low. The upper NAND gate is open, and the counting pulse passes through (waveform W3) and is sent to the add pulse input terminal CU of the bidirectional counter 74LS193 for addition counting. At this time, the lower NAND gate is closed, and its output is high (waveform W4). When the photoelectric encoder rotates counterclockwise, the output waveform of channel A is delayed by 90° compared to the output waveform of channel B. The D flip-flop outputs Q (waveform W1) are low and Q (waveform W2) are high. The upper NAND gate is closed, and its output is high (waveform W3). At this time, the lower NAND gate is open, and the counting pulse passes through (waveform W4) and is sent to the decrement pulse input terminal CD of the bidirectional counter 74LS193 for subtraction counting.
When the car steering wheel rotates clockwise and counterclockwise, its maximum rotation angle is two and a half turns. An encoder with a resolution of 360 pulses/revolution is selected, and its maximum output pulse count is 900. The actual counting circuit used consists of three 74LS193 chips. During system power-on initialization, the chip is first reset (CLR signal), and then its initial value is set to 800H, which is 2048 (LD signal). Thus, when the steering wheel rotates clockwise, the output range of the counting circuit is 2048 to 2948, and when the steering wheel rotates counterclockwise, the output range of the counting circuit is 2048 to 1148. The data outputs D0 to D11 of the counting circuit are sent to the data processing circuit.
In actual use, the steering wheel is frequently turned clockwise and counterclockwise. Due to quantization errors, after working for a long time, the output of the counting circuit when the steering wheel returns to center may not be 2048, but rather deviate by a few digits. To solve this problem, we added a steering wheel centering detection circuit. After the system is working, when the simulator is in a non-operational state, the data processing circuit detects the centering detection circuit. If the steering wheel is in the centering state and the data output of the counting circuit is not 2048, the counting circuit can be reset and the initial value can be reset.
2.2 Application of photoelectric encoders in gravity measuring instruments
A rotary photoelectric encoder is used, with its shaft connected to the compensation knob shaft in the gravity measuring instrument. The angular displacement of the compensation knob in the gravity measuring instrument is converted into a certain electrical signal. There are two types of rotary photoelectric encoders: absolute encoders and incremental encoders.
Incremental encoders are sensors that output pulses. Their code disks are much simpler and have higher resolution than those of absolute encoders. Generally, only three tracks are needed. These tracks no longer have the same function as those in an absolute encoder; instead, they generate counting pulses. The outer and middle tracks of the code disk have an equal number of evenly distributed transparent and opaque sector areas (gratings), but the two sectors are offset by half a zone. When the code disk rotates, its output signals are A-phase and B-phase pulse signals with a 90° phase difference, plus a pulse signal generated by the third track, which has only one transparent slit (this serves as the reference position of the code disk, providing an initial zero-position signal to the counting system). The direction of rotation can be determined from the phase relationship (leading or lagging) of the A and B output signals. As shown in Figure 3(a), when the code disk rotates clockwise, the pulse waveform of track A leads track B by π/2, while in reverse rotation, the pulse of track A lags track B by π/2. Figure 3(b) shows a practical circuit where the lower edge of the A-channel shaping wave triggers a positive pulse generated by a monostable multivibrator, which is then ANDed with the B-channel shaping wave. When the code disk rotates forward, only the positive pulse is output; conversely, only the negative pulse is output. Therefore, the incremental encoder determines the rotation direction and relative angular displacement of the code disk based on the output pulse source and pulse count. Typically, if the encoder has N (code channels) output signals with a phase difference of π/N, the countable pulses are 2N times the number of gratings; in this case, N=2. A drawback of the circuit in Figure 3 is that it sometimes generates false pulses, causing errors. This occurs when one signal is at a 'high' or 'low' level, while another signal is fluctuating between 'high' and 'low'. In this case, although the code disk does not move, it generates a unidirectional output pulse. For example, this can happen when the code disk jitters or when manually aligned (as seen below in gravimeter measurements).
Figure 4 shows a quadruple frequency subdivision circuit that can both prevent false pulses and improve resolution. Here, a D-type flip-flop with memory function and a clock generation circuit are used. As shown in Figure 4, each channel has two D flip-flops connected in series. Thus, during the clock pulse interval, the two Q terminals (e.g., pins 2 and 7 of the 74LS175 corresponding to channel B) maintain the input state of the previous two clock cycles. If they are the same, it indicates no change during the clock interval; otherwise, the direction of change can be determined based on their relationship, thus generating a 'positive' or 'reverse' output pulse. When a channel fluctuates between 'high' and 'low' due to vibration, it will alternately generate 'positive' and 'reverse' pulses. This can be eliminated when the algebraic sum of the two counters is applied (this will also be relevant to the instrument readings below). Therefore, the frequency of the clock generator should be greater than the maximum possible value of the vibration frequency. Figure 4 also shows that four counting pulses are obtained within the original pulse signal period. For example, an encoder with 1000 pulses per revolution can generate 4000 pulses at 4 times the frequency, with a resolution of 0.09°. In fact, current sensor products of this type encapsulate the amplification and shaping circuits of the photosensitive element's output signal with the sensing element, so by simply adding subdivision and counting circuits, an angular displacement measurement system can be formed (74159 is a 4-to-16 decoder).