# Design and Implementation of a System-on-Chip for Self-Calibration of an Angular Position Sensor
## 3 Calibration Method Design
### Design of Self-Calibration Coprocessor Based on LMSED  
The coprocessor is mounted on the low speed APB for real-time data acquisition and processing. It is mainly composed of three modules: parameter identification, signal calibration, and angle calculation. The parameter identification and signal calibration modules form the self-calibration  
Figure 2: Architecture of the proposed System-on-Chip (SoC). part, whose architecture is shown in Figure 3. The parameter identification module uses the LMSED algorithm to solve the sine, cosine, and DC signal component values. Parameter calculation is then performed based on these values. The LMSED process only occurs in demodulation mode, while calculation mode directly uses the parameter calculation results to calibrate the signals. Demodulation mode works when the measured signal changes at a certain frequency. In this case, the signal model can be expressed as  
\[ \begin{array}{l}U(k)=a_{1}\cdot\sin(\omega_{c}k+\varphi)+b_{1},\\ V(k)=a_{2}\cdot\cos(\omega_{c}k+\varphi+\beta)+b_{2}.\end{array}  \tag{5}\]  
where \(k\) is the number of sampling points, \(\omega_{c}\) is the rotation speed of the angle, and \(\varphi\) is the phase difference between the reference signal and the measured signal. With reference sine, cosine, and DC components, Equation (5) can be expressed as  
\[ \begin{array}{l}U(k)=a_{1}\cos(\varphi)\cdot\sin(\omega_{c}k)+a_{1}\sin( \varphi)\cdot\cos(\omega_{c}k)+b_{1},\\ V(k)=-a_{2}\sin(\varphi+\beta)\cdot\sin(\omega_{c}k)+\ a_{2}\cos(\varphi+ \beta)\cdot\cos(\omega_{c}k)+b_{2}.\end{array}  \tag{6}\]  
Equation (6) can then be simplified to  
\[ \begin{array}{l}U(k)=a_{u}\cdot\sin(\omega_{c}k)+b_{u}\cdot\cos(\omega_{c}k )+c_{u},\\ V(k)=a_{v}\cdot\sin(\omega_{c}k)+\ b_{v}\cdot\cos(\omega_{c}k)+c_{v}.\end{array}  \tag{7}\]  
where the relationship between the reference signal components and measured signal parameters can be expressed as  
\[ \begin{array}{l}a_{u}=a_{1}\cos(\varphi),b_{u}=a_{1}\sin(\varphi),c_{u}=b_{ 1},\\ a_{v}=-a_{2}\sin(\varphi+\beta),b_{v}=a_{2}\cos(\varphi+\beta),c_{v}=b_{2}. \end{array}  \tag{8}\]  
The demodulation module obtains the coefficients of Equation (8) based on the LMSED algorithm; the principles and implementation details of this process are described in the next section. The parameter calculation module obtains the parameters of the two signals based on the relationship in Equation (8), and performs numerical calculations as shown in Equation (9):  
Figure 3: Architecture of the proposed coprocessor. \[ \begin{array}{l}a_{1}=\sqrt{a_{u}^{2}+b_{u}^{2}},p_{1}=c_{u},\\ a_{2}=\sqrt{a_{v}^{2}+b_{v}^{2}},p_{2}=c_{v},\\ \varphi=\text{atan}\Big{(}\frac{b_{u}}{a_{u}}\Big{)},\beta=\text{atan}\Big{(} \frac{a_{u}}{b_{v}}\Big{)}-\varphi.\end{array}  \tag{9}\]  
The root number and arctangent operations are contained in this module. The root number operation is performed in the digital circuit based on the fixed point iteration method [18], and is approximated by 30 iterations. For the problem of \(y^{2}=x\), the following iterative calculation method is used:  
\[y_{k+1}=y_{k}^{2}-x+y_{k},y_{0}=0. \tag{10}\]  
The design principle of the root number operation module is shown in Equation (10). In the design process, the clock used by the module is 32 times the main drive clock. Among them, the first clock cycle is used to latch the operand, 30 clock cycles are used to complete 30 iteration calculations, and the last clock cycle is used to latch the calculation result and provide an output valid signal. The arctangent operation is based on a proportional-integral (PI) controller [19], which refers to the working principle of AD2S1210 [20]. The working schematic is shown in Figure 4. The digital controller reduces the error value by adjusting the value of the reference signal. In the ideal case, when the error value is 0, the value of the reference signal is equal to the true angle value. Therefore, the iteratively adjusted reference signal value can be used as the calculated value of the real angle. The iteration formula is  
\[