# An Optical Encoder Chip with Area Compensation
## 4 Testing and Analysis  
In order to verify the performance of the chip, the test circuit shown in Figure 7 is built. Firstly, the photocurrents of the M-code are converted into voltages by trans-impedance amplifiers (TIA) and amplified in the first stage. Then the signals enter the comparators to be compared with the set threshold, and the analog signals are converted into digital signals corresponding to the code elements. The photocurrents of the incremental code are first converted into voltages by TIA and amplified in the first stage. Then, the operational amplifiers (OPA) convert the single-ended signals into differential signals, and secondary amplification is carried out simultaneously. The PCB, where the chip and its peripheral circuits are located, is mounted on a motor with a reflective code disk. The motor shaft drives the code disk to rotate, and the chip will generate the corresponding photoelectric signals. The generated signals are processed by the peripheral circuits and then connected to the oscilloscope. The output results are displayed by the oscilloscope. Since the oscilloscope has only four channels, it is impossible to simultaneously test all the outputs of the M-code photodiode arrays. To illustrate the compensation effect, the outputs of the photodiodes farthest and closest to the light source in each M array are taken as an example for illustration, that is, the outputs of photodiodes A1, A6, A11 and B1, B6, B11 in Figure 5. At the same time, an oscilloscope channel is reserved for displaying the incremental signal INC1 of the auxiliary M-code readout. Ideally, the duty cycle of the square wave signal generated by a pair of light and dark stripes on the code disk is 50%. When the LED working current is 13.56 mA and the reference level of the comparators is 0.85V, the square waves of signals of channels A1, A6, A11 and B1, B6, B11 after passing through comparators are shown in Figure 8a,b. The parts marked by dotted lines in Figure 8a are the square wave signals generated by the same pair of light and dark stripes in channels A1, A6, and A11. By calculation, the duty cycles of the square wave signals in channels A1, A6, and A11 are 50.2%, 49.1%, and 49.5% respectively. Similarly,  
Figure 6: Photo of chip. the parts marked by dotted lines in Figure 8b are the square wave signals generated by another pair of light and dark stripes in channels B1, B6, and B11. By calculation, the duty cycles of the square wave signals in channels B1, B6, and B11 are 51.8%, 50.8%, and 51% respectively. The square wave duty cycle error of the six channels is within 2%, which indicates that the output signals of photodiodes at different positions have high consistency. Then change the working current of the LED light source, and test the consistency of the output signals of each M-code channel when the LED's luminous intensity changes. Taking the three channels A1, A6, and A11 as an example, the working current of the LED is reduced to 10.71 mA. At this time, the luminous intensity of the LED decreases, and the photocurrents generated by the photodiode arrays decrease. When the reference level of the comparators remains unchanged, the duty cycles of the square wave signals generated by a pair of light and dark stripes on the code disk will become smaller, as shown in Figure 9a. The parts marked by dotted lines in Figure 9a are the square wave signals generated by the same pair of light and dark stripes in channels A1, A6, and A11. After calculation, the duty cycles of the square wave signals in the three channels are 38.2%, 36.5%, and 36.2% respectively. Similarly, when the working current of the LED is increased to 16.41 mA, the luminous intensity of the LED will increase, and the photocurrents generated by the photodiode arrays will increase. By keeping the reference level of the comparators unchanged, the duty cycles of the square wave signals generated by a pair of light and dark stripes on the code disk will become larger, as shown in Figure 9b.