You are on page 1of 16

MATLAB/Simulink Sample Model Description

Vecrtor Control Simulation of AC Motor














































1
Vector Control Simulation of AC Motor

1. Introduction 2
2. Vector Control Model 4
2.1. Vector Control Basic principles 4
2.2. System Modeling 5
2.3. Using SimPowerSystems 7
3. Velocity Sensorless by Adaptive Secondary Flux Observer 8
3.1. Analysis Model and Principles 8
3.2. Modeling of Observer 11
4. Simulation Results 13
5. Conclution 14
6. References 15
7. Exemption from Responsibility 15
8. Author 15
9. Note 15
2
1. Introduction

The reasons depicted as below demonstrate that MATLAB/Simulink is a tool suitable for vector
control of AC Motor in this article.

Simulink block diagram can express configuration of the vector control diagram clarifying signal
stream by grouping and organizing function unit as subsystem,
Easy to express matrix formula often used in system expression of motor,
Able to model and simulate multi domain systems such as electric and mechanical systems as it is
simulator for mathematical expression model,
Embedded Legacy C source code can be verified through simulation with this legacy code as
controller and plant model in Simulink block diagram,
Able to co-simulate with magnetic field analysis software, mechanical analysis software and
electric circuit simulator.
Optional toolboxes and extended blocksets provide solutions for a wide variety of development
phases from algorithm design, verification, prototype testing to implementation.

Some of the solutions provided for development phase are listed below and what is covered in this
article is clarified as well.


Paramter Estimation of Motor
Implementation on processor
Control System Toolbox
SimPowerSystems
Real-Time Workshop
xPC Target
Optimization Toolbox
Real-Time Workshop
RTW Embedded Coder
Covered
region
Data Acquisition Toolbox
Optimization Toolbox
Control Design and Analysis
Verification by simulation
Controller Rapid Prototyping


Figure 1.1 Controller development process and related optional tools

3
In vector control, accuracy of internal parameter such as resister of motor armature and inductance
affects control performance. Internal parameters are used, for example, feed-forward compensator of
current controller and parameters of observer model in position sensorless. In the process of of
figure 1.1, some methods are possible such as: the same input voltage is applied to actual motor and
motor modeled in Simulink, and from the cost function that minimizes output current deviation, each
parameter is estimated in least square method. Data Acquisition Toolbox provides interface with A/D,
D/A boards, and allows acquisition of real signal by MATLAB program execution. The Optimization
Toolbox, function library providing various optimization methods, is available for optimization
calculation for parameter estimation.
In the process of , Control System Toolbox is available for designing observer based on modern
control theory, and verifying its characteristic features.
In the process of , simulation of the whole system is executed based on the parameters and
observers obtained from the processes and .
The SimPowerSystems, electric systems library, provides inverter and motor blocks. Because the
prepared Motor block is an ideal model not including non-linearity such as magnetic saturation, a
method such as co-simulating with magnetic analysis tool is considered in a more realistic
simulation.
Real-Time Workshop (RTW) can generate C-code from controller modeled by Simulink and
implement on MPU or DSP. However, as plant model of simulation is ideal motor model, control
parameter tuning may be required for actual machine. In the process of , xPC target can be used
for real-time simulation of actual motor, and tune parameters on Simulink model while monitoring
signal in real time. Auto-tuning through optimization calculation is applicable if Optimization
Toolbox is used in conjunction.
C code implemented on embedded system requires maximum performance from limited resources.
Although the RTW imposes less constraints and provides various solutions such as faster execution
and prototype test, generated code include redundancies not directly relevant to implementation. In
the process of , production-quality code suitable for implementation with good readability,
customization and performance, can be generated by combining add-on tool of RTW, RTW
Embedded Coder.

4
2. Vector Control Model

2.1 Vector Control Basic principles
In this section, basic principles of vector control are explained for modeling description.
As in figure 2.1, armature current I of three phase AC motor can be observed as rotating vector
by power supply angular velocity, , if observed on fixed coordinate system with axis of UVW of
which phases are deviated 120 degrees. The current vector can be kept motionless if observed in
synchronously rotating coordinate system with the power supply angular velocity. It can be
considered as direct-current value . We can simplify the electrical equations by using coordinate
transformation technique and the transformation angle can be arbitary selected. In the
case of induction motor, it is easy to treat the equations in synchronously rotating coordinate system
(d-q frame) with rotor flux linkage vector
r
.The equations on the three phase fixed coordinate
system (UVW) are converted into two phase fixed coordinate axis ( - ) of which phase are
deviated 90 degrees .And then, they are converted into d-q frame by the rotation angle in figure
2.2.
Then, electrical torque of AC motor can be expressed by outer product of flux vector and current
vector in the equation below.
( )
r r m e
I P T =
(2.1)
where P
m
: number of pole pares,

r
: rotor flux vector
| |
T
qr dr

, I
r
: rotor current vector
| |
T
qr dr
i i


U
V
W
I

I
r
d
q



Figure 2.1 three-phase fixed coordinate system Figure 2.2 two-phase fixed coordinate system and
rotating coordinate system

Equation (2.1) can be expressed below by treating d axis as rotor flux vector
|
|
.
|

\
|
= =
qs
r
dr m qr dr m e
i
L
M
P i P T

where M: coefficient of mutual induction, L
r
: rotor self inductance (2.2)
Subscript s means stator, r means rotor.
Equations (2.2) shows that with rotor flux being constant, the motor torque can be controlled by q
axis current of stator. Rotor flux can be expressed as
ds
r
dr
i
s
M
t

+
=
1

where,
r
= L
r
/R

: time constant (2.3)


Equations (2.3) shows the rotor flux can be controlled to be constant by d axis current of stater.
It allows to control the motor torque using constant target value of current in the same simple way as
conventional DC brush motor in coordinate conversion by phase of flux vector.
5
2.2 System Modeling
It is important to determine accurate flux vector in induction motor. Some of the methods to detect
flux vector include direct detection, where magnetic sensor by hall element is used, and indirect
detection, where slip angular frequency is added to the detected rotating angular velocity. Here, we
consider model that estimates flux vector and rotating angle using flux observer. This is one of the
sensorless methods that do not require magnetic and position sensors.


Speed
Controller
Current
Controller
Coordinate
Transformer
Rotating Fix
Coordinate
Transformer
2 axis 3 axis
Coordi nate
Transformer
Fix Rotating
Adaptive
Observer
Inverter
Induction
Motor
Coordinate
Transformer
3 axis 2 axis
r
r
o
|

1
tan

Speed
Controller
Current
Controller
Coordinate
Transformer
Rotating Fix
Coordinate
Transformer
2 axis 3 axis
Coordi nate
Transformer
Fix Rotating
Adaptive
Observer
Inverter
Induction
Motor
Coordinate
Transformer
3 axis 2 axis
r
r
o
|

1
tan

*
r
e
u
*
*
qs
ds
i
i
*
*
qs
ds
v
v
*
*
|
o
v
v
r
r
r
e

|
o

*
*
*
w
v
u
v
v
v
w
v
u
i
i
i
qs
ds
i
i
|
o
i
i
Controller part


Figure 2.3 Position sensorless vector control configuration

3
vw
2
vv
1
vu a
b
u
v
w
Two_To_Three
u
v
w
a
b
Three_To_Two
Phai*ids*
Subsystem
w*
w
Te*
SpeedController
xx
yy
Theta
x
y
Rotating_To_Fixed
xx
yy
Theta
x
y
Fixed_To_Rotating
atan2(u(2),u(1))
Fcn2
f(u)
Fcn1
f(u)
Fcn
Demux
ids*
iqs*
Ramda_r*
ids_feedback
iqs_feedback
w
vds
vqs
Currnet Controller
va*
vb*
ia
ib
Ram_ar
Ram_br
wr^
Adaptive Observer
3
iuvw
2
wr*
1
Ramda_r*
ids*
iqs*
vds*
vqs*
va*
vb*
vb*
vb*
ia ia
ib ib
iqs
ids
vu*
vv*
vw*
wr^
wr^
iu
iv
iw
w
Ramd_ar
Ramd_br
theta
theta


Figure 2.4 Modeling example of controller part (note: see at the end of this paper for symbols)

Symbol * in figure 2.3 denotes target value, and ^ denotes estimate value (see the end of this paper).
Note, as in figure 2.4, configuration diagram of controller part in figure 2.3 is expressed by making
each operator element subsystem.
Coordinate transformation can be expressed in the equation below.

6
Transformation Equation
From fixed coordinate to rotating coordinate i
e
=Ci
From rotating coordinate to fixed coodinate v=C
T
v
e

From three phase to two phase i
2
=Di
3

From two phase to three phase v
3
=D
T
v
2

Where;
Rotary matrix:
(

=
u u
u u
cos sin
sin cos
C
,
three-phase to two-phase transformation matrix:
(

=
) 3 4 ( sin ) 3 2 ( sin 0 sin
) 3 4 ( cos ) 3 2 ( cos 0 cos
3
2
t t
t t
D


where, denotes vector, e denotes direct-current value, T denotes transpose, subscript 2 denotes
two-phase, 3 denotes three-phase.
This part easily expressed, for example as figure 2.5 shows, by mathematical formula definition of
Fcn block in Simulink.

2
y
1
x
- u(1)*sin(u(3)) +u(2)*cos(u(3))
Fcn1
u(1)*cos(u(3)) +u(2)*sin(u(3))
Fcn
3
Theta
2
yy
1
xx

Figure 2.5 Internal model of coordinate trasformer subsystem

Current controller is PI control loop with feedforward compensater considered in synchronously
rotating coordinate system. This model compensates, by feedforward, nonstationary term of power
supply frequency, , obtained from electric formula of motors analogous circuit in orthogonal two
axis rotating coordinate system.
2
vqs*
1
vds*
ids*
Ramda*
w
Out1
feedforward2
iqs*
w
Out1
feedforward1
PID
Discrete
PID Controller1
PID
Discrete
PID Controller
6
w
5
iqs_feedback
4
ids_feedback
3
Ramda_r*
2
iqs*
1
ids*

Figure 2.6 Internal model of currnt controller subsystem

Adaptive observer is constructed by two-phase fixed coordinate system.Modeling of adaptive
observer is described in the next chapter.
7
2.3 Using SimPowerSystems
Motor, PWM Generator and Inverter of carrier wave comparison can be modeled by using
Simulink. If time saving of modeling is desirable, SimPowerSystems, Simulinks extended option, is
available. Synchronous Motor, Induction Motor Drive, DC Motor and others are prepared in the
block library. Figure 2.7 on the next page indicates model of the overall system and figure 2.4
indicates internal model of the controller. Reference voltage from CPU subsystem is compared with
carrier wave with PWM Generator block provided in SimPowerSystems and generates 6 PWM
pulses. The mechanism switches each gate of IGBT of three arm bridge circuit block (block name:
Universal Bridge), and drive connected induction motor block. Universal Bridge also allows
switching of MOSFET, GTO, Thyristor, ideal switch from menu. Features of the SimPowerSystems
are listed as below:

Modeling in circuit topology using block of symbolized element
Continuous and discrete simulation modes using Simulinks stiff ordinary differential equation
solver are provided. Faster simulation is achieved in discrete mode.
Inside of block can be almost referenced.
Supports automatic code generation tool, RTW, and real time-simulation is achievable
Many sample demo models related to Motor control, including vector control are provided.

Discrete,
Ts =1e- 005s.
Vdc
v
+
-
Vab
g
A
B
C
+
-
Universal Bridge
Sw1
Sw
1000
Speed_ref2
RPM
1000
Speed_ref1
RPM
In1 Out1
Sigs
Scope
Signal(s) Pulses
PWMGenerator
50
Load2
1
Load1
Tm
m
A
B
C
Induction Motor
- K-
Gain2
- K-
Gain
0.96
Flux_ref
In1 Out1
Current filter
Ramda_r*
wr*
iuvw
vu
vv
vw
CPU
<Rotor speed (wm)>
<Electromagnetic torque Te (N*m)>

Figure 2.7 Modeling Example using SimPowerSystem

8
3. Velocity Sensorless by Adaptive Secondary Flux Observer
3.1 Analysis Model and Principles
Rotor flux should be estimated if the same input voltage as the actual input is applied to the
mathematical model simulator that is implemented on the processor.
However, when constructing velocity sensorless system, changes of nonstationary velocity term can
not be made by actual velocity sensor output ,and the estimated value of flux will deviate from the
actual value.
So, adaptive observer that modifies incorrect constant term of mathematical model with function of
the output deviation is applied (figure 3.1). In this case, the terms of electric angular velocity are
regarded as the incorrect terms.
State-space expression of induction motor in orthogonal two axis fixed coordinate system can be
expressed in the equation below:
Cx i Bv Ax dt dx
s s
= + = ,
(3.1)

where,
| |
| |
| |
( ) ( ) ( ) ( )
( ) ( )
( ) | |
| |
( ) M L L L L M
I C
I L B
J I L R I L MR
J I L R I L L R M R
A
J I
i i i
v v v
i i x
r s r s
T
s
r r r r r
r r r s r r s
T
s s s
T
s s s
T
r r s s
o c o
o
e
c e c o

| o
| o
| o | o
= =
=
=
(

+
+
=
(


=
(

=
=
=
=

, 1
0
0 1
0 1
1 0
,
1 0
0 1
2
2 2
2 2
2 2

Note 1: reference: Equation of 2) applies
Note 2: See the end of this paper for meanings of each symbol
9
I M
B C
H
/

s
v
s
i
r
e
r

s s
i i e =

s
i

x
Speed Adaptive
system


Figure 3.1 Adaptive Flux Observer Configuration Diagram

State-space expression of observer in figure 3.1 can be expressed in the equation below:
x C i He Bv x A dt x d
s s

= + =
(3.2)
where, H is observer gain, ^ is estimation value, e is current error
s s
i i e =


( ) ( ) ( ) ( )
( ) ( )
(

+
+
=
J I L R I L MR
J I L R I L L R M R
A
r r r r r
r r r s r r s
e
c e c o

2 2

Then, parameter adjusting law of estimation electric angular velocity,
r
, are provided by the
following equation using size of outer product of current error vector, e, and estimation flux:

( ) ( )
}
+ = dt e J K e J K
T
r i
T
r p r
e

(3.3)

Observer gain H is designed in a way to ensure adaptability of control system consisting of adaptive
observer and induction motor, i.e.,
0 lim =

e
t
. Assuming that terms other than velocity estimation
value is true value, equation concerning current error, e, can be expressed as below from formulas
(3.1) and (3.2). It can be obtained by subtracting (3.1) from (3.2) and define matrix B

by
separating term of from system matrix. Its complete derivation is omitted here.
( )
r r
r r
J s G
J B HC A sI C e
e
e
e

) (
)

( ) (
1
4
A =
A + =

(3.4)
where,
r r r
e e e = A
, I
4
: 4x4 unit matrix,
| |
T
I I B = c
e

10
Then, consider feedback system comprising linear time-invariant block G(s) and nonlinear time
variation block similar to the figure below. Applying Popovs hyper stability, the following needs to
be satisfied to ensure stability,
0 lim =

e
t
.
1) linear time-invariant block G(s) is SPR (Strictly Positive Real).
2) input, v1, and output, w1, of nonlinear time variation block satisfy Popovs equation for all time
t1>t0.
2
0
1
0
1 1
>
}
dt w v
t
t
T
(3.5)
where, r
0
is constant independent of time

G(s)
P I

0
r
J r
e
r
e
T
r
J ) (
s s
i i e =
1
v
1
w
parameter
adjusting law


Figure 3.2 Current error block feedback system

It is possible to prove that 2) is satisfied by using e.q.(3.3). Optimal feedback gain H obtained from
the only solution of Riccati equation is applied to make G(s) SPR as a condition of 1).

H=PC
T
R
-1
(3.6)
Riccati equation:
0
1
= + +
T T T
QB B CP R PC AP PA
e e
(3.7)
where, P: Solution of Riccati equation, Q, R: Weight matrix
The weight matrices are Q=1, R=y I, respectively (however, y is a small positive number). (3.8)


11
3.2 Modeling of Observer
Parameters of motor and each matrix of state-space expression are defined in program (M-file) of
MATLAB language, and formula (3.7) is solved using the Control System Toolbox, and optimal
feedback is obtained. A program example is shown as follows:
Feedback gain is obtained in the last line.
[H, P, E] = lqe(A, Bw, C, Q, R)
The lqe is a function provided for designing Kalman filter estimator in Control System Toolbox. It
returns feedback gain, H, solution of Riccati equation, P, and pole of estimator, E=eig(A-H*C). Once
executed, M-file is loaded onto memory (workspace) in MATLAB, and defined as each block
parameter of Simulink model. Model example inside the subsystem of adoptive observer in figure
2.4 is indicated in figure 3.4. A key to the modeling is to separate and add nonstationary term (term
for
r
) included in system matrix A. You can see that modeling can be easily done using the
Integrator block if motor system is expressed in state-space.
Then, stability of transfer function G(s) of linear stationary term is verified. If absolute value of
phase difference between input and output is within 90 degrees, adaptive observer operates stably.
As indicated as mark of arrow in figure 3.4, the Linearization Point, provided by Simulink Control
Design, are located in the relevant input and output points.


























Figure 3.3 Program example of M-file



%%%%%%Motor parameters %%%%%%%%%%
Ts=2e- 6; %Sampl i ng Ti me ( sec)
Rs=0. 435; %Stator resi stance (Ohms)
Ll s=2. 0e- 3; %Stator l eakage i nductance ( H)
Rr=0. 816; %Rotor resi stance ( )
Ll r=2. 0e- 3; %Rotor l eakage i nductance (H)
M=69. 31e- 3; %Mutual I nductance (H)
Ls=M+Ll s; %Stator sel f i nductance ( H)
Lr=M+Ll r; %Rotor sel f i nductance (H)
p=2; %number of pol e pai rs
Ed=1000; %I nverter vol tage ( V)
Emax=Ed/ sqrt( 3); %Maxi mumtermi nal vol tage (V)
tr=Lr/ Rr; %Ti me Constant of f l ux
si gma=1- M^2/ ( Ls*Lr) ;
%%%%%%%State Space Matri x %%%%%%%%%%%%%
I =[1 0; 0 1]; J =[0 - 1; 1 0];
A11 =- (Rs +M^2*Rr/ Lr^2) / (si gma*Ls) * I ; A12 =M/ (si gma*tr*Ls*Lr) * I ;
A21 =M/ tr * I ; A22=- 1/ tr * I ;
A =[A11 A12; A21 A22] ;
B =[1/ (si gma*Ls) * I ; zeros(2) ];
C =[I zeros( 2)] ;
Bw=[M/ (si gma*Ls*Lr) * I ; - I ];
%%%%%% Wei ght Matri x %%%%%%%%%%%%%%%%%%
ep =0. 006;
R =ep*I ;
Q=I ;
%%%%%%Obtai ni ng Feedback Gai n %%%%%%%%%%
[ H, P, E] =l qe(A, Bw, C, Q, R) ;
12



















Figure 3.4 Example of Adaptive Observer Model


Figure 3.5 is a bode diagram of linear time-invariant block G(s) drawn with the LTI Viewer of the
Control System Toolbox. From the phase diagram, you can see that weight factor of formula (3.8)
=1, =0.006, are within 90 across the whole frequency range, and they are stable.




Figure 3.5 Bode diagram of linear time-invaliant block
Upper: gain characteristics Lower: Phase characteristics
o mark line: =0.006, * mark line: =1


Out1
1
Product1
Matrix
Multiply
Matrix_Gain3
Bw* u
Matrix_Gain2
[zeros(2) I]* u
Matrix_Gain1
J * u
Matrix_Gain
A* u
Gain
- 1
wr^
2
x
1
Ramda
Input Point
Output
Point
13
4. Simulation Results
This model includes PI gain that requires tuning for velocity controller, current controller and
velocity estimator.
Each control parameter is tuned by trial-and-error from response results of simulation. Refer to
reference 1) for design method of parameter proportional gain, Kp, integrator gain, K1 of velocity
estimator. Figure 4.1 shows simulation results from 0 to 1.5 seconds. 0 to 0.5 seconds show velocity
step response when velocity reference value is changed from 0[rpm] to 1000[rpm], 0.5 to 1.0 show
velocity step response of 1000[rpm] to 500[rpm], and 1.0 to 1.5 show torque step response when
external load torque is changed from 1[N] to 50[N]. Voltage between inverter UVs, armature current,
rotating velocity, and transient response of torque are simulated.

igure 4.1 Simulation Results
From the top,
voltage between inverter UVs[V],
three-phase stator current of motor[A],
motor rotating velocity[rpm], and torque[Nm]
14
5. Conclusion
This note presents position-sensorless vector control simulation by observer using optimal feedback
gain as an example of process from algorithm design to logic verification, by using
MATLAB/Simulink. Of cource, same way can be also applied to other motor type (e.g, PMSM).
However, some of control method as represent by flux-weakening control, one of the highly efficient
control methods of IPMSM, are necessary to consider hysteresis characteristics by magnetic
saturation, but not in the simulation presented in this paper. Solutions including magnetic field
analysis remain to be examined.



Symbol description
R Resistor [ ]
L Self-inductance [H]
M mutual inductance [H]
Rotor flux rotation angle [rad]
Rotor flux angle velocity [rad/sec]

r
Electric angular velocity [rad/sec]
T
e
Electric torque [N]
i current value [A]
v voltage value [V]
Flux linkage
P
m
number of pole pairs
s Laplace operator

Subscript symbol description
s Variable in the stator
r Variable in the rotor
U, V, W Variables in three-phase fixed coordinate system
, Variables in orthogonal two-axis fixed coordinate system
d, q Variables in orthogonal two-axis rotating coordinate system
* Target value
^ Estimation value

Description of signal label in figure 2.4
vds, vqs Voltage target value on d and q axes
va, vb Voltage target values on , axes
vu, vv, vw Voltage target values on UVW axis
ids, iqs Current target values on d and q axes
iu, iv, iw Current value on UVW axis
ia, ib Current values on and axes
* Subscript indicating target value
theta Rotor flux rotation angle (power supply angle)
w Rotor flux rotating angler velocity (power supply angler velocity)
wr Electric angler velocity estimation value
Ramd_ar, Ramd_br Rotor flux of and axes


15
6. References

1) Position Sensorless Control of PM Electric Motor using Adaptive Observer of Rotary Coordinate
System, Institute of Electrical Engineers Journal D (Industrial Application Journal) Vol.123-D No.5
p.600, 2003
Yoshihiko Kinpara

2) Robust Adaptive Full-Order Observer Design with Novel Adaptive Scheme for Speed Sensorless
Vector Controlled Induction Motors, IEEE-IECON 2002, PE-03, p. 83-88, 2002
Masaru Hasegawa, Keiju Matsui

3) Vector Control of AC Motor
Publisher: Nikkan Kogyo Shinbun Ltd.
Author: Takayoshi Nakano


7. Exemption from Responsibility
Under no circumstances will CYBERNET SYSTEMS CO.,LTD be liable in any way for in this
content, or for any loss or damage of any kind incurred as a result of the use of this content.


8. Author
Misao Katoh
katoh@cybernet.co.jp

Application Engineer
CDA Engineering Group, Field Application Engineering Department,
Applied Systems First Division
CYBERNET SYSTEMS CO.,LTD.


9. Note
This model is created using MATLAB products as follows.
(1) MATLAB Version 7.4 (R2007a)
(2) Simulink Version 6.6 (R2007a)
(3) SimPowerSystems Version 4.4 (R2007a)
(4) Control System Toolbox Version 8.0 (R2007a)

To run simulation of sample model, it is need above products (1) , (2) and (3).

You might also like