# An Optical Encoder Chip with Area Compensation
## 3 Theoretical Analysis of Light Intensity and Compensation Design
### Design of Photodiode Area Compensation  
The image obtained by the light source irradiating the code disk can be regarded as the image of the code track pattern magnified by \(\varepsilon\) times, as shown in Figure 4. The value of magnification \(\varepsilon\) is related to the height \(h\) from the light source to the code disk and the height \(H\) from the code disk to the photodiode arrays. According to the principle of similar triangles, the expression of magnification \(\varepsilon\) can be obtained as follows:  
\[\varepsilon=\frac{H+h}{h}=\frac{2H-\Delta h}{H-\Delta h} \tag{6}\]  
where \(\Delta h\) is the height of the LED light source relative to the photodiode arrays. The imaging size and position corresponding to the code elements can be calculated according to the magnification and the pattern size of the M-code track. Figure 3: Solid angle relationship when the receiving plane is not perpendicular to the light direction. After obtaining the imaging information of the code element, the photodiode can be placed at the imaging location. For the M-code track with 512 (\(2^{9}\)) light and dark stripes, nine photodiodes are generally required. Due to the need for error detection and correction in the digital part, a redundant photodiode is added on the left and right sides so that each M-code track corresponds to 11 photodiodes, as shown by the dotted lines in Figure 5. In Figure 5, the M-code track near the outer side of the code disk corresponds to the photodiode array M1, and the M-code track near the inner side corresponds to the photodiode array M2. In order to realize the consistency of the output signals of different channels of M-code, it is necessary to make corresponding area compensation according to the irradiance of 22 photodiodes. In this study, the photocurrent generated by the photodiode at position B6 in Figure 5 is used as the benchmark, and the area compensation is performed for the photodiodes at the remaining positions. The current \(I_{c}\) generated by each photodiode is related to the incident light power \(P\) received by the photodiode, and their relationship is as follows:  
\[I_{c}=R(\lambda)\times P \tag{7}\]  
where \(R(\lambda)\) is the responsivity of the photodiode, which is defined as the ratio of the photocurrent generated by the photodiode to the incident light power at a certain wavelength. Figure 4: Schematic diagram of code track pattern amplification relationship. Figure 5: Photodiode arrays corresponding to M-code track. Its value is given by the process manufacturer, and the responsivity of the photodiodes in different positions is the same. Each photodiode's incident light power \(P\) equals to the integral of its radiation illuminance and the light receiving area. For the convenience of calculation, Equation (5) needs to be expressed in the rectangular coordinate system. Because the light source and the photodiode arrays are in the same plane, that is, the normal of the light source surface is parallel to the normal of the receiving surface, so \(\theta=\beta\) in Equation (5). Suppose the plane where the light source is located is the \(xy\) plane, and the \(z\)-axis represents the normal direction of the LED light source surface. If the coordinates of the light source are \((X,Y,0)\), the expression of Equation (5) in the rectangular coordinate system is as follows:  
\[E(x,y,z)=\frac{z^{m+1}I_{0}}{\left[\left(x-X\right)^{2}+\left(y-Y\right)^{2}+ z^{2}\right]^{\left(m+3\right)/2}} \tag{8}\]  
where \(x\),\(y\) and \(z\) are the coordinates of any point on the receiving surface. \(I_{0}\) is the light intensity of the LED along the normal direction of the light source surface.