# An Optical Encoder Chip with Area Compensation
## 2 Principle of Reflective Hybrid Optical Encoder  
The reflective optical encoder integrates a light source and photodiode arrays and is placed on one side of the optical code disk. When the code disk rotates, the light emitted by the light source is reflected by the code disk to form alternating light and dark stripes corresponding to the code disk pattern and return to the photodiode arrays. Photodiodes are illuminated by the reflected light and dark stripes and produce photocurrents corresponding to the light intensity. After the processing of the following circuit, the code disk pattern at the current position and the angle information corresponding to the pattern can be obtained.  
The hybrid optical encoder's code disk integrates both incremental code tracks and absolute code tracks. The code disk structure used in this study adopts a four-track design. As shown in Figure 1, the innermost and outermost code tracks on the code disk are absolute code tracks, and the two middle code tracks are incremental code tracks. There are 512 light and dark stripes with the same sequence on the two absolute code tracks, and the coding method is M-code [9]. M-code, also known as the maximum length sequence, is a pseudo-random sequence composed of binary digits 0/1. For an M sequence of n bits, all subsequences of length n are unique and occur only once in a cycle [22]. Therefore, the M-code can be used to encode the angle value on the circumference uniquely, and the absolute position information can be obtained by decoding.  
Figure 1: (**a**) Overall code disk structure. (**b**) Local code disk structure.  
Since the signal at the junction of the light and dark stripes is prone to miscoding when reading discrimination, the relative positions of the two M-code tracks on the code disk in the direction of rotation are designed to differ by half a bit (half the width of a code element). In this way, when the junction of the light and dark stripes of the outer M-code track rotates to the center of the outer photodiode array, the light and dark stripes generated by the inner M-code track align with the inner photodiode array. At this time, the signal of the inner photodiode array can be read to obtain the current position information and vice versa. In this way, the detection accuracy can be improved, and the bit error rate can be reduced. The selection of the two M-code track signals is realized by the sinusoidal signal generated by the incremental code track close to the inner side. There are 512 pairs of light and dark stripes on this incremental code track, and the width of a pair of light and dark stripes corresponds to the width of one stripe in the M-code track. During the rotation process, the period of the sinusoidal signal generated by the incremental code track is the same as the period of one code element of the absolute code. During the 0\({}^{\circ}\)-180\({}^{\circ}\) period of one sinusoidal signal, the signal of the inner M-code track is read, and during the 180\({}^{\circ}\)-360\({}^{\circ}\) period, the signal of the outer M-code track is read, so as to achieve the selection of the M-code track signals, as shown in Figure 2. The black arrows in Figure 2 mark the reading range of the two M-code track signals. There are 1024 pairs of light and dark stripes on the incremental code track near the outer side, which are used to achieve angle subdivision.