# Research on Permanent Magnet Synchronous Motor Control System Based on Adaptive Kalman Filter
## 2 Theoretical Analysis of the EKF
### The PAEKF Model of the PMSM  
When the EKF cannot obtain the accurate process noise Q in advance, calculating the prior estimation of covariance in the EKF cannot be used. Using inaccurate or false process noise Q will deviate the priori covariance and Kalman gain matrix. The optimal estimation of Kalman cannot be obtained, which results in instability of the filter. Finally, the accuracy of a priori state estimation is affected. In order to eliminate the dependence of EKF on a priori and exact Q and keep the simplicity of EKF, this paper proposes a new PAEKF to improve the covariance calculation steps of EKF innovatively.  
In the model of the PMSM, PAEKF retains the state prediction step, the gain calculation step, and the state update step. The new calculation method replaces the previous covariance calculation step, which can be expressed as [26]:  
\[\begin{array}{l}P_{k|k-1}=P_{k-1|k-2}+\Delta P_{k-1},\\ \Delta P_{k-1}=(\Delta x_{k-1}\Delta_{k-1}^{T}-K_{k-1}HP_{k-1|k-2})/(k-1)\end{array} \tag{11}\]  
where \(P_{k|k-1}\) calculated by the new adaptive Kalman filter method, which represents the estimation of a priori error covariance at time k, \(\Delta P_{k-1}\) represents the adjustment amount of \(P_{k|k-1}\) at the previous time, which can be calculated from a piece of posterior information, \(\Delta x_{k}\) represents the sequence of a posterior residual vector, which is obtainedby the difference between the posterior state vector and the a priori state vector of the Kalman filter, and its representation is  
\[\Delta x_{k}=\hat{x}_{k}-\hat{x}_{k|k-1},k=1,2,\ldots,k-1 \tag{12}\]  
(11) can be obtained by calculating maximum likelihood estimation [26]. Given that Gaussian noise innovation sequence with a mean value of 0 is set up as \(\varepsilon_{k}=y_{k}-H\hat{x}_{k|k-1}\). And its covariance is \(E(e_{k}e_{k}^{T})=C_{k}=HP_{k|k-1}H^{T}+R\). \(\varepsilon_{k}=\{e_{1},e_{2},\ldots e_{k-1}\}\) is the set of historical innovation sequence before time k. It is assumed that at any time \(j\) (\(j=1,2,\ldots,k-1\)), the priori error covariance of the optimal Kalman filter is invariant. By calculating the maximum likelihood function:  
\[L(\hat{P}_{k|k-1})=\ln P(\varepsilon_{k}|\hat{P}_{k|k-1})=\ln\prod_{j=1}^{k-1} P(e_{j}|\hat{P}_{k|k-1})=\sum_{j=1}^{k-1}\ln P(e_{j}|\hat{P}_{k|k-1})\,, \tag{13}\]  
a priori-error covariance calculation method that does not require noise parameter Q participation is obtained.  
Finally, the new adaptive Kalman filter model of permanent magnet synchronous motor can be expressed as  
\[\hat{x}_{k|k-1}=\hat{x}_{k-1}+[f(\hat{x}_{k-1})+Bu_{k-1}]T, \tag{14}\]  
\[\Delta P_{k-1}=(\Delta x_{k-1}\Delta_{k-1}^{\text{T}}-K_{k-1}HP_{k-1|k-2})/(k -1), \tag{15}\]  
\[K_{k}=P_{k|k-1}H^{\text{T}}[HP_{k|k-1}H^{\text{T}}+R]^{-1} \tag{16}\]  
\[\hat{x}_{k}=\hat{x}_{k|k-1}+K_{k}(y-H\hat{x}_{k|k-1}) \tag{17}\]  
The new PAEKF model of PMSM is shown in Figure 1. The key of the proposed adaptive Kalman filter is the covariance, which is obtained by using the new adaptive scheme Equation (15). Firstly, the feedback item \(\Delta P_{k-1}\) can be calculated by the posteriori residual vector sequence \(\Delta x_{k-1}\). Then, the priori error covariance \(\Delta P_{k-1|k-2}\) can be corrected by the feedback term \(\Delta P_{k-1}\) at the previous time. Finally, the priori error covariance \(P_{k|k-1}\) at the new time is obtained.