Linearization of Permanent Magnet Synchronous Motor Using MATLAB and Simulink

Permanent magnet machines, particularly at low power range, are widely used in the industry because of their high efficiency. They have gained popularity in variable frequency drive applications. The merits of the machine are elimination of field copper loss, higher power density, lower rotor inertia and a robust construction of the rotor (Bose 2002). In order to find effective ways of designing a controller for PM synchronous motor (PMSM), the dynamic model of the machine is normally used. The dynamic model of PM motor can be derived from the voltage equations referred to direct (d) and quadrature (q) axes (Bose 2002).The model derived essentially has quadratic nonlinearity. Linear control techniques generally fail to produce the desired performance. Feedback linearization is a technique that has been used to control nonlinear systems effectively. By applying exact linearization technique (Cardoso & Schnitman 2011) it is possible to linearize a system and apply linear control methods. But this requires that certain system distributions have involutive property. An approximate feedback linearization technique was formulated by Krener (Krener 1984) based on Taylor series expansion of distributions for non-involutive systems. Chiasson and Bodson (Chiasson & Bodson 1998) have designed a controller for electric motors using differential geometric method of nonlinear control based on exact feedback linearization. But from a practical point of view, this technique suffers from singularity issues. If the system goes into a state, during the course of the system operation, where the singularity condition is satisfied, then the designed controller will fail. Starting with the quadratic model of PMSM, we apply quadratic linearization technique based on coordinate and state feedback. The linearization technique used is the control input analog of Poincare’s work ( Arnold 1983) as proposed by Kang and Krener (Kang & Krener 1992) and further developed by Devanathan (Devanathan 2001,2004) .The quadratic linearization technique proposed is on the lines of approximate linearization of Krener (Krener 1984) and does not introduce any singularities in the system compared to the exact linearization methods reported in (Chiasson & Bodson 1998). MATLAB simulation is used to verify the effectiveness of the linearization technique proposed. In this chapter, MATLAB/SIMULINK modeling is used to verify the effectiveness of the quadratic linearization technique proposed. In particular, the application of MATLAB and SIMULINK as tools for simulating the following is described:


Introduction
Permanent magnet machines, particularly at low power range, are widely used in the industry because of their high efficiency. They have gained popularity in variable frequency drive applications. The merits of the machine are elimination of field copper loss, higher power density, lower rotor inertia and a robust construction of the rotor (Bose 2002). In order to find effective ways of designing a controller for PM synchronous motor (PMSM), the dynamic model of the machine is normally used. The dynamic model of PM motor can be derived from the voltage equations referred to direct (d) and quadrature (q) axes (Bose 2002).The model derived essentially has quadratic nonlinearity. Linear control techniques generally fail to produce the desired performance. Feedback linearization is a technique that has been used to control nonlinear systems effectively. By applying exact linearization technique (Cardoso & Schnitman 2011) it is possible to linearize a system and apply linear control methods. But this requires that certain system distributions have involutive property. An approximate feedback linearization technique was formulated by Krener (Krener 1984) based on Taylor series expansion of distributions for non-involutive systems. Chiasson and Bodson (Chiasson & Bodson 1998) have designed a controller for electric motors using differential geometric method of nonlinear control based on exact feedback linearization. But from a practical point of view, this technique suffers from singularity issues. If the system goes into a state, during the course of the system operation, where the singularity condition is satisfied, then the designed controller will fail. Starting with the quadratic model of PMSM, we apply quadratic linearization technique based on coordinate and state feedback. The linearization technique used is the control input analog of Poincare's work ( Arnold 1983) as proposed by Kang and Krener (Kang & Krener 1992) and further developed by Devanathan (Devanathan 2001(Devanathan ,2004 .The quadratic linearization technique proposed is on the lines of approximate linearization of Krener (Krener 1984) and does not introduce any singularities in the system compared to the exact linearization methods reported in (Chiasson & Bodson 1998). MATLAB simulation is used to verify the effectiveness of the linearization technique proposed. In this chapter, MATLAB/SIMULINK modeling is used to verify the effectiveness of the quadratic linearization technique proposed. In particular, the application of MATLAB and SIMULINK as tools for simulating the following is described: www.intechopen.com i. Dynamic model of a sinusoidal Permanent Magnet Synchronous machine(PMSM) ii. Application of nonlinear coordinate and state feedback transformations to linearize the PMSM model and iii. Tuning the transformations against a linear system model put in Brunovsky form employing error back propogation. As these applications were somewhat sophisticated , customization and improvisation of the MATLAB/SIMULINK tools were essential. These applications are described in detail in this chapter. In section 2, linearization of dynamic model of PMSM is discussed and simulation results using MATLAB are given. In section 3, linearization of PMSM machine model is given. Construction of PMSM model using SIMULINK and verification of linearization of PMSM SIMULINK model is given in Section 4. Tuning of the linearizing transformations to account for unmodelled dynamics is discussed in Section 5. In section 6, the chapter is concluded.

Dynamic model of PMSM
The dynamic model of a sinusoidal PM machine, considering the flux-linkage f λ to be constant and ignoring the core-loss, can be written as (Bose 2002).
where all quantities in the rotor reference frame are referred to the stator. , ω r is the angular velocity of the rotor; λ f is the amplitude of the flux induced by the permanent magnets of the rotor in the stator phases and p is the number of pole pairs. Using linear coordinate and state feedback transformations (Kuo 2001) the dynamic model can be written with the linear part put in Brunovsky form (Parvathy et. al. 2005(Parvathy et. al. ,2006 as where 123 ,, bbbare constants derived from the motor parameters. www.intechopen.com

Verification of linearization using MATLAB function
The problem now is to apply MATLAB to verify the theoretical result on quadratic linearization of the dynamic model (4). Expanding (4), we can see that the expression of the derivative of each state variable has the other two state variables in it. This becomes difficult to solve using manual methods of differential equation solution. The tool selected for solving the dynamic equations is the MATLAB function called ODE45. ODE45 is a MATLAB function that solves initial value problems for ordinary differential equations (ODEs). It uses the iterative Runge Kutta method of solving equations. Hence, this function does not return the solution as an expression, but the values of the solution function at discrete instants of time. ODE45 is based on an explicit Runge-Kutta formula, the Dormand-Prince pair. It is a one-step ode45 -in the sense that, in computing () , n yt it needs only the solution at the immediately preceding time point 1 () n yt − .In general, ode45 is the best function to apply as a "first try" for most problems.
[t,Y] = ode45(odefun,tspan,y0) with tspan = [t0 tf] integrates the system of differential equations from time t0 to tf with initial conditions y0. Function f = odefun(t,y) is defined, where t corresponds to the column vector of time points and y is the solution array. Each row in y corresponds to the solution at a time returned in the corresponding row of t. To obtain solutions at the specific times t0, t1,...,tf (all increasing or all decreasing), we use tspan = [t0,t1,...,tf].
[t, Y] = ode45(odefun,tspan,y0,options) solves as above with default integration parameters replaced by property values specified in 'options'. Commonly used properties include a scalar relative error tolerance RelTol (1e-3 by default) and a vector of absolute error tolerances AbsTol (all components are 1e-6 by default). The PLOT function is used to create a computer-graphic plot of any two quantities or a group of quantities with respect to time. A simulation of (4) was carried out for different values of inputs u 1 and u 2 in the open loop before applying the linearizing transformations where 1 b = -0.0165*(10^-3) ; 2 b -186.96; u 1 = 0.1{u(t)-u(t-1)} and u 2 =0.1{u(t)-u(t-1)} where u(t) is a unit step function . The system is oscillatory as seen from Fig 1. Fig. 2 shows the result of simulation of equation (4) after the linearizing transformations (5) and (6) are applied to the system. It shows a plot of y 1 ,y 2 ,y 3 against time for pulse inputs v 1 =0.2{u(t)-u(t-1)}, v 2 =0.2{u(t)-u(t-1)}. From Fig 2 it is seen that the system shows a stable response for a pulse input in v 1 and v 2 even under open loop conditions. .  shows the steady state gain of y 3 with respect to v 1 while v 2 is maintained constant. It is observed that the plot between y 3 and v 1 is almost linear, thus verifying that the linearizing system is almost linear. A similar test before linearization revealed that the steady gain of 3 x with respect to input u 1 varied over a large range thus revealing the nonlinearity. Thus the linearization of the dynamic model of PMSM was verified through the use of MATLAB function ODE45 .

PMSM model in normal form
The 4 vvii represent the quadrature and direct axis voltages and currents respectively and , e θω represent rotor position and angular velocity respectively.
λ is the flux induced by the permanent magnet of the rotor in the stator phases. , d q LL are the direct and quadrature inductances respectively. R is the stator resistance. p is the number of pole pairs and J is the system moment of inertia.
The model (7) can be reduced to normal form for two inputs (Brunovsky 1970), in a standard way using the following transformations (Kuo 2001)

Linearization of PMSM normal form model
Given the 4 dimensional model of a PM synchronous motor (IPM model) of the form (9), the system can be linearized using the following transformations (1) (2) 2 (( ) )( ) uI x where 2 I is the identity matrix of order 2. The system then reduces to O y v represents third and higher order nonlinearities .

Construction of PMSM model
Customization of PMSM machine model using MATLAB/SIMULINK tools had to be carried out as the standard library available contained only special cases. The PM motor drive simulation was built in several steps through the construction of q-axis circuit, d-a xis circuit, torque block and speed block.

q-axis circuit
By using the following system equation the q-axis circuit is constructed.
() qq qrd d fq q vR i L i L i =+ ω + λ + ρ q-axis circuit in the SIMULINK is shown in Fig.4 .

d-axis circuit
By using the following system equation the d-axis circuit is constructed.
Simulation of the d-axis circuit is shown in Fig. 5.

Torque block
By using the following torque equation the torque block is constructed.

Speed block
By using the following equations the speed block is constructed.
The simulation of m ω circuit is shown in the Fig.7.

Designed PMSM with V q and V d as inputs
The PMSM is constructed by using q-axis, d-axis, torque and speed blocks (figures 4,5, 6, and 7 ) and is shown in figure 8.

Linearization of PMSM SIMULINK model
The PMSM model is first converted to controller normal form of the linear part (9) using transformations as given in (8). Then linearization of the PMSM is carried out using quadratic coordinate and state feedback as given in (10) and (11). Fig.9 gives the PMSM model including linearization blocks. 1 N and 2 N include the linear transformations (8) while 1 L and 2 L , denote the nonlinear transformations (11) and (10) respectively. 1 N , 2 N , 1 L and 2 L are implemented using function blocks. Fig. 9. Linearization of PMSM model is not constant because of the system nonlinearity. To verify the linearity of the system after linearization, we investigated the variation of its gain of 2 y ( a scaled version of e ω as can be seen from (8) and (10)) with input 1 v (see Fig. 9) and the results are given in Table 2. The table reveals that the gain of the system is nearly constant thus verifying that by applying the homogeneous linearizing transformation, the PMSM model is made nearly linear for the given set of inputs. Figures 10 and 11 show the time response of angular velocity e ω by closing the loop around PMSM model (Fig. 8) before linearization when q v = 5 units and 30 units respectively. It is observed that the dynamic response for q v = 5 is more oscillatory compared to the case of q v = 30 with a fixed controller of proportional gain = 50 and integral constant =2. This is to be expected since the loop gain is higher in the former case with a higher static gain in the plant or motor as can be seen from Table I.  Figures 12 and 13 show the time response of 2 y of the transformed PMSM system (Fig. 9) in closed loop when 1 v = 5 units and 30 units respectively . It is observed that a uniform output response is obtained in the closed loop after linearization when the reference is varied. Since the static gain in Table II is nearly uniform, the loop gain is also nearly constant for the extreme points in the operating range, thus resulting in the uniform dynamic responses in Fig. 12 and 13. Simulation results show that the nearly constant gain of the linearized model, results in a uniform response on a range of set point and load inputs with a fixed controller. This is in contrast to the case before linearization under the corresponding conditions.

Tuning linearizing transformations
Unmodelled dynamics coupled with the third and higher order nonlinearities introduced due to quadratic linearization, are best accounted for by tuning the transformations (Levin & Narendra 1993).
To further improve the linearity of the system taking into account unmodelled dynamics and higher order nonlinearities, tuning of the transformation parameters against an actual PM machine is done on the lines similar to those proposed by Narendra (Levin & Narendra 1993). Fig 14 shows can be independently tuned by tuning 1 k and 1 k ′ respectively and (2) () x α is not varied.

Updation of N 2 transformation coefficients
Tuning of 2 N transformation implies the tuning of (2) () x φ . As (2) () x φ is a function of only 134 kxx , the coefficient 1 k has to be updated based on the error between the outputs of quadratic linearized system and normal form. The updation law is derived as follows.
where m corresponds to the updating step and ρ correspond to the accelerating factor.

Updation of N 1 transformation coefficients
Tuning of 1 N transformation is achieved by tuning of (1) () x β . As (1) () x β is a function of 13 kx ′ and 14 kx ′ , the coefficient 1 k ′ has to be updated based on the error between the outputs of quadratic linearized system and normal form . The updation law is derived as follows.
where ; Assuming that the steady state of the Simulink model is reached within the tuning period.
Tuning of the quadratic linearizing transformations is done by updating the transformation coefficients of vector polynomials (2) () x φ and (1) () x β .

Construction of controller tuning blocks
Updation of (2) () x φ is done by using (14) and 1 k Δ can be obtained from (13). The tuning is done using Memory blocks and they are constructed in simulink as shown. Fig. 15      Complete simulation diagram including conversion to Brunovsky form, linearization and tuning is given in Fig.18. It is seen that the error after tuning is reduced to 0.01. In Table 3, improvements are obtained for the steady state gain of 2 y versus 1 v for the linearized system after incorporating tuning of the transformation parameters. Table 3 reveals that the gain of the system is even more constant compared to that shown in Table 2, thus verifying that by tuning the homogeneous linearizing transformation, the linearity of the system has been improved for the given set of inputs.

Conclusion
Application of MATLAB and SIMULINK tools for the verification of linearization of permanent magnet synchronous motor is considered in this chapter. Simulation is done using the dynamic model of PMSM, application of nonlinear coordinate and state feedback transformations to the SIMULINK model which is customized to PMSM and tuning the transformations against a linear system model employing error back propogation to account for unmodelled dynamics. Initially, linearization of PMSM is verified using the dynamic model of PMSM. The dynamic model of a PM synchronous motor involving quadratic nonlinearity is linearized and simulated using MATLAB. Steps are given to perform dynamic simulation for the nonlinear system using the dynamic equations based on parameters of the machine, together with the state and input transformations using MATLAB function ODE45. The SIMULINK model of Interior Permanent Magnet machine is specially developed by integrating various blocks as standard library functions do not cater to generic purposes . The PMSM machine model, together with the state and input transformations, are simulated using SIMULINK. The simulation results show that the linearizing transformations effectively linearize the system thus supporting the theory. To account for the unmodelled dynamics and third and higher order nonlinearities, tuning of the transformation parameters is done by comparing the output of the linearized system with a normal form output. Tuning the transformation functions (2) () x φ and (1) () x β is shown further to improve the linearity of the resulting system. More details of the simulation results are given in (Parvathy et. al. 2011).