12/19/2017
1
Chapter 5-1
Karadeniz Technical UniversityDepartment of Electrical and Electronics Engineering
61080 Trabzon, Turkey
Chapter 5-2
State-Space Modelling
Bu ders notları sadece bu dersi alan öğrencilerin kullanımına açık olup,üçüncü sahıslara verilmesi, herhangi bir yöntemle çoğaltılıp başkayerlerde kullanılması, yayınlanması Prof. Dr. İsmail H. ALTAŞ’ın yazılıiznine tabidir. Aksi durumlarda yasal işlem yapılacaktır.
12/19/2017
2
Chapter 5-3
Mechanical System
uxkdtdx
Bdt
xdM =++
22
dtdx
Bxkuffudt
xdM bs
--=--=2
or,2
u(t)
x(t)
M
B
k
)()()()(2 sUsXksXBssXMs =++
Laplace transform;
)(1)( 2 sUkBsMs
sX ++= Transfer Fonksiyonu: G(s)
Chapter 5-4
RLC Circuit
ivi vo
LR
C
)(1)()()(Vi sICs
sILssIRs ++=
1 dtiCdt
diLiR ++= òVoltage of each elementvi =å
)()()(1)(2
sVsGsV
CRsLs
ssI ii =++
=
Transfer fonksiyon , G(s)
Using Laplace transform
Solve for I(s)
12/19/2017
3
Chapter 5-5
RLC Circuit
Similarities between mechanicaland electrical elements
• L <=> M• R <=> B• 1/C <=> k
)(1)( 2 sUkBsMs
sX ++=
Mechanical system Electrical system
Chapter 5-6
u(t)
x(t)
M
B
k
)(1)( 2 sUkBsMs
sX ++=
Mechanical System
Transfer functionDifferential equation
12/19/2017
4
Chapter 5-7
Mechanical System
One 2nd order LTI diff. Eq. can bewritten as two 1st order LTI diff. Eq.
Chapter 5-8
Mechanical System
Statevector
A: System matrixB: Input matrixC: Output matrix
StatevariablesOutput variable
12/19/2017
5
Chapter 5-9
Simulation Diagrams
y(t)
X(s) Y(s) X(s) Y(s)
X(s) Y(s)s-1
Chapter 5-10
U(s) Y(s)
Transfer Function to Simulation Diagram
U(s) Y(s)Z(s)
D(s)1
12/19/2017
6
Chapter 5-11
Transfer Function to Simulation DiagramEXAMPLE
(Initial conditions are zero)
Chapter 5-12
StateEquations
Outputequation
Transfer Function to Simulation DiagramEXAMPLE
12/19/2017
7
Chapter 5-13
+++
+
ControlCanonicalform
Transfer Function to Simulation DiagramEXAMPLE
Chapter 5-14
+ +++
From Figure
Transfer Function to Simulation Diagram
12/19/2017
8
Chapter 5-15
Multiply by
The type of this TF is similar to the obtained using Mason’s gainFormula as described below.
Transfer Function to Simulation Diagram
Chapter 5-16
Product of the ith foward path gains
1 – the loops remaining after removing path i. If noneremain, then Δi = 1.
Mason’s gain Formula
Transfer Function to Simulation Diagram
:Δ:M
i
i
1 - (S all individual loop gains
+ (Snontouching loop gains taken two at a time.)
- (S nontouching loop gains taken three at a time)+ ................
:D
12/19/2017
9
Chapter 5-17
So we have,
We have 3 paths from input to output
Transfer Function to Simulation Diagram
u y
Chapter 5-18
+ + ++ +
+
+
Transfer Function to Simulation Diagram
u y
12/19/2017
10
Chapter 5-19
Transfer Function to Simulation Diagram
Denominator of the transfer function
0
y
Chapter 5-20
Transfer Function to Simulation Diagram
y
+ +
---
+
12/19/2017
11
Chapter 5-21
Transfer Function to Simulation Diagram
+ + ++ +
+
+
Block diagramrepresenting thenominator
Get the complete block diagram by combining these two diagrams.
+ +
---
+Block diagramrepresenting thedenominator
Chapter 5-22
Transfer Function to Simulation Diagram
ObserverCanonicalform
---
+ + +
+ + x1x3 x2
12/19/2017
12
Chapter 5-23
Transfer Function to Simulation Diagram
Observer Canonical form
---
+ + ++ + x1x3 x2
From figure:
Stateequations
Chapter 5-24
Transfer Function to Simulation Diagram
Controlcanonicalform
Observercanonicalform
Two different simulation diagramThe number ofsimulation diagrams is n
Two differentstateequations
12/19/2017
13
Chapter 5-25
State-Space to Transfer Function
U(s) Y(s)
For a SISO system.
Chapter 5-26
State-Space to Transfer Function
alınırsa
For a SISO system.
12/19/2017
14
Chapter 5-27
State-Space to Transfer Function
Chapter 5-28
Matrices A, B, C and D are given below. Obtain the poles, zeros,characteristic equation, and the transfer function of this system.
State-Space to Transfer Function Example
Solution
12/19/2017
15
Chapter 5-29
State-Space to Transfer Function Example
Chapter 5-30
Zeros: -(-2+j1.7321)-(-2-j1.7321)
Poles: -1 ve -2
State-Space to Transfer Function Example
Characteristic Equation:
Transfer function
12/19/2017
16
Chapter 5-31
State-Space to Transfer Function Example
% From State space% to transfer functionA=[0 1;-2 -3];B=[1;2];C=[1 0];D=1;[num, den]=ss2tf(A,B,C,D)zeros=roots(num)poles=roots(den)
>>state_tf <enter>
num =1 4 7
den =1 3 2
zeros =-2.0000 + 1.7321i-2.0000 - 1.7321i
poles =-2-1
state_tf.m file Matlab command window
Chapter 5-32
Review following topics and solve the problems given.
Solution of the state equations using Laplace transformation.
Solution of the state transition matrix using inverse Laplacetransformation.
Search alternative solution methods to the following equation.
The solution of the state transition matrix using infitite series.
A, B, C and D matrices and vectors are given below. Solve the stateequations of this system and obtain the values of x((t) using the methodsdescribed above.
12/19/2017
17
Chapter 5-33
The state equations of a system are obtained from its differential equations ortransfer function. Various methods are applied to solve the state equations.
Chapter 5-34
Laplace
Apply thge same process to the 2nd set of the equations:
If the Laplace transformation of all equations are obtained in the same way andcombined , the general form given below is obtained.
Let us write this equation for X(s);
12/19/2017
18
Chapter 5-35
The state vector x(t) is obtained by getting the Inverse LaplaceTransformation.
DURUM GEÇİŞ MATRİSİ
Chapter 5-36
(It is also called the base matrix.)
Remarks:v An nth order system has an nth order state transition matrix.v The invers Laplace transformation of a matrix is defined as the inverse
Laplace transformations of its individual elements.v The inverse Laplace transformation of the last equation is difficult, time
consuming and possibility of making mistake is high.v The most practical way of solving state vector x(t) is the computer
simulation.
12/19/2017
19
Chapter 5-37
A transfer function is given above. Write the state equations of this system inobserver canonical form and solve for the state variables.
Chapter 5-38
continued...
State transition matrix:
12/19/2017
20
Chapter 5-39
Continued...
Solve the second part of the general solution equation for a unit step (u(t)=1)input.
Chapter 5-40
Then
The solution:
Continued...
12/19/2017
21
Chapter 5-41
The inverse Laplacetransform of the product oftwo terms in s-domain canbe expressed as aconvulation integral.
The solution with the Convulation theorem can be written as follows:
Zero input (includesthe initial values)
Zero state depends on inputs.(forced solution)
The statetransition matrixacts as a centre insolution of thestate equations.
Chapter 5-42
Bir önceki örnekte elde edilen durum geçiş matrisini ve B girişvektörünü basamak giriş işareti ile birlikte kullanarak x(t)bağıntısının sağ tarafında verilen konvülasyon integralinihesaplayınız.
12/19/2017
22
Chapter 5-43
Devam...
Elde edilen bu zorlanmış çözüm daha önce elde edilen çözümle aynıdır. Toplamçözümü elde etmek için durum geçiş matrisinin sıfır giriş kısmındaki F(t)x(0)çözümünün de buna eklenmesi gerekir.
Şu ana kadar yapılan çözümler ya Laplace dönüşümü, ya da Laplace dönüşümüile konvülasyon integralinin birleştirilmesiyle elde edildi. Bu yöntemlerin her ikiside uzun ve hata yapmaya açıktır.
Chapter 5-44
Bütün sistem girişlerinin sıfır olduğu durum için durum denklemleri:
U(t)=0
Böylece;
Denkleminde U(s)=0 yani u(t)=0 için
Denkleminin çözümü bir vektör olarak elde edilir. Öğle ki vektöraşağıdaki gibi bir seriyle ifade edilebilir.
12/19/2017
23
Chapter 5-45
Ai : Bilinmeyen katsayılar
t : zaman ölçeği
Bu denklemin türevi alınırsa;
Chapter 5-46
Şimdi aşağıdaki işlemleri gerçekleştirelim:
v Yukardaki son denklemi t=0 için elde edelim
v Bu son denklemin türevini alıp, sonucu t=0 için yazalım
v Tekrar türevini alıp, t=0 için yeniden yazalım
v Bu işlemin her tekrarlanmasında bilinmeyen Ai matrisinde birdenklem elde edilir.
v Bu işlemin etkisiyle yukarıdaki son denklemde ti katsayılarıeşitlenmektedir.
12/19/2017
24
Chapter 5-47
Bu işlemler yapılırsa:t=0
Türev alıp, t=0 için düzenlenirse
Tekrar türev alıp, t=0 için düzenlenirse
T=0 için aşağıdaki denklem yeniden yazılırsa;
Olduğu görülür. Ve diğer matrislerbağıntısından elde edilir.
Chapter 5-48
Olarak elde edilince, Olarakbelirlenir.
Böylece durum geçiş matrisi aşağıdaki gibiyazılabilir.
Bu ifade Taylor serisine benzemekte olup, skaler bir exponansiyel olarak ifadeedilebilir.
Kullanılan notasyona uygun olması bakımından durum geçiş matrisi için;
Yazılabilir.
12/19/2017
25
Chapter 5-49
Serisinin sonlu bir sayıda sıfır olmayan terimlere sahip olduğu durum için transferfonksiyonu
Olan bir sistemi ele alalım.
Verilen sistem aşağıdaki işaret akış grafiği ile temsil edilebilir.
U(s) Y(s)
Böylece durum denklemleri:
Chapter 5-50
Devam...U(s) Y(s)
Şekilden:
Benzer şekilde;
12/19/2017
26
Chapter 5-51
Devam...Böylece
denkleminden
Durum geçiş matrisi;
Bu örnekte durum geçiş matrisi kolayca elde edildi. Ancak her zamanböyle kolay olmayabilir.
Chapter 5-52
İkinci dereceden bir sistem aşağıdaki matrislerle temsiledilmektedir.
Aşağıdaki koşullar için çözümleri bulunuz.
12/19/2017
27
Chapter 5-53
Önce durum geçiş matrisi hesaplanmalı.
Chapter 5-54
Devam...
12/19/2017
28
Chapter 5-55
Aşağıdaki sistem için F(t) durum geçiş matrisini hesaplayınız.
Olduğuna göre
Chapter 5-56
Devam...
% state_trans.m% State trans. matr.A=[0 1; -2 -3];t = sym('t');STM = expm(A * t)
12/19/2017
29
Chapter 5-57
% MATLAB Program› kontrol1.m% transfer fonksiyonundan% durum degiskenlerine donusum% pay ve payda verilerinum=[2 8 6];den=[1 8 16 6];[A,B,C,D]=tf2ss(num,den);printsys(A,B,C,D)
» kontrol1a =
x1 x2 x3x1 -8.00000 -16.00000 -6.00000
x2 1.00000 0 0x3 0 1.00000 0
b =u1
x1 1.00000x2 0x3 0
c =x1 x2 x3
y1 2.00000 8.00000 6.00000d =
u1y1 0
Chapter 5-58
% kontrol2.m% Durum matrisi ve% diger verilerA=[0 -2; 1 -3]; B=[2;0];C=[1 0]; D=[0];dt=0.2;DGM=expm(A*dt);DGM
» kontrol2
DGM =
0.9671 -0.29680.1484 0.5219
12/19/2017
30
Chapter 5-59
% program kontrol3.m% lsim fonksiyonu ile durumlarin% ve cikisin elde edilmesi% Durum matrisi ve diger verilerA=[0 -2; 1 -3]; B=[2;0]; C=[1 0];D=[0];x0=[1 1];t=[0:0.01:1];u=0*t;[y,x]=lsim(A,B,C,D,u,t,x0);subplot(211), plot(t,x(:,1))xlabel('time[sec]'), ylabel('x1')subplot(212), plot(t,x(:,2))xlabel('time[sec]'), ylabel('x2')
lsim fonksiyonu
Chapter 5-60
Aralarında yay bulunan iki kütleli bir sistemin simülasyonu(ref. Modern Control Systems by Dorf and Bishop page 160)ÖRNEK
% program Ornek01.m% Ornek simulasyon programi .Aralarinda yay bulunan iki kutleli bir sistem% Model parametreleriM1=0.02; M2=0.0005;b1=410e-03; b2=4.1e-03; k=10;t=[0:0.001:1.5];% durum degisken modeli verileriA=[ 0 0 1 0;
0 0 0 1;-k/M1 k/M1 -b1/M1 0;k/M2 -k/M2 0 -b2/M2 ];
B=[0; 0; 1/M1; 0]; C=[0 0 0 1]; D=0;u=1; % Birim basamak simulasyonuy=step(A,B,C,D,u,t);plot(t,y)xlabel('time[sec]'), ylabel('hareket hizi (m/s)')grid
birimlerk : kg/mb : kg/m/sm : kg
12/19/2017
31
Chapter 5-61
Aralarında yay bulunan iki kütleli bir sisteminsimülasyonu (ref. Modern Control Systems by Dorfand Bishop page 160)
ÖRNEK
Chapter 5-62
Sürekli Miknatisli Dogru Akim motorununSimulasyonu - 01ÖRNEK
% Program Kontrl04.m% PMDC motor denklemleri% verilerVa=36; Ia=15; Inl=1.62;Ra=1.4; La=0.00805; Ka=0.095;Km=Ka; Nn=3400;Bm=4.31e-4; Jm=7.432e-4;K0=0.106309; K1=8.4e-5;K2=1.1e-6;A=[ -(Ra/La) -(Ka/La)
Km/Jm -(Bm/Jm) ];B=[ 1/La 0
0 -(1/Jm) ];
» kontrl04» AA =
-173.9130 -11.8012127.8256 -0.5799
» BB =
1.0e+003 *0.1242 0
0 -1.3455
12/19/2017
32
Chapter 5-63
Sürekli Miknatisli Dogru Akim motorununSimulasyonu - 02ÖRNEK
% PMDC motor denetimsiz tepkesi% verilerVa=36; Ia=15; Inl=1.62; Nn=3400;Ra=1.4; La=0.00805; Ka=0.095; Km=Ka;Bm=4.31e-4; Jm=7.432e-4;K0=0.106309; K1=8.4e-5; K2=1.1e-6;A=[ -(Ra/La) -(Ka/La)
Km/Jm -(Bm/Jm) ];B=[ 1/La; 0]; C=[0 1]; D=[0 ] ;TL=0;% Birim basamak simulasyonuu=1; t=[0:0.01:2];y=step(A,B,C,D,u,t);plot(t,y,'r')xlabel('ZAMAN (s)');ylabel('Motor Hizi (rad/s)')
Chapter 5-64
Sürekli Miknatisli Dogru Akim motorununSimulasyonu - 02ÖRNEK
Jm=7. 432´10-4
12/19/2017
33
Chapter 5-65
Sürekli Miknatisli Dogru Akim motorununSimulasyonu - 02ÖRNEK
Jm=7. 432´10-6
Chapter 5-66
Sürekli Miknatisli Dogru Akim motorununSimulasyonu - 02ÖRNEK
Jm=7. 432´10-3
12/19/2017
34
Chapter 5-67
SÜREKLI MIKNATISLI DA MOTORUNUNZAMAN TEPKELERI
% Program Kontrl04.m% PMDC motor denetimsiz tepkesi. Transfer Fonksiyonu (TL=0 icin)% Birim basamak tepkesi, Birim darbe tepkesi, birim rampa tepkesi% verilerVa=36; Ia=15; Inl=1.62; Nn=3400;Ra=1.0; La=0.08; Ka=0.095; Km=Ka; %La=0.00805; Bm=4.31e-4;Jm=7.432e-4; % Jm=7.432e-6; % Jm=7.432e-3;K0=0.106309; K1=8.4e-5; K2=1.1e-6;A=[ -(Ra/La) -(Ka/La)
Km/Jm -(Bm/Jm) ];B=[ 1/La; 0 ]; C=[0 1]; D=[0 ] ; TL=0;
Chapter 5-68
[num, den]=ss2tf(A,B,C,D); % Transfer fonksiyonu% Bulunan transfer fonkiyonu:% num = 1597.8; den = S^2 +13.0799 S + 159.0420% Birim basamak tepkesi
u=1; t=[0:0.01:1];[ys1,xs1,ts1]=step(A,B,C,D,u,t);[ys2,xs2,ts2]=step(num,den,t);
% Birim darbe tepkesi[yi1,xi1,ti1]=impulse(A,B,C,D);[yi2,xi2,ti2]=impulse(num,den,t);
% Birim rampa tepkesinum2=[0 num]; den2=[den 0];[yr1,xr1,tr1]=step(num2,den2,t);AA=[A zeros(2,1);C 0]; BB=[B;0];CC=[0 0 1]; DD=0; % y=x3=z alinirsa[yr2,xr2,tr2]=step(AA,BB,CC,DD);
SÜREKLI MIKNATISLI DA MOTORUNUNZAMAN TEPKELERI
12/19/2017
35
Chapter 5-69
% Grafiklersubplot(211)plot(ts1,ys1)xlabel('ZAMAN (s)'); title('Birim Basamak Tepkesi (rad/s)'); gridsubplot(212)plot(ts2,ys2); xlabel('ZAMAN (s)'); title('Birim Basamak Tepkesi (rad/s)'); grid;pausesubplot(211)plot(ti1,yi1); xlabel('ZAMAN (s)'); title('Birim Darbe Tepkesi (rad/s)'); gridsubplot(212)plot(ti2,yi2); xlabel('ZAMAN (s)'); title('Birim Darbe Tepkesi (rad/s)'); grid;pausesubplot(211)plot(tr1,yr1,'o',t,t,'-'); xlabel('ZAMAN (s)'); title('Birim Rampa Tepkesi (rad/s)');gridsubplot(212)plot(tr2,yr2,'o',t,t,'-'); xlabel('ZAMAN (s)'); title('Birim Rampa Tepkesi (rad/s)'); grid
SÜREKLI MIKNATISLI DA MOTORUNUNZAMAN TEPKELERI
Chapter 5-70
SÜREKLI MIKNATISLI DA MOTORUNUNZAMAN TEPKELERI
12/19/2017
36
Chapter 5-71
SÜREKLI MIKNATISLI DA MOTORUNUNZAMAN TEPKELERI
Chapter 5-72
SÜREKLI MIKNATISLI DA MOTORUNUNZAMAN TEPKELERI
12/19/2017
37
Chapter 5-73
SÜREKLI MIKNATISLI DA MOTORUNUNHIZ ve KONUM KONTROLÜ
PMDC Motor kontrol simülasyonu
PID Controller
Chapter 5-74
SÜREKLI MIKNATISLI DA MOTORUNUNHIZ ve KONUM KONTROLÜ
12/19/2017
38
Chapter 5-75
SÜREKLI MIKNATISLI DA MOTORUNUNHIZ ve KONUM KONTROLÜ
Chapter 5-76
SÜREKLI MIKNATISLI DA MOTORUNUNHIZ ve KONUM KONTROLÜ
12/19/2017
39
Chapter 5-77
Controllability
andObservability
Chapter 5-78
Controllability and Observability
v A system is said to be completely controllable ifthere exists a control input transferring any statevariable to a desired final location; otherwise thesystem is uncontrollable.
v A system is said to be completely observable ifthe initial state vector x(t0) can be found usingcontrol input u(t) and measured output y(t);otherwise the system is unobservable.
Basic Definitions
12/19/2017
40
Chapter 5-79
Controllability
(a) (b)
-a2
-a3
-a1
u
x1
x2
x3
y
-a5
-a6
-a4
u
x1
x2
x3
y
x.1
x.2
x.3
x1
x2
x3
=
-a1 0 0
0 -a2 0
0 0 -a3
+
111
ux.
1x.
2x.
3
x1
x2
x3
=
-a4
0 00 -a
5 00 0 -a
6
+
011
u
UncontrollableControllable
Chapter 5-80
Controllability
is controllability matrix.
An nth order plant
is completely controllable if the matrix
is of rank n where
det( ) is nonzero.
x = Ax + Bu.
Pc =[B AB A B … A B2 n-1
Pc
Pc
12/19/2017
41
Chapter 5-81
Controllability
The state equation for a system is given above. Determine whether the systemis controllable.
Determinant of = -48Rank of is 3
% contr_matr.mA=[-1 2 00 -2 00 0 -3]B=[0;2;3]Pm=ctrb(A,B)Rank=rank(Pm)Det=det(Pm)
Controllable
x = Ax + Bu =. x
-1 2 00 -2 00 0 -3
+023
u
0 4 -122 -4 83 -9 27
Pc =[B AB A B] =2
PcPc
Chapter 5-82
Observability
(a) (b)
-a2
-a3
-a1
u
x1
x2
x3
y
-a5
-a6
-a4
u
x1
x2
x3
y
x1
x2
x3
= 1 1 1y=Cx x1
x2
x3
= 0 1 1y=Cx
Observable Unobservable
12/19/2017
42
Chapter 5-83
Observability
is controllability matrix.
An nth order plant
is completely observable if the matrix
is of rank n where
det( ) is nonzero.
x = Ax + Bu.
Po
Po
y = Cx
P =o
CCA
.
.
.
CAn-1
Po
Chapter 5-84
Observability
The state equation for a system is given above. Determine whether the systemis observable.
% obs_matr.mA=[0 1 00 0 1
-1 -2 -3]C=[0 4 1]Po=obsv (A,C)Rank=rank(Po)Det=det(Po)
Observable
x = Ax + Bu =. x
0 1 00 0 1
-1 -2 -3+
012
u
0 4 1-1 -2 1-1 -3 -5
0 4 1y = Cx =
Determinant of = -23Rank of is 3Po
Po
P =o
CCACA
2 =