You are on page 1of 36

Torque Ripple Minimization in Permanent Magnet Synchronous motor using Model Reference Adaptive Control

by

Rajmohan Asokan
Person Number: 50097503
May,2014

Department of Mechanical and Aerospace Engineering


State University of New York at Buffalo

Abstract
The objective of this Nonlinear Control course project is to design a
model reference adaptive control (MRAC) to minimize the torque ripple
of Permanent Magnet Synchronous Motor (PMSM). The PMSM is modelled as a current subsystem and a speed subsystem. Another inertial
system is coupled to the motor shaft via a spring which makes the mechanical subsystem a fifth-order system. The MRAC is modified to enable
perfect tracking of the fifth-order system. The simulations are analysed
to understand the performance of the designed MRAC.

Table 1: List of Symbols


id
direct-axis plant current
iq
quadrature-axis plant current
R = 33.6
Stator resistance
Ld = 0.0284H
direct-axis stator inductance
Lq = 0.0284H
quadrature-axis stator inductance
ud
direct-axis stator voltage
uq
quadrature-axis stator voltage
d and q
total flux linkages

rotational speed of rotor/shaft in rad/sec


p=2
Number of pole pairs
e = p
Electrical angular speed

rotor/shaft position in radians


e = p
Electrical angular position
idm
direct-axis model current
iqm
quadrature-axis model current
Mm
Motor output torque
Bf = 8.2 10 6Kgm2 /s
Motor friction coefficient
J/J1 = 1.6 10 5Kg/m2
Moment of Inertia of rotor/shaft
J2 = usedanarbitraryvalue
Moment of Inertia of rotary system attached to shaft
K
Spring stiffness
1
Angular position of the rotor/shaft
2
Angular position of the rotary system attached
In chapter 5
a5
1
a4
5
a3
6
a2
8
a1
3
a0
2
adm = aqm = bdm = bqm = 1000
Co-efficient of plant and reference models used

500

500
d , q ,
Adaptation Gain matrices

Contents
1 INTRODUCTION
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . .

4
4
4

2 MODEL REFERENCE ADAPTIVE CONTROL OF CURRENT


SUBSYSTEM
5
3 MRAC FOR SPEED SUBSYSTEM USING LYAPUNOV APPROACH
9
4 MRAC OF SPEED SUBSYSTEM USING AUGMENTED ERROR METHOD
14
5 MRAC TO CONTROL A ROTARY SYSTEM ATTACHED
TO MOTOR SHAFT
16
6 SIMULATION

19

7 APPENDIX
28
7.1 Model Reference Adaptive Control for Current and Speed Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7.2 MRAC of Speed subsystem using Augmented error . . . . . . . . 32
7.3 MRAC of rotary system attached to shaft . . . . . . . . . . . . . 33

1
1.1

INTRODUCTION
Motivation

The field of disturbance elimination has been one of the major areas of research in the control community for a variety of reasons. One of the major
applications of disturbance elimination is in the field of synchronous motor.
Synchronous Motor are used in manufacturing facilities, high precision robotic
actuators, disk drives, electric vehicles and lot of other areas where rotational
and translational motion are required. Speed Control of motors has always
served as a benchmark testing for various model control algorithms. In the last
couple of decades, the focus has shifted to estimating and eliminating periodic
disturbances in synchronous motors which arise due to construction flaws, variation in the electromagnetic parameters over time and possibly other problems
which might contribute to the ripples in motor shaft torque.

1.2

Problem Statement

A permanent magnet synchronous motor is modelled as a current and mechanical subsystem. The current model has coupling non-linear term. The mechanical
model is a second-order linear system with unknown plant parameters. A Model
reference adaptive control (MRAC) is designed exclusively for current and plant
model. A smooth motor torque is generated to have a ripple free velocity profile
of the shaft. Further, another rotary system is added to the systems making
the mechanical model to be fifth-order now. MRAC is now applied to control
the velocity profile of the rotary system attached.

MODEL REFERENCE ADAPTIVE CONTROL


OF CURRENT SUBSYSTEM

The PMSM is modelled as current and speed subsystems. The electro-magnetic


model is given by

R
1
1
i d = id +
ud +
d T d
Ld
Ld
Ld

(2.1)

R
1
1
i q = iq +
uq
q T q
Ld
Lq
Lq

(2.2)

where,
d = [Lq
d = [e iq
q = [Ld
q = [e id

q6

q12 ]T

e sin(6e )
d0
e

d6

e sin(12e )]
d12 ]T

e cos(6e )

e cos(12e )]

d0 = d0
d6 = 6q6 + d6
q6 = 6d6 + q6
d12 = 12q12 + d12
q12 = 12d12 + q12
The modelling of a permanent magnet synchronous motor can be referred in
[1]. The reason for separate current and speed systems is due to the fact that
current dynamics is faster than the speed dynamics. Due to the non-sinusoidal
magnetic field between stator and rotor, the flux linkages are shown to be

drot = d0 + d6 cos(6e ) + d12 cos(12e )

(2.3)

qrot = q6 sin(6e ) + q12 sin(12e )

(2.4)

From literature [1],[2] it is found that for control and estimation tasks, it
is good enough to consider harmonics only up to 12th. This is because as the
order of harmonics increases it decays faster and does not capture the entire
effect on the model.
The reference model for the current system is modelled as
i dm = adm idm + bdm rd
i qm = aqm iqm + bqm rq

(2.5)
(2.6)

where the constants adm , bdm , aqm and bqm are selected as per design requirements and rd , rq are the reference signals to the id and iq currents respectively.
The control law is chosen to be
ud = d d

(2.7)

uq = q q

(2.8)

where,
d = [d1

d2

d = [id

rd

q = [q1
q = [iq

d4

d5 ]

q4

q5

d ]T
q2

rq

d3

q3

q6 ]

q ]T

The ideal values of the control parameters are given by


d1 = adm Ld + R
d2 = Ld bdm
[d3

d4

d5 ] = d

q1 = aqm Lq + R
q2 = Lq bqm
[dq

q4

q5

q6 ] = q

On substituting the control law with the ideal parameters in the plant model,
it reduces to the form of the reference model. As the plant parameters are unknown, the ideal values can not be calculated and are therefore estimated for
6

controlling the plant output.


The adaptive law for estimating the control parameter are derived in the
same manner for both the q-axis and d-axis current. The derivation of the
adaptive law for the q-axis current alone is presented in the following theory.
The q-axis current tracking error is given by
eq = iq iqm

By adding the control term

Lq q q

(2.9)

to the plant model, it reduces to the form

1
i q = aqm eq + bqm rq +
(uq Tq q )
Lq

(2.10)

Then the error dynamics is given by


1
(uq q q )
Lq

(2.11)

1
(q q q q )
Lq

(2.12)

e q = aqm eq +
e q = aqm eq +

Therefore, by substituting in the above equation the parameter estimation error


given by
q = q q

(2.13)

The error dynamics is refined to


e q = aqm eq +

1
(q q )
Lq

(2.14)

Since the equation relating the q-axis current tracking error and the parameter
estimation error is of first order, it is strictly positive real (SPR). This prompts
the formulation of the adaptive law based on the Lyapunov design. Considering
the Lyapunov function candidate
Vq =

e2q
1 T 1
+
q
2
Lq q q

(2.15)

In the above equation, Lq > 0 since inductance is positive and the adaptation
gain matrix, q > 0 as well making it a positive definite function.
The Lyapunov function derivative is given by
1
1 T 1
V q = aqm e2q + eq q q +
q
Lq
Lq q q

(2.16)

Therefore, for negative semi-definiteness, q is chosen to be


q = eq q q

(2.17)

This gives the adaptation law for the controller parameter


In a similar procedure, d can be obtained to be
d = ed d d

(2.18)

The torque produced by the motor is of the form

Mm =

3
3
p((Ld Lq )id iq ) p((q6 sin(6e ) + q12 sin(12e ))id )+
2
2
3
p((d0 + d6 cos(6e ) + d12 cos(12e ))iq )
2
(2.19)

The first term does not have any contribution to the motor output torque since
Ld = Lq . The second term does not consist of any DC gain. It only contributes
to the ripple in torque due to the harmonic terms. So its contribution is nullified
by having the d-axis current to be zero by making rd = 0. The third and the last
term is used to provide the reference signal to the q-axis current by considering
the term from hereafter called Current Factor(CF) multiplied by the command
torque Mw
CF =

3
2 p(d0

1
+ d6 cos(6e ) + d12 cos(12e ))

(2.20)

The terms in the current factor are adaptively estimated as they are in the control parameters.
rq = CF Mw

MRAC FOR SPEED SUBSYSTEM USING


LYAPUNOV APPROACH

Now, the model for the mechanical subsystem is given by


1
Bf
+ Mm
(3.1)
J
J
The command torque Mw and the motor output torque Mm are given by the
same model as that of q-axis current reference model for simplicity. The load
torque which is considered to be a disturbance is neglected for convenience
=

M m = aqm Mm + bqm Mw

(3.2)

The transfer function relating the angular velocity and the command torque
Mw is given by
Kp
(s)
= Wp (s) = 2
Mw (s)
s + a1 s + a0

(3.3)

where,
Kp =

bqm
J

a1 = aqm +
a0 =

Bf
J

aqm Bf
J

Kp , a1 and a0 are time-varying unknown coefficients


The reference model for the speed subsystem is given as
m (s)
Km
= Wm (s) = 2
r (s)
s + am1 s + am0

(3.4)

Based on model reference control (MRC), the control law is derived to be in the
form of
Mw (s) = 1

1
1
Mw (s) + 2
(s) + 3 (s) + 4 r (s)
(s + )
(s + )

(3.5)

where, (s + ) is a Hurwitz polynomial and 1 , 2 , 3 and 4 are ideal control


parameters obtained by matching equations in the case of known plant parameters
The closed loop transfer function is obtained as
(s)
Kp 4 (s + )
= 2
r (s)
(s + a1 s + a0 )((s + ) 1 ) Kp (2 + 3 (s + ))
9

(3.6)

Therefore the ideal control parameters can be found out to be


1 = a1 am1
((a0 am0 ) + a0 1 Kp 3 )

2 =

1
KP

3 =

1
Kp ((a1

4 =

Km
Kp

am1 ) + (a0 am0 ) a1 1 )

Representing the plant model in state space format


x = Ax + bMw

(3.7)

=c x

(3.8)

where, x is state vector and A,b,c are matrices with appropriate dimensions.
The control law (3.5) is represented as
1 = 1 + Mw
T

where, D = diag(c

(3.9)

2 = 2 + c X

(3.10)

Mw = DX T + 4 r

(3.11)

1), X = [x

2 ]

The control law estimates are


4 and = [3

2 ]

Therefore, the plant model can be modified as


X = A0 X + Bc Mw
=

CcT X

(3.12)
(3.13)

where,

A
A0 = 0
cT



0
b
c
0 , Bc = 1 , Cc = 0
0
0

(3.14)

Using the ideal control parameters in the state space equations, the ideal
closed loop transfer function is derived as
X = Ac X + Bc 4 r

(3.15)

= CcT X

(3.16)

10

where,
T

Ac = A0 + B c * D
Therefore,
Gc (s) = CcT (sI Ac )1 Bc 4 = Wm (s)
Therefore the reference model can be represented in state space form as
X m = Ac Xm + Bc 4 r

(3.17)

m = CcT Xm

(3.18)

The speed tracking error is given by


e1 = m

(3.19)

e = X Xm

(3.20)

and also
By adding and subtracting the ideal control law in the form
T
Bc * DX + Bc 4 r to the augmented plant equation,
T
X = Ac X + Bc 4 r + Bc (Mw * DX 4 r )

(3.21)

= CcT X

(3.22)

c 1 (Mw * T DX 4 r )
e = Ac e + B
4

(3.23)

e1 = CcT e

(3.24)

where,
c = B c
B
4
Substituting the control law in the above equation it is seen that the parameter error is related to the tracking error through the reference model Wm (s)
Since the reference model is of relative degree 2 it is not strictly positive real
(SPR) and hence cannot be used to formulate an adaptive law to estimate the
controller parameters using a Lyapunov function. Therefore, to make it strictly
positive real, a first order polynomial (s + ), > 0 is multiplied by Wm (s) such
that Wm (s)(s + ) is strictly positive real(SPR).
Therefore, the tracking error now becomes
c 1 (s + )(Mwf * T DXf 4 rf )
e = Ac e + B
4
11

(3.25)

where,
Mwf = (s + )1 Mw , Xf = (s + )1 X and rf = (s + )1 r are filtered
signals. The control law is modified to be
Mwf = T DXf + 4 rf

(3.26)

Introducing = and 4 = 4 4
c 1 (T DXf + 4 rf )
e = Ac e + B
4

(3.27)

e1 = CcT e

(3.28)

It can also be represented as


e = Wm (s)(s + )

1 T
( DXf + 4 rf )
4

(3.29)

The control law is currently of the form


Mw = (s + )Mwf

(3.30)

T DXf + T DX + 4 rf + 4 r
Mw =
The error equations can be re-written by using e =
as
e = Ac e + B1

(3.31)

e(Bc 1 T DXf +Bc 1 4 rf )


4
4

1 T
( DXf + 4 rf )
4

e1 = CcT e

(3.32)
(3.33)

c + B
c and CcT Bc = 0
In the above equation B1 = Ac B
The Lyapunov function is given by
V =

1 T
1 1
1 1
e P e + | |T 1 + | | 1 42
2
2 4
2 4

(3.34)

In the above function, > 0, > 0 are the design parameters and since Wm (s)
is SPR, from Mayer-Kalman-Yakubovich (MKY) lemma,
ATc P + P Ac = Q

(3.35)

P B1 = Cc

(3.36)

where P > 0, Q > 0


The Lyapunov derivative function is given by
1
1
1
1 1

V = eT (Q)
e+ eT P B1 T DXf + eT P B1 4 rf +| |T 1 +|
| 4 4
4
4
4
4
(3.37)
12

For V 0, considering eT P B1 = e1 it is chosen that


= sgn( 1 )e1 DXf and 4 = sgn( 1 )e1 rf
4

This leads to V = e (Q)


e0
T

Therefore, the adaptive laws to estimate the control parameters are


= sgn( 1 )e1 DXf

(3.38)

= sgn( 1 )e1 rf

4
4

(3.39)

The simulation results show good performance when the initial conditions
of the control law parameters are nearer to ideal values and unsatisfactory performance when it is not near ideal values.

13

MRAC OF SPEED SUBSYSTEM USING AUGMENTED ERROR METHOD

Now an adaptation law based on the augmented error method is used and the
performance is evaluated using simulations.
The plant model is once again,
(s)
Kp
= Wp (s) = 2
Mw (s)
s + a1 s + a0

(4.1)

The reference model for the speed subsystem is also given by


Km
m (s)
= Wm (s) = 2
r (s)
s + am1 s + am0

(4.2)

Since the plant parameters are considered to be unknown, the control law is
given by

u = T (t)(t)

(4.3)

As the degree of the plant model is n = 2 the control law has 2n parameters
in (t)
= [1

= [r (t)

4 ]T

(4.4)

and
(t)]T

(4.5)

Considering the parameter error to be


(t) = (t) (t)

(4.6)

Therefore the control law becomes


u = (t) + T (t)

(4.7)

The equation relating the tracking error and the parameter error is given by
e(t) = Wm (s)[T (t)(t)/1 (t)]

(4.8)

Considering the auxiliary error to be


(t) = T (t)Wm (s)[(t)] Wm (s)[T (t)(t)]

(4.9)

The augmented error is given by


(t) = e(t) + (t)(t)
14

(4.10)

The adaptation law is given by


sgn(Kp )

=
T
1+


1+
T

(4.11)
(4.12)

where,
= Wm (s)[]
The simulation results obtained show good performance compared to the
Lyapunov based approach used with initial conditions not nearer to ideal values.

15

MRAC TO CONTROL A ROTARY SYSTEM


ATTACHED TO MOTOR SHAFT

The MRAC is now extended to control the velocity of another rotatory system
attached to the shaft of the motor via a spring of stiffness K. The model of the
mechanical subsystem of the PMSM changes now.

Figure 1: Two degree system


The equations of motion of the mechanical subsystem is given by
J1 1 + K(1 2 ) + Bf 1 = Mm
J2 2 K(1 2 ) = 0
2

(J1 s + Bf s + K)1 (s) K2 (s) = Mm


2

(5.1)
(5.2)
(5.3)

(J2 s + K)2 (s) K1 (s) = 0

(5.4)

K
2 (s)
=
Mm
(J1 J2 )s4 + (J2 Bf )s3 + (J1 K + J2 K)s2 + Bf Ks

(5.5)

The transfer function relating the commanding torque Mw and Mm is given by


Mm (s)
bqm
=
Mw (s)
s + aqm
2 (s)
Kbqm
=
5
Mw (s)
(J1 J2 )s + (aqm J1 J2 + J2 Bf )s4 + (aqm + J1 K + J2 K)s3 +
1
(aqm J1 K + aqm J2 K + Bf K)s2 + (aqm Bf K)s

(5.6)

(5.7)

Therefore, the plant model is


2 (s)
Kp
= Wp (s) =
Mw (s)
a5 s5 + a4 s4 + a3 s3 + a2 s2 + a1 s + a0
16

(5.8)

where the coefficients, a5 , a4 , a3 , a2 , a1 and a0 are unknown time-varying coefficients to be adaptively estimated.
The reference model is obtained to be
2m
Km
= Wm (s) =
5
4
ref
a5m s + a4m s + a3m s3 + a2m s2 + a1m s + a0m

(5.9)

The adaptation law can not be obtained using Lyapunov approach as the reference model is not SPR due to the relative degree being greater than one.
Therefore the adaptation law is obtained using the augmented error method as
seen in the previous chapter
The procedure is same except for the number of control law parameters
The control law is given by
Mw (s) = T (t)(t)
where, = [1
= [ref (t)

2
1

3
2

6
4

7
5

(5.10)
8

9
7

10
8

2 (t)]T

The filter signal (1 : 8) is obtained as


[ 1 2 3 4 ]T = diag( )[1 2 3 4 ]T + [h h h h]T Mw (5.11)
[ 5 6 7 8 ]T = diag( )[5 6 7 8 ]T + [h h h h]T 2

(5.12)

where, q (s) = Zm (s)l (s) in which l (s) is a Hurwitz polynomial


And det[sI ] = q (s)
The tracking error is given by
e = 2 ref

(5.13)

Now considering the auxilliary error,


(t) = T (t)Wm (s)[(t)] Wm (s)[T (t)(t)]

(5.14)

The augmented error is given by


(t) = e(t) + (t)(t)

(5.15)

The adaptation law is given by


sgn(Kp )

=
T
1+

17

(5.16)


1+
T

where,
= Wm (s)[]

18

(5.17)

SIMULATION

The simulation of the MRAC for the speed subsystem is done using a reference
signal of r = 5sin(0.5t).

Figure 2: Motor shaft speed


In Figure 2, a perfect tracking of the reference model by the plant model is
observed. At time instance t = 6.1 sec there is a slight offset of plant output from
model output. This is attributed to the shift in the estimated parameter which
will be seen in Figure 5. It is to be noted that the initial values for the controller
parameters were chosen near to the ideal values ie., = [0
200 0]. The
error tracking shown in Figure 3 confirms the statement.

Figure 3: speed error

19

Figure 4: Parameter convergence of Speed control law parameters-I

Figure 5: Parameter convergence of Speed control law parameters-II


The simulation of the MRAC for the current subsystem is done using a
reference signal of rq = CF sin(0.25t) instead of rq = CF Mw for better
interpretation of results

20

Figure 6: q-axis model current


The wild oscillations in Figure 6 till t = 2.5sec is due to the fact that the
parameter converges only at t = 2.5sec as seen in Figure 9. After that the
oscillations die off.

Figure 7: q-axis plant current


The plant current almost follows the model current perfectly

21

Figure 8: q-axis current error


The q-axis current error confirms the above statements made for the q-axis
plant and model current

Figure 9: q-axis Current Control law parameter convergence

22

The d-axis current is made 0 by having a d-axis reference current of rd = 0.


Therefore the d-axis current contribution to the output torque Mm is nil.

Figure 10: d-axis current


The output torque Mm does not have the harmonics that was inherent in its
equation since it is nullified by the q-axis current. But still, the oscillations in
q-axis current due to the tracking error is translated to the output torque Mm

Figure 11: Torque output, Mm

23

When initial conditions not close to ideal values were chosen


= [1
100 1], the results were not satisfactory with the Lyapunov based
adaptation law. The plots for velocity profile (reference and model), parameter
convergence and velocity tracking error are shown below

Figure 12: Shaft Speed fro non-ideal initial conditions

Figure 13: Parameter convergence for non-ideal initial conditions, 2

24

Figure 14: Speed tracking error for non-ideal conditions


The simulation for the MRAC design of speed subsystem based on Augmented error method is shown below.
The simulations showed perfect tracking for different initial conditions

Figure 15: Velocity profile of Plant and Reference for MRAC based on Augmented error

25

Figure 16: Parameter convergence MRAC based on Augmented error


The simulation of MRAC when another rotary system is attached for a
reference signal r = sin(0.25t) is shown below

Figure 17: Speed profile of the rotary system attached, 2

26

The parameter convergence and the tracking error are shown below

Figure 18: Parameter convergence for the control law for 2


It is seen that the error does not converge to zero but still negligible enough
to consider the plant model almost tracking the reference model. This is due
to the fact that the control law becomes less effective with increasing order of
plant for MRAC based on augmented error method.

27

Figure 19: Speed tracking error for 2

7
7.1

APPENDIX
Model Reference Adaptive Control for Current and
Speed Subsystem

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%Rajmohan Asokan%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%Model Reference Adaptive Control%%%%%%%%%%
%%%%%%%%%%%%%%Current and Speed Subsytem%%%%%%%%%%%%%
function Final version
options=odeset('RelTol',1e-2,'AbsTol',1e-2);
ts=[0 50];
xi(1:4)=0;
xi(5:6)=0;
xi(7:11)=0;
xi(12:14)=[0 -200 0]; % Near ideal initial conditions
% xi(12:14)=[1 -100 1]; % Non-ideal initial conditions
xi(15)=0;
xi(16:18)=0;
xi(19:23)=[5 0 0 0 28];
xi(24:29)=[5 0 0.2 0 0 30];
xi(30:31)=0;
[t,y]=ode45(@exec,ts,xi,options);

28

[am,bm,cm,dm] = tf2ss([200000],[1 1200 200000]);


omega m = y(:,1:2)*cm';
[ap,bp,cp,dp] = tf2ss([62500000],[1 1000.5125 512.5]);
omega = y(:,3:4)*cp';
figure(1);
plot(t,omega m,'r--','linewidth',2);hold on;
plot(t,omega,'-b','linewidth',2);
title('Rotational speed of the rotor in rad/sec','FontSize',15);...
set(legend('Model','plant'),'FontSize',15);
xlabel('Time in sec','FontSize',15);ylabel('Speed','FontSize',15);
figure(2)
plot(t,y(:,17),'linewidth',2);
title('q-Axis model current','FontSize',15)
xlabel('Time in sec','FontSize',15);ylabel('Current (A)','FontSize',15);
M m=(1.5.*2.*(y(:,27)+y(:,28).*cos(6.*2.*y(:,18))+...
y(:,29).*cos(12.*2.*y(:,18)))).*y(:,31);
figure(3)
plot(t,M m,'linewidth',2);
title('Output Torque','FontSize',15);
xlabel('Time in sec','FontSize',15);ylabel('Torque(Nm)','FontSize',15);
figure(4)
plot(t,y(:,31),'linewidth',2);
title('q-Axis plant current','FontSize',15);
xlabel('Time in sec','FontSize',15);ylabel('Current(A)','FontSize',15);
e q = y(:,31) - y(:,17);
figure(5)
plot(t,e q,'linewidth',2);
title('q-Axis current error','FontSize',15);
xlabel('Time in sec','FontSize',15);ylabel('E q','FontSize',15);
figure(6)
plot(t,y(:,27),'-k','linewidth',3);hold on;
plot(t,y(:,28),'-b','linewidth',3);hold on;
plot(t,y(:,29),'-r','linewidth',1.5);
title('Parameters of Current Factor','FontSize',15);...
set(legend('psi-do','psi-d6','psi-d12'),'FontSize',15);
xlabel('Time in sec','FontSize',15);ylabel('Flux(Wb)','FontSize',15);
figure(7)
e 1 = (62500000.*y(:,4))-(200000.*y(:,2));
plot(t,e 1,'linewidth',2);
title('Speed Error','FontSize',15);
xlabel('Time in sec','FontSize',15);ylabel('e-1','FontSize',15);
figure(8)
plot(t,y(:,13),t,y(:,14),t,y(:,12));
title('Parameters of Speed control law','FontSize',15);
set(legend('theta1','theta2','theta3'),'FontSize',15);
xlabel('Time in sec','FontSize',15);
figure(9)
plot(t,y(:,30),'linewidth',2)
title('d-Axis plant current','FontSize',15);
xlabel('Time in sec','FontSize',15);ylabel('Current(A)','FontSize',15);
figure(10)
plot(t,y(:,16),'linewidth',2);
title('d-Axis model current','FontSize',15);
xlabel('Time in sec','FontSize',15);ylabel('Current(A)','FontSize',15);
clc
clear all

29

function dx = exec(t,x)
%% Speed Control subsystem
% Reference Model
omega r = 5*sin(0.5*t);
[am,bm,cm,dm] = tf2ss([200000],[1 1200 200000]);
dx(1:2,1) = am*x(1:2)+bm*omega r;
omega m = cm*x(1:2);
% Control law
[ap,bp,cp,dp] = tf2ss([62500000],[1 1000.5125 512.5]);
[af,bf,cf,df]=tf2ss([1],[1 500]);
dx(7:10,1) = blkdiag(af,af,af,af)*x(7:10)+...
blkdiag(bf,bf,bf,bf)*[x(3) x(4) x(5) x(6)]';
X f = blkdiag(cf,cf,cf,cf)*x(7:10);
dx(11,1) = af*x(11)+bf*omega r;
omega rf = cf*x(11);
omega = cp*x(3:4);
% Error
e 1 = (62500000.*x(4))-(200000.*x(2));
dx(12:14,1) = -sign(1/0.0032)* e 1 *diag([12 12 12])*blkdiag(cp,1,1)* X f;
dx(15,1) = -sign(1/0.0032)* e 1 *12*omega rf;
% Command Torque
M w = (dx(12:14,1)'*blkdiag(cp,1,1)* X f)+[x(12) x(13) x(14)]*...
blkdiag(cp,1,1)*[x(3) x(4) x(5) x(6)]'+...
(dx(15,1)*omega rf)+x(15)*omega r;
dx(3:4,1) = ap*x(3:4)+bp* M w;
dx(5) = -500*x(5)+M w;
dx(6) = -500*x(6)+cp*x(3:4);
%%CURRENT LOOP
rd = 0;
CF=1/(1.5*2*(x(27)+x(28)*cos(6*2*x(18))+x(29)*cos(12*2*x(18))));
% rq = CF.* M w;
rq=CF.*sin(0.5.*t);
% Current Subsystem
% Reference Model
a dm = 1000;
a qm = 1000;
b dm = 1000;
b qm = 1000;
dx(16,1)=-a dm. *x(16)+b dm. *rd;
dx(17,1)=-a qm. *x(17)+b qm. *rq;
%% Control law and plant model
dx(18,1)=(62500000.*x(4));
phi d = [2*omega*x(31) 2*omega*sin(6*2*x(18,1)) 2*omega*sin(12*2*x(18))];
phi q = [2*omega*x(30) 2*omega 2*omega*cos(6*2*x(18,1))...
2*omega*cos(12*2*x(18))];
xd=[x(30) rd phi d];
xq=[x(31) rq phi q];
ud = [x(19) x(20) x(21) x(22) x(23)]*xd';
uq = [x(24) x(25) x(26) x(27) x(28) x(29)]*xq';

30

e d = x(30) - x(16);
e q = x(31) - x(17);
dx(19:23,1) = -e d *diag([2 2 0.8 0.8 2])*xd';
dx(24:29,1) = -e q *diag([2 2 0.8 0.8 0.8 2])*xq';
Omega d=[0.0284 0.0036 0.0022];
Omega q=[0.0284 0.303 0.0181 0.0024];
% Plant model
R=33.6;
Ld=0.0284;
Lq=0.0284;
dx(30,1) = -(R./Ld)*x(30)+(1./Ld).*ud+(1./Ld).*(Omega d* phi d');
dx(31,1) = -(R./Lq)*x(31)+(1./Lq).*uq-(1./Lq).*(Omega q* phi q');

31

7.2

MRAC of Speed subsystem using Augmented error

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%Rajmohan Asokan%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%MRAC of Speed subsystem using Augmented error%%%%%%%%
function MRAC augmented error
initial=zeros(25,1);
[t,z]=ode45(@exec,[0 100],initial);
[am,bm,cm,dm]=tf2ss([200000],[1 1200 200000]);
Q ref=z(:,1:2)*cm';
[ap,bp,cp,dp]=tf2ss([62500000],[1 1000.5125 512.5]);
Q2=z(:,11:12)*cp';
plot(t,Q ref,t,Q2);
title('Speed of the motor shaft','FontSize',15);
legend('Reference','Plant');
xlabel('Time in sec','FontSize',15);
ylabel('Speed in rad/sec','FontSize',15);
figure(2);
plot(t,z(:,5:8));
title('Parameter convergence','FontSize',15);
xlabel('Time in sec','FontSize',15);
clc;
clear all;
function dx = exec(t,x)
rt=sin(0.25*t);
%%
% Reference Model
[am,bm,cm,dm]=tf2ss([200000],[1 1200 200000]);
dx(1:2,1)=am*x(1:2)+bm.*rt;
ym=cm*x(1:2)+dm.*rt;
% dx(1,1)=x(2);
% dx(2,1)=-4.*x(2)-4.*x(1)+4*rt;
%%
% Control law & Plant Model
theta=[x(5);x(6);x(7);x(8)];
[ap,bp,cp,dp]=tf2ss([62500000],[1 1000.5125 512.5]);
yp=cp*x(11:12);
% Plant Output
Omega=[rt;x(9);x(10);yp];
u = theta'*Omega; % Control Input
dx(11:12,1)=ap*x(11:12)+bp.*u;
% Filtered signals
dx(9,1)=-2*x(9)+1*u;
dx(10,1)=-2*x(10)+1*yp;
%%
% Adaptation law
error=yp-ym ;
% Error
dx(15:22,1)=blkdiag(am,am,am,am)*x(15:22)+blkdiag(bm,bm,bm,bm)*Omega;
z1=blkdiag(cm,cm,cm,cm)*x(15:22)+blkdiag(dm,dm,dm,dm)*Omega ;
dx(23:24,1)=am*x(23:24)+bm*(theta'*Omega);
z2=cm*x(23:24)+dm*(theta'*Omega);
eta=(theta'*z1)-(z2); % Auxilliary Error
epsilon=error+(x(25)*eta); %Augmented Error

32

% Parameter Adaptation
dx(5:8,1)=-(sign(0.166)*1*epsilon*z1)/(1+z1'*z1);
dx(25,1)=-1*epsilon*eta/(1+z1'*z1);

7.3

MRAC of rotary system attached to shaft

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%Rajmohan Asokan%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%MRAC of rotary system attached to shaft%%%%%%%%%%%%%%%%%%%%%%
function project extension
initial = zeros(84,1);
[t,y] = ode45(@exec,[0 200],initial);
[am,bm,cm,dm] = tf2ss([10],[1 2 3 4 1 1]);
ref = y(:,1:5)*cm';
[ap,bp,cp,dp] = tf2ss([5],[1 5 6 8 3 2]);
fol = y(:,16:20)*cp';
error 1=fol-ref;
plot(t,ref,'r--','linewidth',2);
hold on;
plot(t,fol,'-b','linewidth',2);
title('Velocity profile of Reference and Plant of Two-degree system',...
'FontSize',15);
xlabel('Time in sec','FontSize',15);
ylabel('Speed in rad/sec','FontSize',15);
figure(2)
plot(t,y(:,6:15));
title('Parameter Convergence','FontSize',15);
xlabel('Time in sec','FontSize',15);
figure(3)
plot(t,error 1);
title('Speed Tracking Error','FontSize',15);
xlabel('Time in sec','FontSize',15);
function dx = exec(t,x)
rt = sin(0.25*t);
%% Reference Model
[am,bm,cm,dm] = tf2ss([10],[1 2 3 4 1 1]);
dx(1:5,1) = am*x(1:5)+bm*rt;
ym = cm*x(1:5);
%% Control law & Plant model
theta = x(6:15);
% Plant Model
[ap,bp,cp,dp] = tf2ss([5],[1 5 6 8 3 2]);
yp = cp*x(16:20);
Omega = [rt;x(21:28);yp];
% Control Input
u = theta'*Omega;
dx(16:20,1) = ap*x(16:20)+bp.*u;
% Filtered signal
dx(21:24,1) = (3.162*diag([-5 -4 -3 -2]))*x(21:24)+[1;1;1;1].*u;
dx(25:28,1) = (3.162*diag([-5 -4 -3 -2]))*x(25:28)+[1;1;1;1].*yp;
%% Adaptation law

33

error = yp - ym;
dx(29:78,1) = blkdiag(am,am,am,am,am,am,am,am,am,am)*x(29:78)+...
blkdiag(bm,bm,bm,bm,bm,bm,bm,bm,bm,bm)*[rt;x(21:28);yp];
z1 = blkdiag(cm,cm,cm,cm,cm,cm,cm,cm,cm,cm)*x(29:78);
dx(79:83,1) = am*x(79:83)+bm*u;
z2 = cm*x(79:83);
%% Auxilliary Error
eta = (theta'*z1)-z2;
epsilon = error+(x(84)*eta); % Augmented Error
%Paramter Adaptation law
dx(6:15,1) = -(sign(500)*1*epsilon*z1)/(1+z1'*z1);
dx(84,1) = -1*epsilon*eta/(1+z1'*z1);

34

References
[1] V Petrovi and Aleksandar M Stankovic. Modeling of pm synchronous motors
for control and estimation tasks. In Decision and Control, 2001. Proceedings
of the 40th IEEE Conference on, volume 3, pages 22292234. IEEE, 2001.
[2] Mari
an T
arnk and J
an Murgas. Model reference adaptive control of permanent magnet synchronous motor. Journal of Electrical Engineering,
62(3):117125, 2011.
[3] Richard V Monopoli. Model reference adaptive control with an augmented
error signal. Automatic Control, IEEE Transactions on, 19(5):474484,
1974.
[4] Petros A Ioannou and Jing Sun. Robust adaptive control. Courier Dover
Publications, 2012.
[5] Jean-Jacques E Slotine, Weiping Li, et al. Applied nonlinear control, volume
199. Prentice-Hall Englewood Cliffs, NJ, 1991.

35

You might also like