Karadeniz Technical University Department of Electrical and Electronics Engineering 61080 Trabzon, Turkey Chapter 5-1 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şka yerlerde kullanılması, yayınlanması Prof. Dr. İsmail H. ALTAŞ ın yazılı iznine tabidir. Aksi durumlarda yasal işlem yapılacaktır. Chapter 5-2
Mechanical System d 2x M dt 2 = u - f - s f = u - k b dx x - B dt, or d 2x dx M + B + k x = u dt 2 dt Laplace transform; Ms 2X ( s) + BsX( s) + k X( s) = U( s) k x(t) M B u(t) 1 X( s) = 2 U( s) Ms + Bs+ k Transfer Fonksiyonu: G(s) Chapter 5-3 RLC Circuit v i = å Voltage of each element di 1 = R i + L + ò i dt dt C Using Laplace transform 1 V i ( s ) = R I( s) + Ls I ( s) + Cs Solve for I(s) s I( s) = V ( s) = i 2 1 Ls + Rs + C Transfer fonksiyon, G(s) I ( s) G( s) V ( s) i v i R i L C v o Chapter 5-4
RLC Circuit Mechanical system 1 X( s) = 2 U( s) Ms + Bs+ k Electrical system Similarities between mechanical and electrical elements L <=> M R <=> B 1/C <=> k Chapter 5-5 Mechanical System x(t) k M B u(t) 1 X( s) = 2 U( s) Ms + Bs+ k Differential equation Transfer function Chapter 5-6
Mechanical System One 2nd order LTI diff. Eq. can be written as two 1st order LTI diff. Eq. Chapter 5-7 Mechanical System State vector A: System matrix B: Input matrix C: Output matrix Output variable State variables Chapter 5-8
Simulation Diagrams y(t) X(s) Y(s) X(s) Y(s) X(s) s -1 Y(s) Chapter 5-9 Transfer Function to Simulation Diagram U(s) Y(s) U(s) 1 D(s) Z(s) Y(s) Chapter 5-10
Transfer Function to Simulation Diagram EXAMPLE (Initial conditions are zero) Chapter 5-11 Transfer Function to Simulation Diagram EXAMPLE State Equations Output equation Chapter 5-12
Transfer Function to Simulation Diagram EXAMPLE + + + + Control Canonical form Chapter 5-13 Transfer Function to Simulation Diagram From Figure + + + + Chapter 5-14
Transfer Function to Simulation Diagram Multiply by The type of this TF is similar to the obtained using Mason s gain Formula as described below. Chapter 5-15 Transfer Function to Simulation Diagram Mason s gain Formula M Δ i D i : : : Product of the ith foward path gains 1 the loops remaining after removing path i. If none remain, then Δi = 1. 1 -(S all individual loop gains + (Snontouching loop gains taken two at a time.) -(Snontouching loop gains taken three at a time) +... Chapter 5-16
Transfer Function to Simulation Diagram So we have, We have 3 paths from input to output u y Chapter 5-17 Transfer Function to Simulation Diagram u y + + + + + + + Chapter 5-18
Transfer Function to Simulation Diagram Denominator of the transfer function 0 y Chapter 5-19 Transfer Function to Simulation Diagram y + + + - - - Chapter 5-20
Transfer Function to Simulation Diagram Block diagram representing the nominator Block diagram representing the denominator + + + + + + + - - - + + + Get the complete block diagram by combining these two diagrams. Chapter 5-21 Transfer Function to Simulation Diagram + + + Observer Canonical form x 3 + x 2 + x 1 - - - Chapter 5-22
Observer Canonical form From figure: Transfer Function to Simulation Diagram + + + + + x 3 x 2 - - - x 1 State equations Chapter 5-23 Transfer Function to Simulation Diagram Control canonical form Two different simulation diagram The number of simulation diagrams is n Observer canonical form Two different state equations Chapter 5-24
For a SISO system. State-Space to Transfer Function U(s) Y(s) Chapter 5-25 For a SISO system. State-Space to Transfer Function alınırsa Chapter 5-26
State-Space to Transfer Function Chapter 5-27 State-Space to Transfer Function Example Matrices A, B, C and D are given below. Obtain the poles, zeros, characteristic equation, and the transfer function of this system. Solution Chapter 5-28
State-Space to Transfer Function Example Chapter 5-29 State-Space to Transfer Function Example Transfer function Zeros: -(-2+j1.7321) -(-2-j1.7321) Characteristic Equation: Poles: -1 ve -2 Chapter 5-30
State-Space to Transfer Function Example state_tf.m file % From State space % to transfer function A=[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) Matlab command window >>state_tf <enter> num = 1 4 7 den = 1 3 2 zeros = -2.0000 + 1.7321i -2.0000-1.7321i poles = -2-1 Chapter 5-31 Review following topics and solve the problems given. Solution of the state equations using Laplace transformation. Solution of the state transition matrix using inverse Laplace transformation. 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 state equations of this system and obtain the values of x((t) using the methods described above. Chapter 5-32
The state equations of a system are obtained from its differential equations or transfer function. Various methods are applied to solve the state equations. Chapter 5-33 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 and combined, the general form given below is obtained. Let us write this equation for X(s); Chapter 5-34
The state vector x(t) is obtained by getting the Inverse Laplace Transformation. DURUM GEÇİŞ MATRİSİ Chapter 5-35 (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. Chapter 5-36
A transfer function is given above. Write the state equations of this system in observer canonical form and solve for the state variables. Chapter 5-37 continued... State transition matrix: Chapter 5-38
Continued... Solve the second part of the general solution equation for a unit step (u(t)=1) input. Chapter 5-39 Continued... Then The solution: Chapter 5-40
The inverse Laplace transform of the product of two terms in s-domain can be expressed as a convulation integral. The solution with the Convulation theorem can be written as follows: The state transition matrix acts as a centre in solution of the state equations. Zero input (includes the initial values) Zero state depends on inputs. (forced solution) Chapter 5-41 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 integralini hesaplayınız. Chapter 5-42
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 ikisi de uzun ve hata yapmaya açıktır. Chapter 5-43 Bütün sistem girişlerinin sıfır olduğu durum için durum denklemleri: Böylece; U(t)=0 Denkleminde U(s)=0 yani u(t)=0 için Denkleminin çözümü bir vektör olarak elde edilir. Öğle ki vektör aşağıdaki gibi bir seriyle ifade edilebilir. Chapter 5-44
A i : Bilinmeyen katsayılar t : zaman ölçeği Bu denklemin türevi alınırsa; Chapter 5-45 Ş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 A i matrisinde bir denklem elde edilir. v Bu işlemin etkisiyle yukarıdaki son denklemde ti katsayıları eşitlenmektedir. Chapter 5-46
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 matrisler bağıntısından elde edilir. Chapter 5-47 Olarak elde edilince, Olarak belirlenir. Böylece durum geçiş matrisi aşağıdaki gibi yazılabilir. Bu ifade Taylor serisine benzemekte olup, skaler bir exponansiyel olarak ifade edilebilir. Kullanılan notasyona uygun olması bakımından durum geçiş matrisi için; Yazılabilir. Chapter 5-48
Serisinin sonlu bir sayıda sıfır olmayan terimlere sahip olduğu durum için transfer fonksiyonu 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-49 Devam... U(s) Y(s) Şekilden: Benzer şekilde; Chapter 5-50
Devam... Böylece denkleminden Durum geçiş matrisi; Bu örnekte durum geçiş matrisi kolayca elde edildi. Ancak her zaman böyle kolay olmayabilir. Chapter 5-51 İkinci dereceden bir sistem aşağıdaki matrislerle temsil edilmektedir. Aşağıdaki koşullar için çözümleri bulunuz. Chapter 5-52
Önce durum geçiş matrisi hesaplanmalı. Chapter 5-53 Devam... Chapter 5-54
Aşağıdaki sistem için F(t) durum geçiş matrisini hesaplayınız. Olduğuna göre Chapter 5-55 Devam... % state_trans.m % State trans. matr. A=[0 1; -2-3]; t = sym('t'); STM = expm(a * t) Chapter 5-56
% MATLAB Program kontrol1.m % transfer fonksiyonundan % durum degiskenlerine donusum % pay ve payda verileri num=[2 8 6]; den=[1 8 16 6]; [A,B,C,D]=tf2ss(num,den); printsys(a,b,c,d)» kontrol1 a = x1 x2 x3 x1-8.00000-16.00000-6.00000 x2 1.00000 0 0 x3 0 1.00000 0 b = c = d = u1 x1 1.00000 x2 0 x3 0 x1 x2 x3 y1 2.00000 8.00000 6.00000 u1 y1 0 Chapter 5-57 % kontrol2.m % Durum matrisi ve % diger veriler A=[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.2968 0.1484 0.5219 Chapter 5-58
lsim fonksiyonu % program kontrol3.m % lsim fonksiyonu ile durumlarin % ve cikisin elde edilmesi % Durum matrisi ve diger veriler A=[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') Chapter 5-59 ÖRNEK Aralarında yay bulunan iki kütleli bir sistemin simülasyonu (ref. Modern Control Systems by Dorf and Bishop page 160) % program Ornek01.m % Ornek simulasyon programi.aralarinda yay bulunan iki kutleli bir sistem % Model parametreleri M1=0.02; M2=0.0005; b1=410e-03; b2=4.1e-03; k=10; t=[0:0.001:1.5]; % durum degisken modeli verileri A=[ 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 simulasyonu y=step(a,b,c,d,u,t); plot(t,y) xlabel('time[sec]'), ylabel('hareket hizi (m/s)') grid birimler k : kg/m b : kg/m/s m : kg Chapter 5-60
ÖRNEK Aralarında yay bulunan iki kütleli bir sistemin simülasyonu (ref. Modern Control Systems by Dorf and Bishop page 160) Chapter 5-61 ÖRNEK % Program Kontrl04.m % PMDC motor denklemleri % veriler Va=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) ]; Sürekli Miknatisli Dogru Akim motorunun Simulasyonu - 01» kontrl04» A A = -173.9130-11.8012 127.8256-0.5799» B B = 1.0e+003 * 0.1242 0 0-1.3455 Chapter 5-62
Sürekli Miknatisli Dogru Akim motorunun ÖRNEK Simulasyonu - 02 % PMDC motor denetimsiz tepkesi % veriler Va=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 simulasyonu u=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-63 ÖRNEK Sürekli Miknatisli Dogru Akim motorunun Simulasyonu - 02 J m =7. 432 10-4 Chapter 5-64
ÖRNEK Sürekli Miknatisli Dogru Akim motorunun Simulasyonu - 02 J m =7. 432 10-6 Chapter 5-65 ÖRNEK Sürekli Miknatisli Dogru Akim motorunun Simulasyonu - 02 J m =7. 432 10-3 Chapter 5-66
SÜREKLI MIKNATISLI DA MOTORUNUN ZAMAN TEPKELERI % Program Kontrl04.m % PMDC motor denetimsiz tepkesi. Transfer Fonksiyonu (TL=0 icin) % Birim basamak tepkesi, Birim darbe tepkesi, birim rampa tepkesi % veriler Va=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-67 SÜREKLI MIKNATISLI DA MOTORUNUN ZAMAN TEPKELERI [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 tepkesi num2=[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); Chapter 5-68
SÜREKLI MIKNATISLI DA MOTORUNUN ZAMAN TEPKELERI % Grafikler subplot(211) plot(ts1,ys1) xlabel('zaman (s)'); title('birim Basamak Tepkesi (rad/s)'); grid subplot(212) plot(ts2,ys2); xlabel('zaman (s)'); title('birim Basamak Tepkesi (rad/s)'); grid;pause subplot(211) plot(ti1,yi1); xlabel('zaman (s)'); title('birim Darbe Tepkesi (rad/s)'); grid subplot(212) plot(ti2,yi2); xlabel('zaman (s)'); title('birim Darbe Tepkesi (rad/s)'); grid;pause subplot(211) plot(tr1,yr1,'o',t,t,'-'); xlabel('zaman (s)'); title('birim Rampa Tepkesi (rad/s)');grid subplot(212) plot(tr2,yr2,'o',t,t,'-'); xlabel('zaman (s)'); title('birim Rampa Tepkesi (rad/s)'); grid Chapter 5-69 SÜREKLI MIKNATISLI DA MOTORUNUN ZAMAN TEPKELERI Chapter 5-70
SÜREKLI MIKNATISLI DA MOTORUNUN ZAMAN TEPKELERI Chapter 5-71 SÜREKLI MIKNATISLI DA MOTORUNUN ZAMAN TEPKELERI Chapter 5-72
SÜREKLI MIKNATISLI DA MOTORUNUN HIZ ve KONUM KONTROLÜ PMDC Motor kontrol simülasyonu PID Controller Chapter 5-73 SÜREKLI MIKNATISLI DA MOTORUNUN HIZ ve KONUM KONTROLÜ Chapter 5-74
SÜREKLI MIKNATISLI DA MOTORUNUN HIZ ve KONUM KONTROLÜ Chapter 5-75 SÜREKLI MIKNATISLI DA MOTORUNUN HIZ ve KONUM KONTROLÜ Chapter 5-76
Controllability and Observability Chapter 5-77 Controllability and Observability Basic Definitions v A system is said to be completely controllable if there exists a control input transferring any state variable to a desired final location; otherwise the system is uncontrollable. v A system is said to be completely observable if the initial state vector x(t0) can be found using control input u(t) and measured output y(t); otherwise the system is unobservable. Chapter 5-78
Controllability - x1 - x1 a1 a4 u - x2 y u - x2 y a2 a5 - x3 - x3 a3 (a) Controllable a6 (b) Uncontrollable ẋ 1 ẋ 2 ẋ 3 = -a 1 0 0 x 1 x 2 x 3 0 -a 2 0 + 0 0 -a 3 1 1 1 u ẋ 1 ẋ 2 ẋ 3 = -a 4 0 0 x 1 x 2 x 3 0 -a 5 0 + 0 0 -a 6 0 1 1 u Chapter 5-79 An nth order plant Controllability. x = Ax + Bu is completely controllable if the matrix 2 n-1 P c =[B AB A B A B is of rank n where P c is controllability matrix. det( P c ) is nonzero. Chapter 5-80
Controllability. x = Ax + Bu = -1 2 0 0-2 0 0 0-3 x + 0 2 3 u The state equation for a system is given above. Determine whether the system is controllable. Controllable % contr_matr.m A=[-1 2 0 0-2 0 0 0-3] B=[0;2;3] Pm=ctrb(A,B) Rank=rank(Pm) Det=det(Pm) 2 P c =[B AB A B]= 0 4-12 2-4 8 3-9 27 Rank of P is 3 c Determinant of P = -48 c Chapter 5-81 Observability - x1 - x1 a1 a4 u - x2 y u - x2 y a2 a5 - x3 - x3 a3 (a) Observable a6 (b) Unobservable y=cx = 1 1 1 y=cx = 0 1 1 x 1 x 1 x 2 x 3 x 2 x 3 Chapter 5-82
An nth order plant Observability is completely observable if the matrix is of rank n where P o. x = Ax + Bu y = Cx P o is controllability matrix. det( P o ) is nonzero. P = o C CA... CA n-1 Chapter 5-83 Observability. x = Ax + Bu = 0 1 0 0 0 1-1 -2-3 x + 0 1 2 u y=cx = 0 4 1 The state equation for a system is given above. Determine whether the system is observable. Observable % obs_matr.m A=[0 1 0 0 0 1-1 -2-3] C=[0 4 1] Po=obsv (A,C) Rank=rank(Po) Det=det(Po) P = o C 0 4 1 CA -1-21 CA 2 = -1-3 -5 Rank of P is 3 o Determinant of P = -23 o Chapter 5-84