International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 Sensorless State Estimation in Two-Phase Stepper Motor using EKF and UKF Dr. (Mrs.) J.M.Nair1, Vandana N. Sharma2 1 Insrumentation and control Dept., VES Institute of Technology, Mumbai, India Jin_nair@yahoo.co.in 2 Insrumentation and control Dept., VES Institute of Technology, Mumbai, India vandananihal@gmail.com 3 Third Author Affiliation with address john.doe@email.com ABSTRACT This paper presents the estimation of the states (winding currents, rotor speed and rotor angular position) of two-phase permanent stepper motor. A dynamic model was derived and used for sensorless speed and position measurement. The system is highly nonlinear and one therefore cannot directly use any linear system tools for estimation. To estimate the state variables of motor model, the paper proposes two different methods to estimate them are the Extended Kalman Filter (EKF) and Unscented Kalman Filter (UKF). The simulation results show the effects of noise of the algorithm to motor parameters and found better results for UKF method. Keywords: Stepper motor, Sensorless, Modelling, Extended Kalman Filter, Unscented Kalman Filter, Matlab. 1. INTRODUCTION Stepper motors are in wide range of applications, including high and low propulsion technology, computer peripherals, machine tools, robotics etc. The interest in this system has been steadily increasing requirements for accuracy and repeatability while at the same time placing ever tighter demands on the maximum and constancy of speed as well as position resolution. However it has a non-linear and coupled dynamic structure so we could use different control schemes to make the stepper more competitive to use in different levels of application. Open loop control will provide a satisfactory solution under limited conditions. But for high performance dynamic operation this will not give satisfactory results. So we need to find more sophisticated control methods to make the performance of stepper motors much more competitive. This work is mainly focused on state estimation of Stepper motor for finding optimized control techniques using simulation. Traditionally, DC motors have been chosen for industrial applications over stepper motors due to their linear input/output relationship, which in turn, allows for the use of standard control strategies. Over the past few years, the use of stepper motors has increased. The reasons for this include: better reliability due to the elimination of mechanical brushes, better heat dissipation as the windings are located on the stator and not on the rotor, higher torque-to-inertia ratio due to a lighter rotor, and lower prices [1]. Sensorless Control-In recent years there have been successful applications of different types of control theory in the areas of robotics, aircraft control, and motor torque and speed control and estimation using powerful microcontrollers. Complex applications can be implemented by the use of different control methods in standard practice. In conventional methodologies, one has to use different kinds of sensors or transducers to make controllers more robust. But sensors cost a lot, may not give enough resolution, and may have a high failure rate. Using some kind of observer or filter one can get the information of non-measured states. So to achieve better solutions in low cost applications one can use the proper model of the system, information of easily measured parameters and some kind of observer or filter to get the information of non-measured parameters. The Kalman filter technique is one of the good methods employed to identify the speed and rotor-flux based on Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 measured quantities such as current or voltage. This approach is based on the system model and mathematical model describing stepper motor dynamics. Parameter deviation and measurement disturbance are taken into consideration by initializing covariance matrices to proper values. It has good dynamic behavior and disturbance resistance against measurement and process errors. It can also work well in the standstill position. The filter is optimal when the process noise and the measurement noise can be modelized by white Gaussian noise. Non-linear problems can be solved with the Extended Kalman filter (EKF) and Unscented Kalman Filter (UKF). EKF is based upon the principle of linearizing the state transition matrix and the observation matrix with Taylor series expansions, while the UKF is based on unscented transform (UT). The UT is founded on intuition that “it is easier to approximate a probability distribution than it is to approximate an arbitrary non linear function or transformation” [2]. Instead of using linearized equations to approximate the non linear model as EKF method UKF intentionally generates a finite set of points known as sigma points. These sigma points are transformed to a new set of points using nonlinear model. System states and associated error covariance matrices are determined numerically based on the mean and covariance values of the transformed sigma points. 2. MATHEMATICAL MODELING OF STEPPER MOTOR We consider a two-phase permanent magnet (PM) stepper motor. A simplified schematic of a motor with one pole-pair is shown in Fig. 1. Commanded voltages ( va and vb ) control the two-phase currents (ia and i b). The magnetic field, due to the stator current, interacts with the permanent magnet on the rotor to create a torque, so that the rotor will tend to align itself with the magnetic field produced by the currents. Applying a sequence of voltage to each phase in succession will cause the rotor to step. The size of each step is 90° in the case of Fig. 1[3]. In general, it is determined by n, the number of rotor teeth. A sinusoidal characteristic of the magnetic field in the air gap is assumed. Figure 1. The working flow of DPAGA The dynamic equations, derived [4] in are cast in state-space form as follows: (1) And the output vector Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 (2) Where; is the output vector R is the resistance of the coils L is the inductance of the coils λ is the motor torque constant depending on the design of the rotor J is the inertia of the rotor and the load θ(t ) is the actual rotor position θ is the location of the coil a in the stator ω is the rotational velocity of the rotor ia is the current in the coil as function of time The model described above conforms to the general state space model given by; (3) (4) x, u and y are called the state, input and output vectors, respectively. where; A is called the state matrix, is called input matrix is called output matrix called the direct transmission matrix. 3. KALMAN FILTER THEORY AND ALGORITHM 3.1 Kalman Filter Kalman filter is an estimator for what is called the linear quadratic problem, which is the problem of estimating the instantaneous “state” of a linear dynamic system perturbed by white noise by using measurement linearly related to the state but corrupted by white noise [5]. The resulting estimator is statistically optimal with respect to any quadratic function of estimation error. In the mathematical point view, the KF is a set of equations that provides an efficient recursive computational Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 solution of the least square method. The filter is very powerful in several aspects. It provides estimation of the past, the present and the future states. This is achieved even when precise characteristics of the modeled system are unknown. It is part of the foundation of another discipline – modern control theory. The KF is an extremely effective and versatile procedure for combining noisy sensor outputs to estimate the state of the system with uncertain dynamics. When applied to a physical system, the observer or filter will be under the influence of two noise sources: 1. Process noise - e.g., thermic noise in a resistor, which is a part of the system. 2. Measurement noise - e.g., quantization noise. 3.2 Extended Kalman Filter The An extended Kalman filter is a recursive optimum state-observer that can be used for the state and parameter estimation of a non-linear dynamic system in real time by using noisy monitored signals. This assumes that the measurement noise and system noise are uncorrelated. The noise sources take account of measurement and modeling inaccuracies. In the first stage of the calculations, the states are predicted by using a mathematical model (which contains previous estimates) and in the second stage the predicted states are continuously corrected by using a feedback correction scheme. This scheme makes use of actual measurements by adding a term to the predicted states (which is obtained in the first stage). The additional term contains the weighted difference of measured and estimated output signals. Based on the deviation from the estimated value, the EKF provides an optimum output value at the next input instant. The extended Kalman filter extends the scope of Kalman filter to nonlinear optimal filtering problems by forming a Gaussian approximation to the joint distribution of state x and measurements y using a Taylor series based transformation. In EKF the Jacobians of f and h are calculated around the estimated state. n A nonlinear system with state vector x(k) є R is given by the nonlinear stochastic difference equation [6] x(k 1) f (x(k),u(k),(k)) With a measurement z (k) є R (5) m z(k) h(x(k),(k)) (6) Where, the random variable ξ(k) and η(k) are the plant and measurement noise, respectively and are assumed to be white and independent of each other with the normal probability distributions. In the dynamic equation, the non-linear function f(.) relates the state at time step k to the state at time step k+1 and includes the driving function u(k) and the zero mean plant noise ξ(k). To estimate a process with non-linear difference and measurement relationship, we begin by writing new governing equations that linearize an estimate about (5) and (6) x(k 1) xˆ(k 1) A(x(k) xˆ(k)) Ww(k) (7) z(k) zˆ(k) H (x(k) xˆ(k)) Vv(k) (8) Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 where, x(k 1) and z(k) are the actual state and measurement state, x̂ (k+1)and zˆ (k ) are the approximate and measurement vectors, xˆ (k ) is an a posteriori estimate of the state at step k. the random variables w(k) and v(k) represents the process and measurement noise. A is the Jacobian matrix of partial derivatives of f(.) with respect to x, f (i ) A[i , j ] ( xˆ (k ), u(k ),0) x( j ) (9) W is Jacobian matrix of partial derivatives of f(.) with respect to w, f (i ) W[i , j ] w( j ) ( xˆ (k ),0) (10) H is the Jacobian matrix of partial derivatives of h(.) with respect to x, H [i , j ] h(i ) x( j ) ( xˆ (k ), u (k ),0) (11) V is Jacobian matrix of partial derivatives of h(.) with respect to w, V[i , j ] f (i ) v( j ) ( xˆ (k ),0) (12) Note that for simplicity in the notation we do not use the time step subscript k with Jacobians F,W,H,V even thought they are in fact different at each time step. The complete set of EKF equations are shown below: The times update equations: xˆ (k 1) f ( xˆ (k ), u (k ), 0) P (k 1) A(k ) P(k ) AT (k ) W (k )Q(k )W T (k ) (13) (14) The measurement update equation: xˆ (k ) xˆ (k ) K (k )( z (k ) h( xˆ (k ), 0)) K (k ) P (k ) H T (k )( H (k ) P (k ) H T (k ) V (k ) R(k )V T (k )) 1 P(k ) ( I K (k ) H (k )) P (k ) (15) (16) (17) where K is the Kalman gain matrix, used in the update observer, and containing information about the accuracy of estimate. 3.3 is the covariance matrix for the estate estimation, Unscented Kalman Filter The unscented Kalman filter (UKF), an extension of the Kalman filter that reduces the linearization errors of the EKF. The use of the UKF can provide significant improvement over the EKF. Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 The unscented transformation is the milestone of the UKF algorithm, which is abbreviated as follows [7, 8, 9]. I. We have an n-state discrete-time nonlinear system given as xk+1 = f ( xk ,uk ,tk ) + wk (18) yk = h( xk ,tk ) + uk (19) ωk (0,Qk) (20) vk (0,Rk) (21) Where Q and R are the covariance of the process noise ωk and the measurement noise vk, respectively. II. The UKF is initialized as follows. x̂ 0+ = E( x0) P 0+ = E [ ( x 0 - (22) x̂ 0+) (x0 - x̂ 0+)T ] (23) III. The following time update equations are used to propagate the state estimate and covariance from one measurement time to the next. (a) To propagate from time step (k - 1) to k, first choose sigma points xk-1( i ), with appropriate changes since the current best guess for the mean and covariance of xk are x̂ k-1+ and Pk-1+ : x (i) x̂ k-1(i) = x̂ k-1+ + ~ i=1,…,2n (24) ~ x (i) = ( nP )iT i=1,……,n (25) ~ x (n+i) = -( nP )iT i=1,……,n (26) (b) The known nonlinear system equation f ( xk ,uk ,tk ) is used to transform the sigma points into x̂ k(i) vectors with appropriate changes since our nonlinear transformation is f ( xk ,uk ,tk ) rather than h( xk ,tk ) : x̂ k(i) = f ( x̂ k-1(i) ,uk ,tk ) (c) Combine the x̂ k- = (27) x̂ k(i) vectors to obtain the priori state estimate at time k. 1 2n x̂ k(i) 2n i 1 (28) (d) The a priori error covariance is estimated. However, one should add Qk-1 to the end of the equation to take the process noise into account: P k- = 1 2n ( x̂ k(i) - x̂ k- )( x̂ k(i) - x̂ k- )T + Qk-1 2n i 1 (29) 4. Now that the time update equations are done to implement the measurement update equations: (a) Choose sigma points xk( i ), with the current best guess for the mean and covariance of xk are x̂ k- and Pk-, as above mentioned. This step can be omitted if desired. That is, instead of generating new sigma points one can reuse the sigma points that were obtained from the time update. This will save computational effort, but would sacrifice performance [26, 27]. Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 (b) The known nonlinear measurement equation h( xk ,tk ) is used to transform the sigma points in measurements): ŷ k(i) = h( x̂ k(i) ,tk) (c) Combine the ŷ k = ŷ k(i) vectors (predicted (30) ŷ k(i) vectors to obtain the predicted measurements at time k . 1 2n ŷ k(i) 2n i 1 (31) (d) The covariance of the predicted measurement is estimated. However, one should add Rk to the end of the equation to take the measurement noise into account: Py = 1 2n ( ŷ k(i) - ŷ k )( ŷ k(i) - ŷ k )T + Rk-1 2n i 1 (e) Estimation of the cross covariance between Pxy = x̂ k- 1 2n ( x̂ k(i) - x̂ k- ) ( ŷ k(i) - ŷ k )T 2n i 1 (32) and ŷ k. (33) (f) The measurement update of the state estimate can be performed using the normal Kalman filter equations [12]: Kk = Pxy Py-1 x̂ k+ = x̂ k- (34) + Kk (yk - ŷ k ) (35) Pk+ = Pk- - Kk Py KkT (36) 4. MOTOR STATE ESTIMATION USING EKF AND UKF In the present work, The EKF as well as UKF are applied to estimate the speed and position of a two-phase stepper motor. The Jacobians of the dynamic stepper model described are calculated prior to the application of the EKF. The sensorless speed and position estimator was implemented in matlab, using EKF and UKF algorithms. For our simulation we selected the following stepper motor parameters: Table1. The parameters of two-phase motor Winding Resistance Winding Inductance Motor flux constant Moment of Inertia Coefficient of viscous friction Standard deviation of Control input noise Standard deviation of Acceleration noise Standard deviation of Measurement noise Frequency Ra La λ J B 1.9Ω 3ml 0.1Nm/A 0.002kg.m2 0.001Nms/rad σa 0.001A σa 0.05rad/s2 Σm f 0.1A 1Hz The simulation provides the computed (true) and the estimated winding currents, ia and ib, together with speed , and position, . The state estimation covariance, P, is also computed. This is an indicator of the goodness of the estimate. Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 The combined simulation results of EKF and UKF are shown in figures.The estimated and actual states representing stator currents and rotor velocity and position are shown in Fig.(2, 3, 4, 5). The system was simulated at sampling time (T=2.0 ms). One can easily notice that the EKF and UKF estimators could successively estimate the motor states and the estimators showed an excellent noise rejection capability. However, one can observe that the estimator does hardly estimate the speed and the angular position at the motor starting, but there is a perfect overlap at steady state. Fig.6 shows that the estimation covariance is high using EKF. This is an evidence of poor estimation. While on using UKF its peak is small as compare to EKF Measurement noise, R, was found to be less significant in estimating the states. Therefore, it is advisable to take a great care in choosing the elements of the matrix Q. Winding A Current (Amps) 1.5 True Estimated ekf Estimated ukf 1 0.5 0 -0.5 -1 0 0.5 1 Time (Seconds) 1.5 2 Figure.2 Winding B Current (Amps) 1.5 True Estimated ekf Estimated ukf 1 0.5 0 -0.5 -1 0 0.5 1 Time (Seconds) 1.5 2 Figure.3 Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 8 True Estimated ekf Estimated ukf Rotor Speed (Radians / Sec) 6 4 2 0 -2 -4 -6 -8 0 0.5 1 Time (Seconds) 1.5 2 Figure.4 10 True Estimated ekf Estimated ukf 9 Rotor Position (Radians) 8 7 6 5 4 3 2 1 0 -1 0 0.5 1 Time (Seconds) 1.5 2 Figure.5 Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 Trace(P) 60 ekf ukf 50 40 30 20 10 0 0 0.5 1 Seconds 1.5 2 Figure.6 5. CONCLUSION The focus of this work is the sensorless speed and position measurement of a two-phase stepper motor. A dynamic mathematical model of the stepper motor is derived and formulated into state space model for easy analysis and manipulation. The EKF and UKF are, then, applied to the developed motor model. The model, which is inherently nonlinear, is linearized prior to the EKF application using Jacobian. Simulation results have shown good agreement between true and estimated states. To verify the state estimation performance of the UKF and the EKF, a number of simulations were carried out for different operating conditions and parameter settings. The simulations were implemented using Matlab. A crucial step in the design of the Kalman filters is the choice of the elements of the covariance matrices Q and R, as they will affect the performance, convergence and stability. The use of large values in Q presumes high model noise and/or parameter uncertainties. An increase in the values of the elements of Q will likewise increase the Kalman gain, resulting in faster filter dynamics but poorer steady-state performance. Matrix R is related to the measurement noise. Increasing the values of the elements of R will assume that the current measurements are more affected by noise and thus less reliable. Consequently, the filter gain will decrease, yielding poorer transient response References [1] Azzeddine Ferrah, Jehad Al-Khalaf Bani-Younes, Mounir Bouzguenda, and Abdelkader Tami, “Sensorless Speed and Position Estimation in a Stepper Motor”, IEEE 2007. [2] Julier, S. J. and Uhlmann, J. K., “Unscented Filtering and Nonlinear Estimation”, Proceedings of The IEEE, Vol. 92, No. 3, March 2004. [3] Julier, S. J. and Uhlmann, J. K., “Unscented Filtering and Nonlinear Estimation”, Proceedings of The IEEE, Vol. 92, No. 3, March 2004. [4] A. Ferrah, K. Al-Bahrani, B. Al-Kindi, F. Al-Jaradi, A. Al-Blushi, “Sensorless Speed and Position Estimation in a Two-Phase Stepper Motor,” BEng Thesis, Sohar University, June 2005 [5] R.E. Kalman “ A New Approach to Linear Filtering and Prediction Problem” Transaction of ASME, Journal of Basic Engineering, pp.35-45, March 1960. [6] Greg Welch and Gary Bishop, "An Introduction to the Kalman Filter," University of North Carolina, July 24, 2006. [7] Dan Simon, “Using Nonlinear Kalman Filtering to Estimate Signals,” 2003, (d.j.simon @ccsuohio.edu). [8] Dan Simon, “Kalman Filtering and Neural Networks” Johon Wiley and Sons, Inc.2001. [9] Dan Simon, “Optimal State Estimation:Kalman, H∞ , and Nonlinear Approaches,”John Wiley & Sons Inc., 2006. [10] Dr. Amjed J. Hamidi, Ahmed Alaa Ogla & Yaser Nabeel Ibrahem, “State Estimation of Two-Phase Permanent Magnet Synchronous Motor”, Eng. & Tech. Journal, Vol.27, No.7,2009. Organized By: Vivekanand Education Society's Institute Of Technology International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: editor@ijaiem.org ISSN 2319 - 4847 Special Issue for International Technological Conference-2014 [11] “Short Tutorial on Matlab,” Tomas Co.,2004. MATLAB Help, Stepper Motor Drive, MATLAB R2008a AUTHORS Dr. (Mrs.) J. M. Nair received B.Sc. degree in Electrical Engineering university of Kerala, INDIA in 1984 with First Class with Distinction, the M. Tech. degree in Controls Systems from University of Kerala, INDIA in 1986 with First Class with Distinction and the Ph.D. degree in Systems & Control Engineering with research topic Robust Control of Singularly Perturbed System from IIT Bombay, INDIA in 1995. She joined in V.E.S. Institute of Technology, University of Mumbai as Lecturer in 1986 and promoted as a Principal in 2004. Her current research interests include fractional control systems & error analysis. Vandana N. Sharma received the B. Tech. degree in Electronics and Instrumentation Engineering from M.P.E.C., Kanpur, INDIA, M.E. degree in Instrumentation & Control Engineering from VES Institute of Technology, Mumbai, INDIA in 2006 and 2013, respectively. From 2006 to 2010 she has worked as lecturer in R.K.G.I.T. Engineering College Ghaziabad. Her areas of interest are control system and basic Electronics. Organized By: Vivekanand Education Society's Institute Of Technology