Next Article in Journal
Accessible Battery Model with Aging Dependency
Previous Article in Journal
Modular Marx Generator Based on SiC-MOSFET Generating Adjustable Rectangular Pulses
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Implementation of Extended Kalman Filter with Optimized Execution Time for Sensorless Control of a PMSM Using ARM Cortex-M3 Microcontroller

by
Justas Dilys
1,2,*,
Voitech Stankevič
1,2 and
Krzysztof Łuksza
3
1
State Research Institute Center for Physical Sciences and Technology, Sauletekio Ave. 3, LT-10257 Vilnius, Lithuania
2
Vilnius Gediminas Technical University, Naugarduko 41, LT-03227 Vilnius, Lithuania
3
Department of Power Electronics and Electrical Machines, Gdansk University of Technology, ul. Sobieskiego 7, 80-216 Gdansk, Poland
*
Author to whom correspondence should be addressed.
Energies 2021, 14(12), 3491; https://doi.org/10.3390/en14123491
Submission received: 21 May 2021 / Revised: 7 June 2021 / Accepted: 8 June 2021 / Published: 12 June 2021
(This article belongs to the Topic Power System Modeling and Control)

Abstract

:
This paper addresses the implementation and optimization of an Extended Kalman Filter (EKF) for the Permanent Magnet Synchronous Motor (PMSM) sensorless control using an ARM Cortex-M3 microcontroller. A various optimization levels based on arithmetic calculation reduction was implemented in ARM Cortex-M3 microcontroller. The execution time of EKF estimator was reduced from 260.4 μs to 37.7 μs without loss of accuracy. To further reduce EKF execution time, the separation of a Kalman gain and covariance matrices calculation from prediction and measurement state update, a novel method was proposed, and the performance of it an EKF estimator with separation of a Kalman gain and covariance matrices calculation from prediction and measurement state update was analyzed. Simulation and experiments results validate that the proposed technique could provide the same accuracy with less computation time. A tendency of minimum Kalman gain and covariance matrices calculation frequency from rotor electrical frequency was analyzed and are presented in the paper.

1. Introduction

Permanent Magnet Synchronous Motor (PMSM) technology has become attractive thanks to its energy saving capabilities and high dynamic performance. PMSMs have been increasingly used in autonomous electric vehicles, drones, smart buildings and many automation processes [1].
In motor control applications requiring high efficiency, the information about the rotor speed and position is essential to provide feedback for the control loops. The use of mechanical position sensors in motor drives increases the drive’s cost and decreases the system’s reliability. Therefore, sensorless control would be a practical alternative to the motor control with mechanical sensors. Nowadays, the sensorless control is an essential feature of commercial products in the field of electric motor drives. A popular and widely used sensorless control algorithm is the Extended Kalman Filter (EKF). The EKF is an optimal algorithm which minimizes the mean square error of the estimated quantities. It takes into account the model inaccuracies and measurement noises, and comes up with an accurate estimation result [2,3]. Because of heavy online computation, performed on matrices, the EKF algorithm is a time-consuming process [4]. In order to address this problem, various optimization algorithms which can lower the computational costs have been reported. Computational cost of the full order EKF can be minimized by a reduced order model [5,6,7]. The idea of these filters is to reduce the number of states of the model by engineering approximation methods. Also, the order reduction simplifies the tuning of the covariance matrices. However, the decrease of the state order can add accuracy damage. Similarly, the reduced order filter taken with the full model order is obtained by minimizing the trace of the estimation error covariance [8]. However, this method is more practical for systems with large number of states. A novel parallel computational mechanism by defining “useful” data and subdividing computation process is proposed in [9]. In this method, optimization is obtained based on exploiting the numerical characteristics of the system. A various optimization methods for Kalman filter extensions is presented in [10].
Moreover, to provide with system superior robustness and good dynamic performance, online tuning of the electrical parameters is necessary, leaving a small room for the EKF [11]. Therefore, most of the researchers have chosen Digital Signal Processors (DSPs) [12,13] or field programmable logic arrays (FPGAs) [14,15,16,17] for the EKF implementation. In a DSP example without simplification, EKF execution time was obtained 71.6 μ s [4]. The impressive EKF implementation on DSP with 17 μ s execution time of EKF was achieved [18]. While the execution time is short, it is still long for direct torque control, where much shorter sampling period is required compared with field oriented control. In another DSP example, the total execution time of the EKF, matrix converter and all control algorithms fit into 400 μ s [19]. While the using FPGA, the EKF execution time 13.36 μ s was achieved [20].
However, in many applications the use of DSP processors is not a cost-effective solution. While the cost of the FPGA is lower, the complete system will mostly still require a DSP or another type of processor for the whole system to be implemented. An alternative solution for low-cost and low-power systems are the ARM Cortex-M3 microcontrollers [21]. ARM Cortex-M3 are low-cost, low-power microcontrollers that can replace the existing 8-bit microcontrollers, while still offering 32-bit performance.
In this paper, a strategy is proposed to separate EKF matrices calculation from prediction and measurement update steps, to minimize the overall time consumption of the EKF algorithm. The strategy was simulated with Matlab programming language and implemented on the ARM Cortex-M3 microcontroller.

2. State-Space PMSM Model

A dynamic model of a surface-mounted permanent magnet synchronous motor and a sinusoidal flux distribution in a stationary reference frame ( α , β ) is expressed by the following system of differential equations:
d i α d t = R s L s i α + λ m L s ω e sin θ e + v α L s d i β d t = R s L s i β λ m L s ω e cos θ e + v β L s d ω e d t = 3 2 λ m J ( i β cos θ e i α sin θ e ) B J ω e T L J d θ e d t = ω e
where: i α and v α are the α axis current and voltage; i β and v β are the β axis current and voltage; R s is the stator resistance; L s is the stator phase inductance; P is the number of the pole pairs; w e and θ e are the rotor electrical angular speed and position respectively; J and B are the rotor inertia and viscous damping coefficients respectively; T L is load the electrical torque. The voltages v α , v β and the load torque T L are the deterministic control inputs of the system. Both the voltages v α , v β and current i α , i β components are the measurable quantities (2). The stator phase currents i a , i b and i c are stator phase currents, which are measured directly.
i α = 2 3 ( i a i b 2 i c 2 ) i β = ( i b i c ) 3 .
The current components in the α - β reference frame are obtained from the three phase stator components by a linear transformation [12]. Similar equations hold for the voltages.

3. EKF Estimator

The Kalman filter is a mathematical model that runs in parallel to the actual system and provides the estimation of the states of linear systems. It provides a feedback as the difference between the measured output and constantly corrects the model with the error signal. The feedback gain is calculated so that the estimate of state is optimal. The block diagram of Kalman filter are shown in Figure 1.
The state-space model for Kalman filter implementation is derived from (1) with the assumption that the speed w e is constant during the switching period [22,23].
d i α d t = R s L s i α + λ m L s ω e sin θ e + v α L s d i β d t = R s L s i β λ m L s ω e cos θ e + v β L s d ω e d t = 0 d θ e d t = ω e .
The α - β axes stator currents i α , i β , the angular electrical rotor speed w e and position θ e are treated as system states. The voltages v α , v β as the input variables. A nonlinear dynamic model accounting for the state transition w and measurement noise v can be expressed generally as:
x ˙ = f ( x ) + B c u + w y = H x + v .
The Gaussian noises w and v are white, zero-mean and uncorrelated, and have known covariance matrices Q and R respectively. For good EKF performance the choice of the covariance matrices P , Q and R is crucial. The covariance matrices P , Q and R are symmetric and positive defined symmetric matrices. Covariance matrices give the statistical description of the model inaccuracy. Matrix Q represents the statistical description of the model, matrix R indicates the magnitude of measurement noise, matrix P 0 contains the information of variances at the initial conditions and mainly affects the convergence rate of EKF in the transient condition [24]. Since these are usually unknown, in most cases the EKF matrices are designed and tuned by trial-and-error procedures [25].The state vector x is denoted as u is input vector and y is the output vector:
x = i α i β ω e θ e T , u = V α V β T , y = i α i β T .
The model’s matrices are expressed as follows:
f ( x ) = f 1 f 2 f 3 f 4 = R s L s i α + λ m L s ω e sin θ e R s L s i β λ m L s ω e cos θ e 0 ω e ,
B c = 1 L s 0 0 1 L s 0 0 0 0 , H = 1 0 0 1 0 0 0 0 ,
B = T B c = T L s 0 0 T L s 0 0 0 0
where T is sampling time. The PMSM model described by (6) is nonlinear as products of variables are involved. The nonlinear function f ( x ) is approximated by a linear set. The continous time Jacobian matrix is expressed as:
F c = f ( x ) x | x = x k 1 = f 1 i α f 1 i β f 1 w e f 1 θ e f 2 i α f 2 i β f 2 w e f 2 θ e f 3 i α f 3 i β f 3 w e f 3 θ e f 4 i α f 4 i β f 4 w e f 4 θ e = R s L s 0 λ m L s sin θ e λ m L s ω e cos θ e 0 R s L s λ m L s cos θ e λ m L s ω e sin θ e 0 0 0 0 0 0 1 0
where the previous estimate of x as a reference point is taken for discretization around this point. For digital implementation the system model (4) has to be discretized. The discrete nonlinear dynamic model is expressed as follows:
x ˙ k = F k 1 x k 1 + B u k 1 + w k 1 y = H x k + v k
where in (11) the matrices x k , F k 1 , u k 1 are discrete matrices of x , F c , u respectively, and the matrices w k 1 , v k are discrete matrices of w , v respectively, independent of the system state. Based on Equation (9) after discretization of F c the Jacobian matrix is:
F k = F = e F c T I + F c T = 1 T R s L s 0 T λ m L s sin θ e T λ m L s ω e cos θ e 0 1 T R s L s T λ m L s cos θ e T λ m L s ω e sin θ e 0 0 1 0 0 0 T 1
where the matrix F in (11) is a discrete, linearized Jacobian matrix.
The extended Kalman filter can be realized by the following steps. The first step is a time update of the state vector and the error covariance matrix, in which a prediction based on the previous estimates x ^ k 1 is performed:
F k 1 = F ( x = x ^ k 1 )
x ^ k = x ^ k 1 + T f ( x ^ k 1 ) + B u k 1
P k = P k 1 F k 1 P k 1 T + Q
where the Jacobian matrix (12) is computed too. Important to note is that the state prediction is done by integrating Equation (13) with Runge-Kutta or other similar method. The second step is a measurement update that corrects the predicted state estimate x ^ k and its error covariance P k matrix through a feedback correction:
P k = ( I K k H ) P k
x ^ k = x ^ k + K k ( y k H x ^ k )
where the extended Kalman filter gain matrix K k is:
K k = P k H T ( H P k H T + R ) 1
Also the correction of the estimated rotor position (18) to limit the angle to a 2 π interval is added:
x ^ k ( 4 ) = x ^ k ( 4 ) 2 π k , k = x ^ k ( 4 ) / 2 π .
The estimation error covariance matrix P denotes the error of the state vector x ^ (19).
P = E [ ( x ^ x ^ ¯ ) ( x ^ x ^ ¯ ) T ] = P 11 P 12 P 13 P 14 P 21 P 22 P 23 P 24 P 31 P 32 P 33 P 34 P 41 P 42 P 43 P 44
where E [ ] is an operator computing the mean of the variable inside the brackets and x ^ ¯ is the mean of the estimated variable. The error covariance matrix P is a degree of accuracy of the estimate. If P is large the error of the estimate is large and if is small the error of the estimate is small. The element P 44 is the variance of the rotor position and it could be an indicator of how well the Kalman filter estimate rotor position. The Kalman gain matrix (20):
K = K 11 K 12 K 21 K 22 K 31 K 32 K 41 K 42
is used as weighting in the measurement update process. The measurement update Equation (16) corrects the state, accounting for the measurements, and can be expressed as:
i α ^ k = i α ^ k + K 11 ( i α k i α ^ k ) + K 12 ( i β k i β ^ k ) i β ^ k = i β ^ k + K 21 ( i α k i α ^ k ) + K 22 ( i β k i β ^ k ) ω e ^ k = ω e ^ k + K 31 ( i α k i α ^ k ) + K 32 ( i β k i β ^ k ) θ e ^ k = θ e ^ k + K 41 ( i α k i α ^ k ) + K 42 ( i β k i β ^ k ) .
In Equation (21) the elements K 41 and K 42 are position correction gains. As only the stator winding currents can be measured, the rotor position and velocity are mainly estimated in measurement update steps.

EKF Technique with Parallel Calculation

The EKF calculation is separated into two different procedures. One is the control procedure and the other the background procedure. The sequence of the EKF algorithm implementation is shown in Figure 2 as a flow diagram.
The control procedure is executed on every PWM switching period and predicts the new state vector using (13), updates the predicted state vector using (16). And also corrects the estimated rotor position to a periodic function using (18). The background procedure calculates the Kalman gain and all covariance matrices. The background is executed on every time m. The majority of the EKF algorithm computation is performed in the background procedure and runs in a periodic cycle, just like the control procedure. The calling rate of the background procedure is the same or smaller, compared to the control procedure.
The reduced Kalman gain and all covariance matrices calculation ratio could be treated like PMSM model are constant for period of time equal to background procedure call period. While the Kalman gain and all covariance matrices calculation ratio is reduced the prediction state (13) and measurement correction state (16) are executed on every control cycle. The prediction state (13) is always updated with the newest input variables in every control cycle. The measurement correction state (16) is also fed with the newest measurements, but with the Kalman gains being constant for a period of time equal to control period.
As shown in Figure 3 the background task period T b is longer or the same compared to T s = 1 F s where F s is PWM switching frequency. The background procedure is separated from the control procedure and does not depend on the PWM switching frequency. The switching frequency can be set to a very high value, while the background procedure can run at a much lower frequency. The total process execution time of EKF could be significantly reduced, because the heavy calculation are doing in background task with period longer than control period.
The control procedure has a higher priority and interrupts the background procedure when it is time to execute it. The synchronization is also performed in the background task, the state vector is taken from the control procedure and the Kalman gain is provided to the control procedure after it is computed. After Kalman gain has been computed in the background procedure, it is important immediately to copy the new Kalman gain matrix into the control procedure to allow control procedure more effectively, to use Kalman gain.

4. Simulation Results

Simulations have been performed with the Matlab programming language. To verify the performance of the proposed EKF algorithm, the simulated PMSM parameters were set for the same values as in the experimental setup and are presented in Table 1.
In order to make the simulation model consistent with further experimental verification, the space vector pulse width modulation (SVPWM) and overall field oriented control system was simulated. In order to verify the effectiveness of the EKF algorithm based on parallel computation, the simulation was carried out for different set point speed values. The performance of sensorless control for various motor speeds is investigated in simulation. The initial state covariance matrix P 0 and covariance matrices accounting for the model and measurement ( Q and R respectively) are as follows:
P 0 = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 , Q = 1 0 0 0 0 1 0 0 0 0 500 0 0 0 0 0.1 , R = 1 0 0 1 .
The EKF algorithm in Figure 2 was the main research object. There, the Kalman gain matrix and its covariance matrices calculation is performed in the background procedure while the prediction and update in the control procedure. The different frequency ratios of the background to the control procedure of the EKF performance at various fundamental motor speeds was researched.
The EKF performance, the Kalman gain and all covariance matrices calculated at the same rate of 5 kHz, are shown in Figure 4. In Figure 5 the Kalman gain and all covariance matrices are calculated at a five times slower rate of f b = 1 kHz, while the control procedure execution rate is the same (5 kHz). Comparing Figure 4c with Figure 5c can be seen that the position error did not increase. The position variance P 44 in Figure 4b and Figure 5b is approximately equal too, only the discretization is different. The Kalman gains K 41 and K 42 for position estimation in Figure 4d and Figure 5d have the same amplitude peak values and have similar sine waveform shapes, but the waveform in Figure 5d are more discretized. The discretization is because of reduced calculation frequency of Kalman gain in simulation is taken. From comparison of Figure 4 and Figure 5 we can conclude that the magnitudes of Kalman gain for position estimation did not change, only it’s discretization. For a period of time Kalman gain values are constant values, and they are used multiple time in correction step. Even Kalman gains are constant values the prediction step and correction steps still corrects state vector accounting new measurements.
Further simulation has shown, that slowing down the Kalman gain and covariance matrices calculation frequency could cause a rise in the rotor position estimation error, causing a loss of the synchronization and causing the rotor speed to drop to zero. The relation between the minimum Kalman gain and covariance matrices calculation frequency f b m i n and the fundamental rotor electrical rotor frequency ( f e = w e / 2 π ) was investigated. To found the relation f b m i n f e the simulations were run by decreasing frequency f b for fixed rotor speed reference set-point w e r e f until control was lost. The loss of control was easily determined from rotor speed not able to reach reference speed in simulation. For various rotor reference speeds w e r e f the minimum Kalman gain update frequency f b m i n are shown in Figure 6a. From Figure 6a we can conclude that the higher the reference speed was set the higher Kalman gain update frequency was required. From Figure 6a we can see linear trend of f b m i n to f e . The steps in Figure 6a mainly are due to simulation strategy when frequencie f b were selected in steps by dividing switching frequency by integer value ( f b = f s / n, n = 1,2…). The Figure 6b is obtained from figure Figure 6a by dividing each f b m i n by f e . While the data in Figure 6b are the same we can see how many times we have to compute Kalman gain per rotor electrical frequency without lost control.

5. Implementation

For the implementation of the EKF algorithm in a real experimental drive system an NXP LPC1549 microcontroller was used. The LPC1549 microcontroller is a 32 bit ARM Cortex-M3 based microcontroller operating at a frequency of up to 72 MHz. It is a microcontroller characterized by a low cost and very low power consumption. It includes two 2 Msamples ADCs, four voltage comparators and a PWM/timer subsystem with four configurable multi-purpose state configurable timers. As the LPC1549 microcontroller does not support of floating point operations, all calculation was performed on integer type variables. Data type of the variables used in the implementation is 16 bit fixed point variable with 32 bit long words. For the implementation in C language and code compilation the IAR compiler was used. Different optimization levels for speed comparison are given in Table 2.
The EKF algorithm implementation using common matrices calculation procedures, with the IAR compiler and with no optimization, gave the longest total execution time 260.4 μ s. Better results were obtained by setting the compiler optimization to a high level. However, the total execution time is still too long for a practical application. A good execution optimization could be achieved by discarding the common matrices calculation procedures, replacing them with simple arithmetic expressions and accounting for all zero elements and symmetry. In this case the total execution time drops to 37.7 μ s and could be used for some practical applications.
However, in situations where very high switching frequency is desired, or other heavy calculations need to be performed, the execution time could still be too long. By implementing the EKF algorithm given in Figure 2 the total execution time could be reduced further. In experimental implementation the switching frequency is selected as 5 kHz and the background procedure call frequency is 1 kHz. In this case the total microcontroller usage for the EKF algorithm calculation is 6.21%. However, if the entire EKF calculation is performed in one switching period, the microcontroller uses as much as is 18.85% of its computational power. With these settings the total microcontroller processing time for EKF is reduced more than 3 times.

6. Experimental Setup and Results

The experimental test platform is shown in Figure 7. The test setup mainly consists of: a 30 W PMSM motor driven by an NXP inverter FRDM-MC-LVPMSM; other PMSM as a load; the NXP board Xpresso-LPC1549; DC voltage power supply 24V; 360P photoelectric incremental rotary encoder; personal computer (PC).
The PMSM parameters used in experimental setup are defined in Table 3. All measurements are done in real time by an LPC1549 microcontroller and data are transferred into a personal computer. The phase current was sampled by sensors while the phase voltages taken from control algorithm. The rotor position estimated by the EKF was compared to the signal obtained from a photoelectric incremental rotary encoder. In Figure 8a the estimated rotor position is compared with rotor position measured by the encoder, for the reference speed set to 400 rad/s. Figure 8b shows position variance and Figure 8d presents the Kalman gains for position measurement corrections. The switching frequency f s was set for 5 kHz, while the Kalman gain and all covariance matrices are calculated at the same frequency of f b = 5 kHz.
In Figure 9 the same measurements are performed, but with a reduced Kalman gain and covariance matrices calculation frequency f b of 1 kHz. To get results in Figure 9 the Kalman gain and covariance matrices are computed 5 times slower. Comparing the results presented in Figure 8b with Figure 9b one can see, that the position error is about the same average value. More details about position error dependency are presented below. The position variance P 44 in Figure 8a and Figure 9a is about the same average value [ 0.35 0.37 ]. This means that the variance of estimated position did not change with reduced Kalman gain and covariance matrices calculation frequency. The Kalman gains for position estimation in Figure 8d and Figure 9d have the same amplitude peak values and have similar shapes, but the shape in Figure 9d are more discrete. A bigger discretization steps are mainly due to reduced calculation frequency of Kalman gain. During a short time ( 1 / f b ) the Kalman gain matrix is assumed to be a constant value. And the Kalman gain matrix is used multiple times in control procedure until background procedure calculates new one.
Further experimental tests have shown that the position error did not increase when reducing the Kalman gain, and it’s covariance matrices calculation rate, until some minimum frequency f b m i n is reached. The position errors at various f b frequencies are shown in Figure 10. In Figure 10e the Kalman gain, and it’s covariance matrices calculation update rate is 12 times slower ( f b = f s / 12 ) than the switching frequency, while the position error order is about the same, as when calculated in every switching instance.
However, slowing the Kalman gain and covariance matrices calculation update rate will cause the synchronization to be lost. By setting: f b = f s / 13 and reference speed w e r e f = 400 Hz the synchronization is lost, and the rotor speed drops to zero and reverse spin occurs as shown in Figure 11.
The last experimental tests have shown that the minimum Kalman gain and covariance matrices calculation update rate depends on the fundamental electrical rotor speed and this relation is very similar to simulation results.
The Figure 12a depicts the relation between the minimum matrices calculation frequency f b m i n and fundamental rotor frequency f e . To obtain the relation of f b f e the experiments with different speed reference points was analyzed. For each speed reference point, the minimum frequency f b m i n was searched. The frequency f b m i n considered enough high if the motor speed with constant reference speed was controllable. In the experiment, the frequency f b m i n was reduced until the control was lost. The loss of the control was easy to see from the rotor speed not able to follow the speed reference set-point, the speed of the rotor dropped to zero. The synchronization was obviously lost. From this experiments it could be seen that the higher the reference speed, the higher update matrices calculation rate was needed. From Figure 12a the relation of minimum required f b m i n and f e is linear. The Figure 12b presents the same measured data as in Figure 12a, by taking ratio f b f e . From Figure 12b can be seen how many times per rotor electrical period, the Kalman gain and covariance matrices has to be computed without losing control. From Figure 12b we can conclude, that for high frequencies ( f e > 50 Hz) the minimum 7 times Kalman gain and covariance matrices have to be computed per one rotor electrical period. The lower ratio of the Kalman gain and covariance matrices calculation ratio ( f b f e < 6 ) will mostly cause lost control. The higher ratio ( f b f e > 7 ) of course will be good, but the higher ratio means more computation power are needed. Also, from Figure 12b we can conclude, that at low frequencies ( f e < 50 Hz) the ratio f b f e is higher than 7 is needed, but from Figure 12a we can see that the required minimum frequency f b m i n is decreasing even if the ratio increase f b m i n f e .
ARM Cortex-M3 LPC1549 processor usages for executing EKF estimator with various background frequencies are given in Table 4. The data from Table 2 was used for calculating usages. Also, by applying the role that at least 7 times per one rotor electrical period Kalman gain and covariance matrices have to be computed, we get maximum allowed electrical frequency ( f e m a x ) in control. That level of optimization to choose is a trade-off decision between processor usage and the maximum allowed electrical frequency in the system.
From Table 4 can be seen that even reduction of background frequency by two times from 5 kHz to 2.5 kHz gives a good time optimization. The further reduction gives less win of the processor time for each step.

7. Conclusions

This paper proposes optimized EKF estimation method for PMSM sensorless control with low execution time. The computational methods used to simplify the EKF estimator and their implementation in fixed-point arithmetic are discussed. Experiments and simulation have been carried out to evaluate the performance and the computing cost of the EKF based on Kalman gain and all covariance matrices calculation in separation from the prediction and update steps. The primary conclusions are summarized as follows:
  • Separation of the Kalman gain and all covariance matrices calculation from prediction and update steps could provide the same accuracy with less execution time of the processor.
  • The minimum required Kalman gain and all covariance matrices update ratio depend on the fundamental electrical frequency, the higher electrical frequency the higher update frequency required.
  • The estimated rotor position error did not increase until minimum required Kalman gain and all covariance matrices update ratio is reached.

Author Contributions

Conceptualization, J.D; methodology, J.D.; software, J.D.; validation, J.D., V.S. and K.Ł.; formal analysis, J.D, V.S. and K.Ł.; investigation, J.D.; resources, J.D.; data curation, J.D.; writing-original draft preparation, J.D.; writing-review and editing, J.D., V.S. and K.Ł.; visualization, J.D.; supervision, J.D.; All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Chandler, J. Pmsm Technology in High Performance Variable Speed Applications; Automotion Inc.: Ann Arbor, MI, USA, 2008. [Google Scholar]
  2. Wei, Z.; Tseng, K.J.; Wai, N.; Lim, T.M.; Skyllas-Kazacos, M. Adaptive estimation of state of charge and capacity with online identified battery model for vanadium redox flow battery. J. Power Sources 2016, 332, 389–398. [Google Scholar]
  3. Wei, Z.; Zhao, J.; Ji, D.; Tseng, K.J. A multi-timescale estimator for battery state of charge and capacity dual estimation based on an online identified model. Appl. Energy 2017, 204, 1264–1274. [Google Scholar] [CrossRef]
  4. Tondpoor, K.; Saghaiannezhad, S.M.; Rashidi, A. Sensorless Control of PMSM Using Simplified Model Based on Extended Kalman Filter. In Proceedings of the 2020 11th Power Electronics, Drive Systems, and Technologies Conference (PEDSTC), Tehran, Iran, 4–6 February 2020; pp. 1–5. [Google Scholar]
  5. Alex, S.S.; Daniel, A.E.; Jayanand, B. Reduced order extended Kalman filter for state estimation of brushless DC motor. In Proceedings of the 2016 Sixth International Symposium on Embedded Computing and System Design (ISED), Patna, India, 15–17 December 2016; pp. 239–244. [Google Scholar]
  6. Glasberger, T.; Mužíková, V.; Peroutka, Z.; Šmídl, V. Sensorless direct torque control of PMSM with reduced model Extended Kalman filter. In Proceedings of the IECON 2013—39th Annual Conference of the IEEE Industrial Electronics Society, Vienna, Austria, 10–13 November 2013; pp. 8239–8244. [Google Scholar]
  7. Chen, H.; Liu, B.; Qu, Y.; Zhou, X. Low speed control for PMSM based on reduced-order adaptive Kalman filter. In Proceedings of the 33rd Chinese Control Conference, Nanjing, China, 28–30 July 2014; pp. 7959–7963. [Google Scholar]
  8. Simon, D. Reduced Order Kalman Filtering without Model Reduction. Control. Intell. Syst. 2007, 35, 169–174. [Google Scholar] [CrossRef] [Green Version]
  9. Hu, S.; Xu, S.; Wang, D.; Zhang, A. Optimization Algorithm for Kalman Filter Exploiting the Numerical Characteristics of SINS/GPS Integrated Navigation Systems. Sensors 2015, 15, 28402–28420. [Google Scholar] [CrossRef] [PubMed]
  10. Raitoharju, M.; Piché, R. On Computational Complexity Reduction Methods for Kalman Filter Extensions. IEEE Aerosp. Electron. Syst. Mag. 2019, 34, 2–19. [Google Scholar]
  11. Bolognani, S.; Zigliotto, M.; Zordan, M. Extended-range PMSM sensorless speed drive based on stochastic filtering. IEEE Trans. Power Electron. 2001, 16, 110–117. [Google Scholar] [CrossRef]
  12. Dhaouadi, R.; Mohan, N.; Norum, L. Design and implementation of an extended Kalman filter for the state estimation of a permanent magnet synchronous motor. IEEE Trans. Power Electron. 1991, 6, 491–497. [Google Scholar] [CrossRef]
  13. Bolognani, S.; Oboe, R.; Zigliotto, M. Sensorless full-digital PMSM drive with EKF estimation of speed and rotor position. IEEE Trans. Ind. Electron. 1999, 46, 184–191. [Google Scholar] [CrossRef]
  14. Quang, N.K.; Tung, D.D.; Ha, Q.P. FPGA-based sensorless PMSM speed control using adaptive extended Kalman filter. In Proceedings of the 2015 IEEE International Conference on Automation Science and Engineering (CASE), Gothenburg, Sweden, 24–28 August 2015; pp. 1650–1655. [Google Scholar]
  15. Chen, Z.; Qiu, J.; Shi, C. FPGA-based PMSM servo system with improved low-speed performance. In Proceedings of the 2013 International Conference on Electrical Machines and Systems (ICEMS), Busan, Korea, 26–29 October 2013; pp. 1319–1324. [Google Scholar]
  16. Ma, Z.; Zhang, X. FPGA-based sensorless control for PMSM drives using the stator/rotor frame extended Kalman filter. In Proceedings of the 2018 Chinese Control And Decision Conference (CCDC), Shenyang, China, 9–11 June 2018; pp. 102–107. [Google Scholar]
  17. Yang, H.; Yang, R.; Hu, W.; Huang, Z. FPGA-Based Sensorless Speed Control of PMSM Using Enhanced Performance Controller Based on the Reduced-Order EKF. IEEE J. Emerg. Sel. Top. Power Electron. 2021, 9, 289–301. [Google Scholar] [CrossRef]
  18. Mužíková, V.; Glasberger, T.; Šmídl, V.; Peroutka, Z. Comparison of full-model and reduced-model EKF based position and speed estimators for sensorless DTC of permanent magnet synchronous machines. In Proceedings of the 2014 International Conference on Applied Electronics, Pilsen, Czech Republic, 9–10 September 2014; pp. 221–224. [Google Scholar]
  19. Aydogmus, O.; Sünter, S. Implementation of EKF based sensorless drive system using vector controlled PMSM fed by a matrix converter. Electr. Power Energy Syst. 2012, 43, 736–743. [Google Scholar] [CrossRef]
  20. Quang, N.K.; Ha, Q.P.; Hieu, N.T. FPGA sensorless PMSM drive with adaptive fading extended Kalman filtering. In Proceedings of the 2014 13th International Conference on Control Automation Robotics & Vision (ICARCV), Singapore, 10–12 December 2014; pp. 295–300. [Google Scholar]
  21. Vaculik, L.; Penhaker, M. High Efficiency Code Optimization in ARM Cortex-M Series Processor; The International Federation of Automatic Control: Velke Karlovice, Czech Republic, 2013. [Google Scholar]
  22. Tian, G.; Yan, Y.; Jun, W.; Ru, Z.Y.; Peng, Z.X. Rotor Position Estimation of Sensorless PMSM Based on Extented Kalman Filter. In Proceedings of the 2018 IEEE International Conference on Mechatronics, Robotics and Automation (ICMRA), Hefei, China, 18–21 May 2018; pp. 12–16. [Google Scholar]
  23. Qiu, A.; Wu, B.; Kojori, H. Sensorless control of permanent magnet synchronous motor using extended Kalman filter. In Proceedings of the Canadian Conference on Electrical and Computer Engineering 2004 (IEEE Cat. No.04CH37513), Niagara Falls, ON, Canada, 2–5 May 2004; Volume 3, pp. 1557–1562. [Google Scholar]
  24. Yan, X.B.Z.W.J.H.F.; Liu, L. A Two-Step Parameter Optimization Method for Low-Order Model-Based State-of-Charge Estimation. IEEE Trans. Transp. Electrif. 2021, 7, 399–409. [Google Scholar]
  25. Bolognani, S.; Tubiana, L.; Zigliotto, M. Extended Kalman filter tuning in sensorless PMSM drives. IEEE Trans. Ind. Appl. 2003, 39, 1741–1747. [Google Scholar] [CrossRef]
Figure 1. Block diagram of Kalman filter.
Figure 1. Block diagram of Kalman filter.
Energies 14 03491 g001
Figure 2. Flow diagram ot the EKF algorithm with parallel calculation.
Figure 2. Flow diagram ot the EKF algorithm with parallel calculation.
Energies 14 03491 g002
Figure 3. Time diagram showing the parallel run of the two EKF algorithm procedures. T s —control period time, T b —background procedure period.
Figure 3. Time diagram showing the parallel run of the two EKF algorithm procedures. T s —control period time, T b —background procedure period.
Energies 14 03491 g003
Figure 4. Simulated rotor position estimation performance at f b = 5 kHz f s = 5 kHz and w e = 400 rad s . (a) real and estimated rotor positions, (b) estimated position error, (c) estimated position variance, (d) position estimation Kalman gains.
Figure 4. Simulated rotor position estimation performance at f b = 5 kHz f s = 5 kHz and w e = 400 rad s . (a) real and estimated rotor positions, (b) estimated position error, (c) estimated position variance, (d) position estimation Kalman gains.
Energies 14 03491 g004
Figure 5. Simulated rotor position performance at f b = 1 kHz f s = 5 kHz and w e = 400 rad s . (a) real and estimated rotor positions, (b) estimated position error, (c) estimated position variance, (d) position estimation Kalman gains.
Figure 5. Simulated rotor position performance at f b = 1 kHz f s = 5 kHz and w e = 400 rad s . (a) real and estimated rotor positions, (b) estimated position error, (c) estimated position variance, (d) position estimation Kalman gains.
Energies 14 03491 g005
Figure 6. The relation between the minimum required Kalman matrices calculation frequency f b m i n and the rotor electrical frequency f e . (a) the relation between minimum required f b m i n and f e , (b) the relation between the ratio of f b m i n to f e and the rotor electrical frequency f e .
Figure 6. The relation between the minimum required Kalman matrices calculation frequency f b m i n and the rotor electrical frequency f e . (a) the relation between minimum required f b m i n and f e , (b) the relation between the ratio of f b m i n to f e and the rotor electrical frequency f e .
Energies 14 03491 g006
Figure 7. Experimental system configuration.
Figure 7. Experimental system configuration.
Energies 14 03491 g007
Figure 8. Experimental results of the rotor position estimation performance at f b = 5 kHz f s = 5 kHz and w e = 400 rad s . (a) measured and estimated rotor positions, (b) estimated position error, (c) estimated position variance, (d) position estimation Kalman gains.
Figure 8. Experimental results of the rotor position estimation performance at f b = 5 kHz f s = 5 kHz and w e = 400 rad s . (a) measured and estimated rotor positions, (b) estimated position error, (c) estimated position variance, (d) position estimation Kalman gains.
Energies 14 03491 g008
Figure 9. Experimental results ot the rotor position estimation performance at f b = 1 kHz, f s = 5 kHz and w e = 400 rad s . (a) measured and estimated rotor positions, (b) estimated position error, (c) estimated position variance, (d) position estimation Kalman gains.
Figure 9. Experimental results ot the rotor position estimation performance at f b = 1 kHz, f s = 5 kHz and w e = 400 rad s . (a) measured and estimated rotor positions, (b) estimated position error, (c) estimated position variance, (d) position estimation Kalman gains.
Energies 14 03491 g009
Figure 10. Estimated position errors at various Kalman matrices calculation update frequencies f b . The switching frequency 5 kHz and the rotor electrical angular speed 400 rad/s. (a) f b = 5 kHz, (b) f b = 2.5 kHz, (c) f b = 1.25 kHz, (d) f b = 500 Hz, (e) f b = 454 Hz, (f) f b = 416 Hz.
Figure 10. Estimated position errors at various Kalman matrices calculation update frequencies f b . The switching frequency 5 kHz and the rotor electrical angular speed 400 rad/s. (a) f b = 5 kHz, (b) f b = 2.5 kHz, (c) f b = 1.25 kHz, (d) f b = 500 Hz, (e) f b = 454 Hz, (f) f b = 416 Hz.
Energies 14 03491 g010
Figure 11. Synchronization lost at: f b = 384 Hz, f s = 5 kHz and reference speed w e r e f = 400 rad/s. (a) measured ( θ e ) and estimated ( θ e ^ ) rotor positions, (b) estimated position error ( Δ θ e ).
Figure 11. Synchronization lost at: f b = 384 Hz, f s = 5 kHz and reference speed w e r e f = 400 rad/s. (a) measured ( θ e ) and estimated ( θ e ^ ) rotor positions, (b) estimated position error ( Δ θ e ).
Energies 14 03491 g011
Figure 12. Experimentally measured relation between the minimum required Kalman matrices calculation frequency f b m i n and the rotor electrical frequency f e . (a) the relation between minimum required f b m i n and f e , (b) the relation between the ratio of f b m i n to f e and the rotor electrical frequency f e .
Figure 12. Experimentally measured relation between the minimum required Kalman matrices calculation frequency f b m i n and the rotor electrical frequency f e . (a) the relation between minimum required f b m i n and f e , (b) the relation between the ratio of f b m i n to f e and the rotor electrical frequency f e .
Energies 14 03491 g012
Table 1. Simulation parameters.
Table 1. Simulation parameters.
Stator resistance R s 1.2 Ω
Synchronous inductance L d 0.5 mH
Synchronous inductance L q 0.5 mH
Flux linkage λ m 0.007 Wb
Number of polesP8
DC supply voltage V d c 24 V
Switching frequency F s 5 kHz
Table 2. Comparison of the EKF steps execution time.
Table 2. Comparison of the EKF steps execution time.
VariableDefining
Equation
No
Optimization [ μ s]
Compiler [ μ s]Compiler +
User [ μ s]
P k P k 1 F k 1 P k 1 T + Q 97.256.813.4
K k P k H T ( H P k H T + R ) 1 56.034.05.4
P k ( I K k H ) P k 78.048.89.6
F , B f ( x ) x 4.43.23.2
x ^ k x ^ k 1 + T f ( x ^ k 1 ) + B u k 1 7.24.44.4
x ^ k x ^ k + K k ( y k H x ^ k ) 17.612.61.7
T o t a l 260.4159.837.7
Table 3. PMSM parameters.
Table 3. PMSM parameters.
ParameterSymbolValue
Stator resistance R s 1.2 Ω
Synchronous inductance L d 0.5 mH
Synchronous inductance L q 0.5 mH
Flux linkage λ m 0.007 Wb
Number of polesP8
Nominal voltage V n 24 V
Nominal torque T n 0.063 Nm
Rated speed ω n 4000 RPM
Rated power P n 30 W
Table 4. Processor usages for executing EKF estimator with different background frequencies, f s = 5 kHz.
Table 4. Processor usages for executing EKF estimator with different background frequencies, f s = 5 kHz.
f b CPU Usage f emax
5 kHz18.85%714 Hz
2.5 kHz10.95%357 Hz
1.25 kHz7.0%179 Hz
500 Hz6.21%71 Hz
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Dilys, J.; Stankevič, V.; Łuksza, K. Implementation of Extended Kalman Filter with Optimized Execution Time for Sensorless Control of a PMSM Using ARM Cortex-M3 Microcontroller. Energies 2021, 14, 3491. https://doi.org/10.3390/en14123491

AMA Style

Dilys J, Stankevič V, Łuksza K. Implementation of Extended Kalman Filter with Optimized Execution Time for Sensorless Control of a PMSM Using ARM Cortex-M3 Microcontroller. Energies. 2021; 14(12):3491. https://doi.org/10.3390/en14123491

Chicago/Turabian Style

Dilys, Justas, Voitech Stankevič, and Krzysztof Łuksza. 2021. "Implementation of Extended Kalman Filter with Optimized Execution Time for Sensorless Control of a PMSM Using ARM Cortex-M3 Microcontroller" Energies 14, no. 12: 3491. https://doi.org/10.3390/en14123491

APA Style

Dilys, J., Stankevič, V., & Łuksza, K. (2021). Implementation of Extended Kalman Filter with Optimized Execution Time for Sensorless Control of a PMSM Using ARM Cortex-M3 Microcontroller. Energies, 14(12), 3491. https://doi.org/10.3390/en14123491

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop