Sie sind auf Seite 1von 103

Scilab Textbook Companion for Automatic Control Systems by B. C. Kuo And F.

Golnaraghi 1
Created by Arpita V Huddar B.Tech (pursuing) Electronics Engineering NIT Karnataka College Teacher S.Rekha Cross-Checked by Sonanya Tatikola, IITB August 9, 2013

by a grant from the National Mission on Education through ICT, http://spoken-tutorial.org/NMEICT-Intro. This Textbook Companion and Scilab codes written in it can be downloaded from the Textbook Companion Project section at the website http://scilab.in

1 Funded

Book Description
Title: Automatic Control Systems Author: B. C. Kuo And F. Golnaraghi Publisher: Princton Hall Of India Private Limited, New Delhi Edition: 7 Year: 1995 ISBN: 81-203-0968-5

Scilab numbering policy used in this document and the relation to the above book. Exa Example (Solved example) Eqn Equation (Particular equation of the above book) AP Appendix to Example(Scilab Code that is an Appednix to a particular Example of the above book) For example, Exa 3.51 means solved example 3.51 of this book. Sec 2.3 means a scilab code whose theory is explained in Section 2.3 of the book.

Contents
List of Scilab Codes 2 Mathematical Foundation 3 Transfer Functions Block Diagrams and Signal Flow Graphs 4 Mathematical Modelling of Physical Systems 5 State Variable Analysis 6 Stability of Linear Control Systems 7 Time Domain Analysis of Control Systems 8 Root Locus Technique 9 Frequency Domain Analysis 4 9 18 26 31 37 44 53 81

List of Scilab Codes


Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa 2.1 2.2 2.3 2.4 2.5 2.7 2.8 2.9 2.10 2.12 2.13 2.14 2.15 2.16 2.17 2.18 2.19 2.20 2.21 2.22 2.23 2.25 3.1 3.3 3.4 3.5 3.6 3.7 laplace transform of step function . . . . . . . . . . laplace transform of exponential function . . . . . nal value thereom . . . . . . . . . . . . . . . . . . inverse laplace . . . . . . . . . . . . . . . . . . . . partial fractions . . . . . . . . . . . . . . . . . . . inverse laplace transform . . . . . . . . . . . . . . inverse laplace transform . . . . . . . . . . . . . . inverse laplace transform . . . . . . . . . . . . . . determinant of matrix . . . . . . . . . . . . . . . . transpose of matrix . . . . . . . . . . . . . . . . . adjoint of matrix . . . . . . . . . . . . . . . . . . . equality of matrices . . . . . . . . . . . . . . . . . addition of matrices . . . . . . . . . . . . . . . . . conformability for multiplication of matrices . . . . multiplication of matrices . . . . . . . . . . . . . . inverse of 2x2 matrix . . . . . . . . . . . . . . . . . inverse of 3x3 matrix . . . . . . . . . . . . . . . . . rank of a matrix . . . . . . . . . . . . . . . . . . . z transform . . . . . . . . . . . . . . . . . . . . . . z transform . . . . . . . . . . . . . . . . . . . . . . z transform . . . . . . . . . . . . . . . . . . . . . . nal value thereom . . . . . . . . . . . . . . . . . . closed loop transfer function matrix . . . . . . . . masons gain formula applied to SFG in gure 3 15 masons gain formula . . . . . . . . . . . . . . . . . masons gain formula . . . . . . . . . . . . . . . . . masons gain formula . . . . . . . . . . . . . . . . . masons gain formula . . . . . . . . . . . . . . . . . 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 9 9 10 10 11 11 11 12 12 12 13 13 14 14 15 15 16 16 17 17 17 18 18 19 20 21 21

Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa

3.9 3.10 3.11 4.1 4.2 4.3 4.4 4.5 4.9 5.1 5.7 5.8 5.9 5.12 5.13 5.14 5.18 5.19 5.20 5.21 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 6.10 7.1 7.2 7.3 7.4 7.5 7.6 8.1 8.2

masons gain formula . . . . . . . . . . . . . . . . masons gain formula . . . . . . . . . . . . . . . . masons gain formula . . . . . . . . . . . . . . . . transfer fnuction of system . . . . . . . . . . . . transfer fnuction of electric network . . . . . . . gear trains . . . . . . . . . . . . . . . . . . . . . mass spring system . . . . . . . . . . . . . . . . . mass spring system . . . . . . . . . . . . . . . . . incremental encoder . . . . . . . . . . . . . . . . state transition equation . . . . . . . . . . . . . . characteristic equation from transfer function . . characteristic equation from state equation . . . eigen values . . . . . . . . . . . . . . . . . . . . . ccf form . . . . . . . . . . . . . . . . . . . . . . . ocf form . . . . . . . . . . . . . . . . . . . . . . . dcf form . . . . . . . . . . . . . . . . . . . . . . . system with identical eigen values . . . . . . . . controllability . . . . . . . . . . . . . . . . . . . . controllability . . . . . . . . . . . . . . . . . . . . observability . . . . . . . . . . . . . . . . . . . . stability of open loop systems . . . . . . . . . . . rouths tabulation to determine stability . . . . . rouths tabulation to determine stability . . . . . rst element in any row of rouths tabulation is z elements in any row of rouths tabulations are all determining critical value of K . . . . . . . . . . determining critical value of K . . . . . . . . . . stability of closed loop systems . . . . . . . . . . bilinear transformation method . . . . . . . . . . bilinear transformation method . . . . . . . . . . type of system . . . . . . . . . . . . . . . . . . . steady state errors from open loop tf . . . . . . . steady state errors from closed loop tf . . . . . . steady state errors from closed loop tf . . . . . . steady state errors from closed loop tf . . . . . . steady state errors from closed loop tf . . . . . . poles and zeros . . . . . . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . . . . . . . . . 5

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

22 23 24 26 27 27 28 28 29 31 32 32 32 33 33 34 35 35 35 36 37 38 38 39 39 40 41 42 42 43 44 44 46 47 49 51 53 53

Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa

8.3 8.4 8.5 8.8 8.9 8.10 8.11 8.12 8.13 8.14 8.15 8.16 8.17 8.18 8.19 8.20 8.21 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 9.10 9.14 9.15 9.17

root locus . . . . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . . . . angle of departure and angle of arrivals multiple order pole . . . . . . . . . . . . intersection of root loci with real axis . breakaway points . . . . . . . . . . . . . breakaway points . . . . . . . . . . . . . breakaway points . . . . . . . . . . . . . breakaway points . . . . . . . . . . . . . root sensitivity . . . . . . . . . . . . . . calculation of K on root loci . . . . . . . properties of root loci . . . . . . . . . . eect of addition of poles to system . . eect of addition of zeroes to system . . eect of moving poles near jw axis . . . eect of moving poles awat from jw axis nyquist plot . . . . . . . . . . . . . . . . nyquist plot . . . . . . . . . . . . . . . . stability of non minimum phase loop tf . stability of minimum phase loop tf . . . stability of non minimum phase loop tf . stability of non minimum phase loop tf . stability of non minimum phase loop tf . eect of addition of poles . . . . . . . . eect of addition of zeroes . . . . . . . . multiple loop systems . . . . . . . . . . gain margin and phase margin . . . . . bode plot . . . . . . . . . . . . . . . . . relative stability . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

56 57 58 59 59 61 63 63 65 67 67 68 71 71 72 76 76 81 81 84 86 86 89 89 91 91 94 97 100 100

List of Figures
8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 8.10 8.11 8.12 8.13 8.14 8.15 8.16 8.17 8.18 8.19 8.20 8.21 8.22 9.1 9.2 9.3 9.4 9.5 9.6 poles and zeros . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . . . . angle of departure and angle of arrivals . intersection of root loci with real axis . . breakaway points . . . . . . . . . . . . . breakaway points . . . . . . . . . . . . . breakaway points . . . . . . . . . . . . . breakaway points . . . . . . . . . . . . . root sensitivity . . . . . . . . . . . . . . root sensitivity . . . . . . . . . . . . . . calculation of K on root loci . . . . . . . eect of addition of poles to system . . . eect of addition of poles to system . . . eect of addition of zeroes to system . . eect of addition of zeroes to system . . eect of moving poles near jw axis . . . . eect of moving poles near jw axis . . . . eect of moving poles awat from jw axis eect of moving poles awat from jw axis nyquist plot . . . . . . . . . . . . . . . nyquist plot . . . . . . . . . . . . . . . stability of non minimum phase loop tf stability of minimum phase loop tf . . stability of non minimum phase loop tf stability of non minimum phase loop tf 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 55 56 57 58 60 61 62 64 65 66 68 69 70 72 73 74 75 77 78 79 80 82 83 84 85 87 88

9.7 9.8 9.9 9.10 9.11 9.12 9.13 9.14 9.15

stability of non minimum phase loop tf eect of addition of poles . . . . . . . . eect of addition of poles . . . . . . . . eect of addition of zeroes . . . . . . . eect of addition of zeroes . . . . . . . multiple loop systems . . . . . . . . . . gain margin and phase margin . . . . . bode plot . . . . . . . . . . . . . . . . relative stability . . . . . . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

90 92 93 94 95 96 98 99 101

Chapter 2 Mathematical Foundation

Scilab code Exa 2.1 laplace transform of step function


1 // l a p l a c e t r a n s f o r m o f 2 syms t s 3 y = laplace ( 1 ,t , s ) 4 disp (y , F ( s )= )

unit function

Scilab code Exa 2.2 laplace transform of exponential function


1 2 3 4

// l a p l a c e t r a n s f o r m o f e x p o n e n t i a l f u n c t i o n syms t s ; y = laplace ( %e( 1 t ) ,t , s ) ; disp (y , a n s= )

Scilab code Exa 2.3 nal value thereom


1 2

// f i n a l v a l u e t h e r e o m syms s 9

3 4 5 6 7 8 9

d = poly ([0 2 1 1] , s , c o e f f ) n = poly ([5] , s , c o e f f ) f=n/d; disp (f , F ( s )= ) x=s*f; y = limit (x ,s ,0) ; // f i n a l v a l u e t h e o r e m disp (y , f ( i n f )= )

Scilab code Exa 2.4 inverse laplace


1 // i n v e r s e l a p l a c e 2 syms s 3 F =1/( s ^2+1) //w=1 4 disp (F , F ( s )= ) 5 f = ilaplace ( F ) 6 disp (f , f ( t )= ) 7 printf ( s i n c e s F ( s ) h a s two p o l e s on i m a g i n a r y a x i s

o f s p l a n e , f i n a l v a l u e t h e r e o m c a n n o t be a p p l i e d in t h i s case )

Scilab code Exa 2.5 partial fractions


1 2 3 4 5 6 7

// p a r t i a l f r a c t i o n s n = poly ([3 5] , s , c o e f f ) d = poly ([6 11 6 1] , s , c o e f f ) f=n/d; disp (f , F ( s )= ) pf = pfss ( f ) disp ( pf )

10

Scilab code Exa 2.7 inverse laplace transform


1 2 3 4 5 6 7 8 9 10 11

// i n v e r s e l a p l a c e t r a n s f o r m n = poly ([4] , s , c o e f f ) d = poly ([4 8 1] , s , c o e f f ) G=n/d; disp (G , G( s )= ) pf = pfss ( G ) disp ( pf , G( s )= ) syms s t g1 = ilaplace ( pf (1) ,s , t ) g2 = ilaplace ( pf (2) ,s , t ) disp ( g1 + g2 , g ( t )= )

//w=2 , damping r a t i o =2

Scilab code Exa 2.8 inverse laplace transform


1 2 3 4 5 6 7 8 9 10 11 12 13 14

// i n v e r s e l a p l a c e t r a n s f o r m n = poly ([5 -1 -1] , s , c o e f f ) d = poly ([0 -1 -2] , s , r o o t s ) Y=n/d; disp (Y , Y( s )= ) pf = pfss ( Y ) disp ( pf , Y( s )= ) syms s t y1 = ilaplace ( pf (1) ,s , t ) y2 = ilaplace ( pf (2) ,s , t ) y3 = ilaplace ( pf (3) ,s , t ) disp ( y1 + y2 + y3 , g ( t )= ) l = limit ( Y *s ,s ,0) disp (l , l i m i t o f y ( t ) a s t t e n d s t o i n f i n i t y = )

Scilab code Exa 2.9 inverse laplace transform 11

1 2 3 4 5 6 7 8 9 10 11 12

// i n v e r s e l a p l a c e t r a n s f o r m n = poly ([1000] , s , c o e f f ) d = poly ([0 1000 34.5 1] , s , c o e f f ) Y=n/d; disp (Y , Y( s )= ) pf = pfss ( Y ) disp ( pf , Y( s )= ) syms s t y1 = ilaplace ( pf (1) ,s , t ) y2 = ilaplace ( pf (2) ,s , t ) y3 = ilaplace ( pf (3) ,s , t ) disp ( y1 + y2 + y3 , y ( t )= )

Scilab code Exa 2.10 determinant of matrix


1 // d e t e r m i n a n t o f t h e m a t r i x 2 A =[1 2;3 4] 3 d = det ( A ) 4 disp ( d )

Scilab code Exa 2.12 transpose of matrix


1 // t r a n s p o s e o f a m a t r i x 2 A =[3 2 1;0 -1 5] 3 t =A 4 disp ( t )

Scilab code Exa 2.13 adjoint of matrix


1

// a d j o i n t o f a m a t r i x 12

2 A =[1 2;3 4] 3 i = inv ( A ) 4 a = i .* det ( A ) 5 disp ( a )

Scilab code Exa 2.14 equality of matrices


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

// e q u a l i t y o f m a t r i c e s A =[1 2;3 4] B =[1 2;3 4] x =1; for i =1:2 for j =1:2 if A (i , j ) ~= B (i , j ) then x =0 end end end if x ==1 then disp ( m a t r i c e s a r e e q u a l ) else disp ( m a t r i c e s a r e n o t e q u a l ) end

Scilab code Exa 2.15 addition of matrices


1 // a d d i t i o n o f m a t r i c e s 2 A =[3 2; -1 4;0 -1] 3 B =[0 3; -1 2;1 0] 4 s=A+B 5 disp ( s )

13

Scilab code Exa 2.16 conformability for multiplication of matrices


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

// c o n f o r m a b l i l i t y f o r m u l t i p l i c a t i o n o f m a t r i c e s A =[1 2 3;4 5 6] B =[1 2 3] C = size ( A ) D = size ( B ) if C (1 ,2) == D (1 ,1) then disp ( m a t r i c e s are conformable for m u l t i p l i c a t i o n AB ) else disp ( m a t r i c e s are not conformable f o r m u l t i p l i c a t i o n AB ) end if D (1 ,2) == C (1 ,1) then disp ( m a t r i c e s are conformable for m u l t i p l i c a t i o n BA ) else disp ( m a t r i c e s are not conformable f o r m u l t i p l i c a t i o n BA ) end

Scilab code Exa 2.17 multiplication of matrices


1 2 3 4 5 6 7 8

// m u l t i p l i c a t i o n o f m a t r i c e s A =[3 -1;0 1;2 0] B =[1 0 -1;2 1 0] C = size ( A ) D = size ( B ) if C (1 ,2) == D (1 ,1) then AB = A * B disp ( AB , AB= ) 14

9 10

else disp ( m a t r i c e s are not conformable f o r m u l t i p l i c a t i o n AB )

11 end 12 if D (1 ,2) == C (1 ,1) then 13 BA = B * A 14 disp ( BA , BA= ) 15 else 16 disp ( m a t r i c e s are not conformable

for

m u l t i p l i c a t i o n BA )
17 end

Scilab code Exa 2.18 inverse of 2x2 matrix


1 // i n v e r s e o f 2 X 2 matrix 2 A =[1 2;3 4] 3 d = det ( A ) 4 if det ( A ) ~=0 then 5 i = inv ( A ) 6 disp (i , A1= ) 7 else 8 disp ( i n v e r s e o f a s i n g u l a r

matrix doesnt e x i s t

)
9 end

Scilab code Exa 2.19 inverse of 3x3 matrix


1 // i n v e r s e o f a 3 X 3 m a t r i x 2 A =[1 2 3;4 5 6;7 8 9] 3 d = det ( A ) 4 if det ( A ) ~=0 then 5 i = inv ( A ) 6 disp (i , A1= )

15

7 8

else disp ( i n v e r s e o f a s i n g u l a r m a t r i x d o e s n t e x i s t )

9 end

Scilab code Exa 2.20 rank of a matrix


1 2 3 4 5 6 7 8 9 10 11 12 13

// r a n k o f a m a t r i x A =[0 1;0 1] [E ,Q , Z , stair , rk1 ]= ereduc (A ,1. d -15) disp ( rk1 , r a n k o f A= ) B =[0 5 1 4;3 0 3 2] [E ,Q , Z , stair , rk2 ]= ereduc (B ,1. d -15) disp ( rk2 , r a n k o f B= ) C =[3 9 2;1 3 0;2 6 1] [E ,Q , Z , stair , rk3 ]= ereduc (C ,1. d -15) disp ( rk3 , r a n k o f C= ) D =[3 0 0;1 2 0;0 0 1] [E ,Q , Z , stair , rk4 ]= ereduc (D ,1. d -15) disp ( rk4 , r a n k o f D= )

Scilab code Exa 2.21 z transform


1 // z t r a n s f o r m 2 syms n z ; 3 a =1; 4 x = %e ^ -( a * n ) ; 5 X = symsum ( x *( z ^( - n ) ) ,n ,0 , %inf ) 6 disp (X , a n s= )

16

Scilab code Exa 2.22 z transform


1 // z t r a n s f o r m 2 syms n z ; 3 x =1; 4 X = symsum ( x *( z ^( - n ) ) ,n ,0 , %inf ) 5 disp (X , a n s= )

Scilab code Exa 2.23 z transform


1 2 3 4 5 6 7 8

// z t r a n s f o r m // t=k T syms k z ; a =1; T =1; x = %e ^ -( a * k * T ) ; X = symsum ( x *( z ^( - k ) ) ,k ,0 , %inf ) disp (X , a n s= )

Scilab code Exa 2.25 nal value thereom


1 // f i n a l v a l u e thereom 2 z = %z 3 sys = syslin ( c ,0.792* z ^2/(( z -1) *( z ^2 -0.416* z +0.208) )

)
4 syms z 5 l = limit ( sys *(1 - z ^ -1) ,z ,1) 6 disp (l , l i m i t a s k a p p r o a c h e s

i n f i n i t y = )

17

Chapter 3 Transfer Functions Block Diagrams and Signal Flow Graphs

Scilab code Exa 3.1 closed loop transfer function matrix


1 2 3 4 5 6 7 8 9 10 11

// c l o s e d l o o p t r a n s f e r f u n c t i o n m a t r i x s = %s G =[1/( s +1) -1/ s ;2 1/( s +2) ] H =[1 0;0 1] GH = G * H disp ( GH , G( s )H( s )= ) I =[1 0;0 1] x = I + GH y = inv ( x ) M=y*G disp (M , M( s )= )

Scilab code Exa 3.3 masons gain formula applied to SFG in gure 3 15

18

1 // mason s g a i n f o r m u l a a p p l i e d t o SFG i n f i g u r e 3 15 2 syms G H 3 M1 = G // a s s e e n from SFG t h e r e i s o n l y one 4 L11 = - G * H 5 6 7 8

forward path // o n l y one l o o p and no non t o u c h i n g loops delta =1 - L11 delta1 =1 Y = M1 * delta1 / delta disp (Y , Y( s ) /R( s )= )

Scilab code Exa 3.4 masons gain formula


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

// masons g a i n f o r m u l a a p p l i e d t o SFG i n f i g u r e 3 8(d ) // two f o r w a r d p a t h s syms a12 a23 a24 a25 a32 a34 a43 a44 a45 M1 = a12 * a23 * a34 * a45 M2 = a12 * a25 // f o u r l o o p s L11 = a23 * a32 L21 = a34 * a43 L31 = a24 * a32 * a43 L41 = a44 // one p a i r o f non t o u c h i n g l o o p s L12 = a23 * a32 * a44 delta =1 -( L11 + L21 + L31 + L41 ) +( L12 ) delta1 =1 delta2 =1 -( L21 + L41 ) x =( M1 * delta1 + M2 * delta2 ) / delta disp (x , y5 / y1= ) // i f y2 i s o u t p u t node M1 = a12 delta1 =1 -( L21 + L41 ) y =( M1 * delta1 ) / delta 19

22

disp (y , y2 / y1= )

Scilab code Exa 3.5 masons gain formula


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

// mason s g a i n f o r m u l a a p p l i e d t o SFG i n f i g u r e 3 16 // y2 a s o u t p u t node syms G1 G2 G3 G4 G5 H1 H2 H3 H4 M1 =1 L11 = - G1 * H1 L21 = - G3 * H2 L31 = G1 * G2 * G3 * - H3 L41 = - H4 L12 = G1 * H1 * G3 * H2 L22 = G1 * H1 * H4 L32 = G3 * H2 * H4 L42 = - G1 * G2 * G3 * H3 * H4 L13 = - G1 * H1 * G3 * H2 * H4 delta =1 -( L11 + L21 + L31 + L41 ) +( L12 + L22 + L32 + L42 ) + L13 delta1 =1 -( L21 + L41 ) +( L32 ) x = M1 * delta1 / delta disp (x , y2 / y1= ) // y4 a s o u t p u t node M1 = G1 * G2 delta1 =1 -( L41 ) y = M1 * delta1 / delta disp (y , y4 / y1= ) // y6 o r y7 a s o u t p u t node M1 = G1 * G2 * G3 * G4 M2 = G1 * G5 delta1 =1 delta2 =1 -( L21 ) z =( M1 * delta1 + M2 * delta2 ) / delta disp (z , y6 / y1=y7 / y1= )

20

Scilab code Exa 3.6 masons gain formula


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

// mason s g a i n f o r m u l a a p p l i e d t o SFG i n f i g u r e 3 16 // y2 a s o u t p u t node syms G1 G2 G3 G4 G5 H1 H2 H3 H4 M1 =1 L11 = - G1 * H1 L21 = - G3 * H2 L31 = G1 * G2 * G3 * - H3 L41 = - H4 L12 = G1 * H1 * G3 * H2 L22 = G1 * H1 * H4 L32 = G3 * H2 * H4 L42 = - G1 * G2 * G3 * H3 * H4 L13 = - G1 * H1 * G3 * H2 * H4 delta =1 -( L11 + L21 + L31 + L41 ) +( L12 + L22 + L32 + L42 ) + L13 delta1 =1 -( L21 + L41 ) +( L32 ) x = M1 * delta1 / delta disp (x , y2 / y1= ) // y7 a s o u t p u t node M1 = G1 * G2 * G3 * G4 M2 = G1 * G5 delta1 =1 delta2 =1 -( L21 ) y =( M1 * delta1 + M2 * delta2 ) / delta disp (y , y7 / y1= ) z=y/x // ( y7 / y2 ) =( y7 / y1 ) / ( y2 / y1 ) disp (z , y7 / y2= )

Scilab code Exa 3.7 masons gain formula


1

// b l o c k d i a g r a m i s c o n v e r t e d t o SFG 21

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

// mason s g a i n f o r m u l a a p p l i e d t o SFG i n f i g u r e 3 17 //E a s o u t p u t node syms G1 G2 G3 G4 H1 H2 M1 =1 L11 = - G1 * G2 * H1 L21 = - G2 * G3 * H2 L31 = - G1 * G2 * G3 L41 = - G1 * G4 L51 = - G4 * H2 delta =1 -( L11 + L21 + L31 + L41 + L51 ) delta1 =1 -( L21 + L51 + L11 ) x = M1 * delta1 / delta disp (x , E( s ) /R( s )= ) //Y a s o u t p u t node M1 = G1 * G2 * G3 M2 = G1 * G4 delta1 =1 delta2 =1 y =( M1 * delta1 + M2 * delta2 ) / delta disp (y , Y( s ) /R( s )= )

Scilab code Exa 3.9 masons gain formula


1 2 3 4 5 6 7 8 9 10 11

// f i n d i n g t r a n s f e r f u n c t i o n from s t a t e d i a g r a m by applying gain formula // s t a t e d i a g r a m i s shown i n f i f u r e 3 21 syms s // i n i t i a l c o n d i t i o n s a r e s s e t t o z e r o M1 = s ^ -1* s ^ -1 L11 = -3* s ^ -1 L21 = -2* s ^ -1* s ^ -1 delta =1 -( L11 + L21 ) delta1 =1 x = M1 * delta1 / delta disp (x , Y( s ) /R( s )= ) 22

Scilab code Exa 3.10 masons gain formula


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

// a p p l y i n g g a i n f o r m u l a t o s t a t e d i a g r a m 3 22 // r ( t ) , x1 ( t ) and x2 ( t ) a r e i n p u t n o d e s // y ( t ) i s o u t p u t node // s u p e r p o s i t i o n p r i n c i p l e h o l d s good syms s r x1 x2 // r ( t ) a s i n p u t node and y ( t ) a s o u t p u t node M1 =0 delta1 =1 delta =1 a =( M1 * delta1 ) / delta y1 = a * r disp ( y1 , y1 ( t )= ) // x1 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node M1 =1 delta1 =1 b =( M1 * delta1 ) / delta y2 = b * x1 disp ( y2 , y2 ( t )= ) // x2 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node M1 =0 delta1 =1 c =( M1 * delta1 ) / delta y3 = c * x2 disp ( y3 , y3 ( t )= ) disp ( y1 + y2 + y3 , y ( t )= )

23

Scilab code Exa 3.11 masons gain formula // a p p l y i n g g a i n f o r m u l a t o s t a t e d i a g r a m i n f i g u r e 3 23( b ) 2 // r ( t ) , x1 ( t ) , x2 ( t ) and x3 ( t ) a r e i n p u t n o d e s 3 // y ( t ) i s o u t p u t node 4 // s u p e r p o s i t i o n p r i n c i p l e h o l d s good
1 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

syms s a0 a1 a2 a3 r x1 x2 x3 // r ( t ) a s i n p u t node and y ( t ) a s o u t p u t node M1 =0 delta1 =1 L11 = - a0 * a3 delta =1 -( L11 ) a =( M1 * delta1 ) / delta y1 = a * r disp ( y1 , y1 ( t )= ) // x1 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node M1 =1 delta1 =1 b =( M1 * delta1 ) / delta y2 = b * x1 disp ( y2 , y2 ( t )= ) // x2 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node M1 =0 delta1 =1 c =( M1 * delta1 ) / delta y3 = c * x2 disp ( y3 , y3 ( t )= ) // x3 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node M1 = a0 delta1 =1 d =( M1 * delta1 ) / delta y4 = d * x3 disp ( y4 , y4 ( t )= ) 24

36 37

disp ( y1 + y2 + y3 + y4 , y ( t )= )

25

Chapter 4 Mathematical Modelling of Physical Systems

Scilab code Exa 4.1 transfer fnuction of system


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

// t r a n s f e r f u n c t i o n o f t h e s y s t e m // from s t a t e d i a g r a m i n 4 1(b ) // i n i t i a l c o n d i t i o n s a r e t a k e n a s z e r o // c o n s i d e r i n g v o l t a g e a c r o s s c a p a c i t o r a s o u t p u t syms R L C s = %s M1 =(1/ L ) *( s ^ -1) *(1/ C ) *( s ^ -1) L11 = -( s ^ -1) *( R / L ) delta =1 -( L11 ) delta1 =1 x = M1 * delta1 / delta disp (x , Ec ( s ) /E( s )= ) // c o n s i d e r i n g c u r r e n t i n t h e c i r c u i t a s o u t p u t M1 =(1/ L ) *( s ^ -1) delta1 =1 y = M1 * delta1 / delta disp (y , I ( s ) /E( s )= )

26

Scilab code Exa 4.2 transfer fnuction of electric network


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

// t r a n s f e r f u n c t i o n o f e l e c t r i c n e t w o r k // from s t a t e d i a g r a m i n 4 2(b ) // i n i t a l c o n d i t i o n s a r e t a k e n a s z e r o // c o n s i d e r i n g i 1 a s o u t p u t syms R1 R2 L1 L2 C s = %s M1 =(1/ L1 ) *( s ^ -1) L11 = -( s ^ -1) *( R1 / L1 ) L21 = -( s ^ -1) *(1/ C ) *( s ^ -1) *(1/ L1 ) L31 = -( s ^ -1) *(1/ L2 ) *( s ^ -1) *(1/ C ) L41 = -( s ^ -1) *( R2 / L2 ) L12 = L11 * L31 L22 = L11 * L41 L32 = L21 * L41 delta =1 -( L11 + L21 + L31 + L41 ) +( L12 + L22 + L32 ) delta1 =1 -( L31 + L41 ) x = M1 * delta1 / delta disp (x , I 1 ( s ) /E( s )= ) // c o n s i d e r i n g i 2 a s o u t p u t M1 =(1/ L1 ) *( s ^ -1) *(1/ C ) *( s ^ -1) *(1/ L2 ) *( s ^ -1) delta1 =1 y = M1 * delta1 / delta disp (y , I 2 ( s ) /E( s )= ) // c o n s i d e r i n g v o l t a g e a c r o s s c a p a c i t o r a s o u t p u t M1 =(1/ L1 ) *( s ^ -1) *(1/ C ) *( s ^ -1) delta1 =1 - L41 z = M1 * delta1 / delta disp (z , Ec ( s ) /E( s )= )

Scilab code Exa 4.3 gear trains 27

1 2 3 4 5 6 7 8 9 10 11 12 13

// g e a r t r a i n s printf ( Given \ n i n e r t i a ( J2 ) =0.05 oz i n . s e c 2 \ n f r i c t i o n a l t o r q u e ( T2 ) =2oz i n . \ n N1/N2 ( r ) =1/5 ) J2 =0.05; disp ( J2 , J2= ) T2 =2; disp ( T2 , T2= ) r =1/5 disp (r , N1/N2= ) printf ( J1 =(N1/N2 ) 2 J2 \ n T1=(N1/N2 ) T2 ) J1 =( r ) ^2* J2 ; disp ( J1 , The r e f l e c t e d i n e r t i a on s i d e o f N1= ) T1 =( r ) * T2 disp ( T1 , The r e f l e c t e d coulumb f r i c t i o n i s = )

Scilab code Exa 4.4 mass spring system


1 2 3 4 5 6 7 8 9 10 11 12

// mass s p r i n g s y s t e m // f r e e body d i a g r a m and s t a t e d i a g r a m a r e drawn a s shown i n f i g u r e 4 18( b ) and 4 18( c ) // a p p l y i n g g a i n f o r m u l a t o s t a t e d i a g r a m syms K M B s = %s M1 =(1/ M ) *( s ^ -2) L11 = -( B / M ) *( s ^ -1) L21 = -( K / M ) *( s ^ -2) delta =1 -( L11 + L21 ) delta1 =1 x = M1 * delta1 / delta disp (x , Y( s ) /F ( s )= )

Scilab code Exa 4.5 mass spring system 28

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

// mass s p r i n g s y s t e m // f r e e body d i a g r a m and s t a t e d i a g r a m a r e drawn a s shown i n f i g u r e 4 19( b ) and 4 19( c ) // a p p l y i n g g a i n f o r m u l a t o s t a t e d i a g r a m syms K M B s = %s // c o n s i d e r i n g y1 a s o u t p u t M1 =(1/ M ) L11 = -( B / M ) *( s ^ -1) L21 = -( K / M ) *( s ^ -2) L31 =( K / M ) *( s ^ -2) delta =1 -( L11 + L21 + L31 ) delta1 =1 -( L11 + L21 ) x = M1 * delta1 / delta disp (x , Y1 ( s ) /F ( s )= ) // c o n s i d e r i n g y2 a s o u t p u t M1 =(1/ K ) *( K / M ) *( s ^ -2) delta1 =1 y = M1 * delta1 / delta disp (y , Y2 ( s ) /F ( s )= )

Scilab code Exa 4.9 incremental encoder


1 2 3 4 5 6 7 8 9 10 11

// i n c r e m e n t a l e n c o d e r // 2 s i n u s o i d a l s i g n a l s // g e n e r a t e s f o u r z e r o c r o s s i n g s p e r c y c l e ( z c ) // p r i n t w h e e l h a s 96 c h a r a c t e r s on i t s p h e r i p h e r y ( ch ) and e n c o d e r h a s 480 c y c l e s ( c y c ) zc =4 ch =96 cyc =480 zcpr = cyc * zc // z e r o c r o s s i n g s p e r r e v o l u t i o n disp ( zcpr , z e r o c r o s s i n g s p e r r e v o l u t i o n = ) zcpc = zcpr / ch // z r e o c r o s s i n g s p e r c h a r a c t e r disp ( zcpc , z e r o c r o s s i n g s p e r c h a r a c t e r = ) 29

12 // 500 khz c l o c k i s u s e d 13 // 500 p u l s e s / z e r o c r o s s i n g 14 shaft_speed =500000/500 15 x = shaft_speed / zcpr 16 disp (x , a n s= ) // i n r e v p e r s e c

30

Chapter 5 State Variable Analysis

Scilab code Exa 5.1 state transition equation


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

// s t a t e t r a n s i t i o n e q u a t i o n // a s s e e n from s t a t e e q u a t i o n A=[0 1; 2 3] B = [ 0 ; 1 ] E=0; A =[0 1; -2 -3] B =[0;1] s = poly (0 , s ) ; [ Row Col ]= size ( A ) // S i z e o f a m a t r i x m = s * eye ( Row , Col ) -A // s I A n = det ( m ) //To Find The D e t e r m i n a n t o f s i A p = inv ( m ) ; // To Find The I n v e r s e Of s I A U =1/ s p=p*U syms t s ; disp (p , p h i ( s )= ) // R e s o l v e n t M a t r i x for i =1: Row for j =1: Col // Taking I n v e r s e L a p l a c e o f e a c h e l e m e n t o f M a t r i x phi ( s ) q (i , j ) = ilaplace ( p (i , j ) ,s , t ) ; end ; 31

19 end ; 20 disp (q , p h i ( t )= ) // S t a t e T r a n s i t i o n M a t r i x 21 y = q * B ; // x ( t )=p h i ( t ) x ( 0 ) 22 disp (y , S o l u t i o n To The g i v e n eq .= )

Scilab code Exa 5.7 characteristic equation from transfer function


1 // c h a r a c t e r i s t i c e q u a t i o n from t r a n s f e r 2 s = %s 3 sys = syslin ( c ,1/( s ^3+5* s ^2+ s +2) ) 4 c = denom ( sys ) 5 disp (c , c h a r a c t e r i s t i c e q u a t i o n= )

function

Scilab code Exa 5.8 characteristic equation from state equation


1 2 3 4 5 6 7 8 9

// c h a r a c t e r i s t i c e q u a t i o n from s t a t e e q u a t i o n A =[0 1 0;0 0 1; -2 -1 -5] B =[0;0;1] C =[1 0 0] D =[0] [ Row Col ]= size ( A ) Gr = C * inv ( s * eye ( Row , Col ) -A ) * B + D c = denom ( Gr ) disp (c , c h a r a c t e r i s t i c e q u a t i o n= )

Scilab code Exa 5.9 eigen values


1 // e i g e n v a l u e s 2 A =[0 1 0;0 0 1; -2 -1 -5] 3 e = spec ( A ) // s p e c g i v e s 4 disp (e , e i g e n v a l u e s= )

eigen values of matrix

32

Scilab code Exa 5.12 ccf form


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

//OCF form s = %s A =[1 2 1;0 1 3;1 1 1] B =[1;0;1] [ row , col ]= size ( A ) c = s * eye ( row , col ) -A x = det ( c ) r = coeff ( x ) M =[ r (1 ,2) r (1 ,3) 1; r (1 ,3) 1 0;1 0 0] S =[ B A * B A ^2* B ] disp (S , c o n t r o l l a b i l i t y m a t r i x= ) if ( det ( S ) ==0) then printf ( s y s t e m c a n n o t be t r a n s f o r m e d i n t o c c f form ) else printf ( s y s t e m can be t r a n s f o r m e d i n t o c c f form ) end P=S*M disp (P , P= ) Accf = inv ( P ) * A * P Bccf = inv ( P ) * B disp ( Accf , A c c f= ) disp ( Bccf , B c c f= )

Scilab code Exa 5.13 ocf form


1 //OCF form 2 A =[1 2 1;0 1 3;1 1 1]

33

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

B =[1;0;1] C =[1 1 0] D =0 [ row , col ]= size ( A ) c = s * eye ( row , col ) -A x = det ( c ) r = coeff ( x ) M =[ r (1 ,2) r (1 ,3) 1; r (1 ,3) 1 0;1 0 0] V =[ C ; C * A ; C * A ^2] disp (V , o b s e r v a b i l i t y m a t r i x= ) if ( det ( V ) ==0) then printf ( s y s t e m c a n n o t be t r a n s f o r m e d i n t o o c f form ) else printf ( s y s t e m can be t r a n s f o r m e d i n t o o c f form ) end Q = inv ( M * V ) disp (Q , Q= ) Aocf = inv ( Q ) * A * Q Cocf = C * Q B = inv ( Q ) * B disp ( Aocf , A o c f= ) disp ( Cocf , C o c f= )

Scilab code Exa 5.14 dcf form


1 //DCF form 2 A =[0 1 0;0 0 1; -6 -11 -6] 3 x = spec ( A ) 4 T =[1 1 1; x (1 ,1) x (2 ,1) x (3 ,1) ;( x (1 ,1) ) ^2 ( x (2 ,1) ) ^2

( x (3 ,1) ) ^2] 5 Adcf = inv ( T ) * A * T 6 disp ( Adcf , Adcf= )

34

Scilab code Exa 5.18 system with identical eigen values


1 2 3 4 5 6 7 8 9

// s y s t e m w i t h i d e n t i c a l e i g e n v a l u e s A =[1 0;0 1] // lamda1=1 B =[2;3] // b11=2 b21=3 S =[ B A * B ] if det ( S ) ==0 then printf ( s y s t e m i s u n c o n t r o l l a b l e ) else printf ( s y s t e m i s c o n t o l l a b l e ) end

Scilab code Exa 5.19 controllability


1 2 3 4 5 6 7 8 9

// c o n t r o l l a b i l i t y A =[ -2 1;0 -1] B =[1;0] S =[ B A * B ] if det ( S ) ==0 then printf ( s y s t e m i s u n c o n t r o l l a b l e ) else printf ( s y s t e m i s c o n t o l l a b l e ) end

Scilab code Exa 5.20 controllability


1 // c o n t r o l l a b i l i t y 2 A =[1 2 -1;0 1 0;1 -4 3] 3 B =[0;0;1]

35

4 S =[ B A * B A ^2* B ] 5 if det ( S ) ==0 then 6 printf ( s y s t e m 7 else 8 printf ( s y s t e m 9 end

i s u n c o n t r o l l a b l e ) i s c o n t o l l a b l e )

Scilab code Exa 5.21 observability


1 2 3 4 5 6 7 8 9 10

// o b s e r v a b i l i t y A =[ -2 0;0 -1] B =[3;1] C =[1 0] V =[ C ; C * A ] if det ( V ) ==0 then printf ( s y s t e m i s u n o b s e r v a b l e ) else printf ( s y s t e m i s o b s e r v a b l e ) end

36

Chapter 6 Stability of Linear Control Systems

Scilab code Exa 6.1 stability of open loop systems


1 // s t a b i l i t y o f open l o o p s y s t e m s 2 s = %s 3 sys1 = syslin ( c ,20/(( s +1) *( s +2) *( s +3) ) ) 4 disp ( sys1 , M( s )= ) 5 printf ( s y s 1 i s s t a b l e a s t h e r e a r e no p l o e s o r 6 7 8 9 10 11 12 13 14 15 16

z e r o e s i n RHP ) sys2 = syslin ( c ,20*( s +1) /(( s -1) *( s ^2+2* s +2) ) ) disp ( sys2 , M( s )= ) printf ( s y s 2 i s u n s t a b l e due t o p o l e a t s =1 ) sys3 = syslin ( c ,20*( s -1) /(( s +2) *( s ^2+4) ) ) disp ( sys3 , M( s )= ) printf ( s y s 3 i s m a r g i n a l l y s t a b l e o r m a r g i n a l l y u n s t a b l e due t o s=j 2 and s= j 2 ) sys4 = syslin ( c ,10/(( s +10) *( s ^2+4) ^2) ) disp ( sys4 , M( s )= ) printf ( s y s 4 i s u n s t a b l e due t o m u l t i p l e o r d e r p o l e a t s=j 2 and s= j 2 ) sys5 = syslin ( c ,10/( s ^4+30* s ^3+ s ^2+10* s ) ) disp ( sys5 , M( s )= ) 37

17

printf ( s y s 5 i s s t a b l e i n t e n t i o n a l l y )

i f p o l e a t s =0 i s p l a c e d

Scilab code Exa 6.2 rouths tabulation to determine stability


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

// r o u t h s t a b u l a t i o n s t o d e t e r m i n e s t a b i l i t y s = %s ; m = s ^3 -4* s ^2+ s +6; disp ( m ) r = coeff ( m ) n = length ( r ) routh = routh_t ( m ) // T h i s F u n c t i o n g e n e r a t e s t h e Routh table disp ( routh , r o u t h s t a b u l a t i o n= ) c =0; for i =1: n if ( routh (i ,1) <0) c = c +1; end end if (c >=1) printf ( s y s t e m i s u n s t a b l e ) else printf ( s y s t e m i s s t a b l e ) end

Scilab code Exa 6.3 rouths tabulation to determine stability


1 2 3 4 5 6

// r o u t h s t a b u l a t i o n s t o d e t e r m i n e s t a b i l i t y s = %s ; m =2* s ^4+ s ^3+3* s ^2+5* s +10; disp ( m ) r = coeff ( m ) n = length ( r ) 38

7 8 9 10 11 12 13 14 15 16 17 18

routh = routh_t ( m ) // T h i s F u n c t i o n g e n e r a t e s t h e Routh table disp ( routh , r o u t h s t a b u l a t i o n= ) c =0; for i =1: n if ( routh (i ,1) <0) c = c +1; end end if (c >=1) printf ( s y s t e m i s u n s t a b l e ) else printf ( s y s t e m i s s t a b l e ) end

Scilab code Exa 6.4 rst element in any row of rouths tabulation is z
1 2 3 4 5 6 7 8

// f i r s t e l e m e n t i n any row o f r o u t h s t a b u l a t i o n i s zero s = %s m = s ^4+ s ^3+2* s ^2+2* s +3 r = coeff ( m ) ; // E x t r a c t s t h e c o e f f i c i e n t o f t h e polynomial n = length ( r ) ; routh = routh_t ( m ) disp ( routh , r o u t h= ) printf ( s i n c e t h e r e a r e two s i g n c h a n g e s i n t h e rouths tabulation , sys i s uns ta ble )

Scilab code Exa 6.5 elements in any row of rouths tabulations are all // e l e m e n t s i n one row o f r o u t h s t a b u l a t i o n s a r e a l l zero 2 s = %s ;
1

39

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

m = s ^5+4* s ^4+8* s ^3+8* s ^2+7* s +4; disp ( m ) r = coeff ( m ) n = length ( r ) routh = routh_t ( m ) disp ( routh , r o u t h s t a b u l a t i o n s= ) c =0; for i =1: n if ( routh (i ,1) <0) c = c +1; end end if (c >=1) printf ( s y s t e m i s u n s t a b l e ) else printf ( s y s t e m i s m a r g i n a l l y s t a b l e ) end

Scilab code Exa 6.6 determining critical value of K


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

// d e t e r m i n i n g c r i t i c a l v a l u e o f K s = %s syms K m = s ^3+3408.3* s ^2+1204000* s +1.5*10^7* K cof_a_0 = coeffs (m , s ,0) ; cof_a_1 = coeffs (m , s ,1) ; cof_a_2 = coeffs (m , s ,2) ; cof_a_3 = coeffs (m , s ,3) ; r =[ cof_a_0 cof_a_1 cof_a_2 cof_a_3 ] n = length ( r ) ; routh =[ r ([4 ,2]) ; r ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]; t = routh (2:3 ,1:2) ; // e x t r a c t i n g t h e s q u a r e sub b l o c k of routh matrix 40

16 routh =[ routh ; - det ( t ) / t (2 ,1) ,0] 17 disp ( routh , r o u t h s t a b u l a t i o n= ) 18 routh (3 ,1) =0 // For m a r g i n a l y s t a b l e s y s t e m 19 sys = syslin ( c ,1.5*10^7/( s ^3+3408.3* s ^2+1204000* s ) ) 20 k = kpure ( sys ) 21 disp (k , K( m a r g i n a l )= ) 22 disp ( =0 , routh (2 ,1) *( s ^2) +1.5*10^7* k , a u x i l l a r y

equation ) 23 p = poly ([1.5*10^7* k ,0 ,3408.3] , s , c o e f f ) 24 s = roots ( p ) 25 disp (s , F r e q u e n c y o f o s c i l l a t i o n ( i n r a d / s e c )= )

Scilab code Exa 6.7 determining critical value of K


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

// d e t e r m i n i n g c r i t i c a l v a l u e o f K s = %s syms K m = s ^3+3* K * s ^2+( K +2) * s +4 cof_a_0 = coeffs (m , s ,0) ; cof_a_1 = coeffs (m , s ,1) ; cof_a_2 = coeffs (m , s ,2) ; cof_a_3 = coeffs (m , s ,3) ; r =[ cof_a_0 cof_a_1 cof_a_2 cof_a_3 ] n = length ( r ) ; routh =[ r ([4 ,2]) ; r ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]; t = routh (2:3 ,1:2) ; // e x t r a c t i n g t h e s q u a r e sub b l o c k of routh matrix routh =[ routh ; - det ( t ) / t (2 ,1) ,0] disp ( routh , r o u t h s t a b u l a t i o n= ) routh (3 ,1) =0 // For m a r g i n a l y s t a b l e s y s t e m sys = syslin ( c ,s *(3* s +1) /( s ^3+2* s +4) ) k = kpure ( sys ) 41

21

disp (k , K( m a r g i n a l )= )

Scilab code Exa 6.8 stability of closed loop systems


1 // s t a b i l i t y o f c l o s e d l o o p s y s t e m s 2 z = %z 3 sys1 = syslin ( c ,5* z /(( z -0.2) *( z -0.8) ) ) 4 disp ( sys1 , M( z )= ) 5 printf ( s y s 1 i s s t a b l e ) 6 sys2 = syslin ( c ,5* z /(( z +1.2) *( z -0.8) ) ) 7 disp ( sys2 , M( z )= ) 8 printf ( s y s 2 i s u n s t a b l e due t o p o l e a t z = 1.2 ) 9 sys3 = syslin ( c ,5*( z +1) /( z *( z -1) *( z -0.8) ) ) 10 disp ( sys3 , M( z )= ) 11 printf ( s y s 3 i s m a r g i n a l l y s t a b l e due t o z=1 ) 12 sys4 = syslin ( c ,5*( z +1.2) /( z ^2*( z +1) ^2*( z +0.1) ) ) 13 disp ( sys4 , M( z )= ) 14 printf ( s y s 4 i s u n s t a b l e due t o m u l t i p l e o r d e r p o l e

a t z=1 )

Scilab code Exa 6.9 bilinear transformation method


1 2 3 4 5 6 7 8 9 10 11

// b i l i n e a r t r a n s f o r m a t i o n method r = %s // p=z 3 + 5 . 9 4 z 2 + 7 . 7 z 0.368 // s u b s t i t u t i n g z =(1+ r ) /(1 r ) we g e t m =3.128* r ^3 -11.47* r ^2+2.344* r +14.27 x = coeff ( m ) n = length ( x ) routh = routh_t ( m ) disp ( routh , r o u t h s t a b u l a t i o n s ) c =0; for i =1: n 42

12 13 14 15 16 17 18 19

if ( routh (i ,1) <0) then c = c +1 end end if (c >=1) then printf ( s y s t e m i s u n s t a b l e ) else printf ( s y s t e m i s s t a b l e ) end

Scilab code Exa 6.10 bilinear transformation method


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

// b i l i n e a r t r a n s f o r m a t i o n method s = %s syms K // p=z 3+ z 2+ z+K // s u b s t i t u t i n g z =(1+ r ) /(1 r ) we g e t m =(1 - K ) * s ^3+(1+3* K ) * s ^2+3*(1 - K ) * s +3+ K cof_a_0 = coeffs (m , s ,0) ; cof_a_1 = coeffs (m , s ,1) ; cof_a_2 = coeffs (m , s ,2) ; cof_a_3 = coeffs (m , s ,3) ; r =[ cof_a_0 cof_a_1 cof_a_2 cof_a_3 ]

n = length ( r ) ; routh =[ r ([4 ,2]) ; r ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]; t = routh (2:3 ,1:2) ; // e x t r a c t i n g t h e s q u a r e sub b l o c k of routh matrix 18 routh =[ routh ; - det ( t ) / t (2 ,1) ,0] 19 disp ( routh , r o u t h s t a b u l a t i o n= )

43

Chapter 7 Time Domain Analysis of Control Systems

Scilab code Exa 7.1 type of system


1 // t y p e o f s y s t e m 2 s = %s 3 G1 = syslin ( c ,(1+0.5* s ) /( s *(1+ s ) *(1+2* s ) *(1+ s + s ^2) ) ) 4 disp ( G1 , G( s )= ) 5 printf ( t y p e 1 a s i t h a s one s term i n d e n o m i n a t o r ) 6 G2 = syslin ( c ,(1+2* s ) / s ^3) 7 disp ( G2 , G( s )= ) 8 printf ( t y p e 3 a s i t h a s 3 p o l e s a t o r i g i n )

Scilab code Exa 7.2 steady state errors from open loop tf // s t e a d y s t a t e e r r o r s from open l o o p t r a n s f e r function 2 s = %s ; 3 // t y p e 1 s y s t e m 4 G = syslin ( c ,( s +3.15) /( s *( s +1.5) *( s +0.5) ) ) //K=1
1

44

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

disp (G , G( s )= ) H =1; y=G*H; disp (y , G( s )H( s )= ) syms s ; Kv = limit ( s *y ,s ,0) ; //Kv= v e l o c i t y e r r o r c o e f f i c i e n t Ess =1/ Kv // R e f e r i n g t h e t a b l e 7 . 1 g i v e n i n t h e book , For t y p e 1 s y s t e m Kp=%inf , E s s=0 & Ka=0 , E s s=% i n f printf ( For t y p e 1 s y s t e m \ n s t e p i n p u t Kp= i n f E s s=0 \ n \ n p a r a b o l i c i n p u t Ka=0 E s s= i n f \ n ) disp ( Kv , ramp i n p u t Kv= ) disp ( Ess , E s s= ) // t y p e 2 s y s t e m p = poly ([1] , s , c o e f f ) ; q = poly ([0 0 12 1] , s , c o e f f ) ; G = p / q ; //K=1 disp (G , G( s )= ) H =1; y=G*H; disp (y , G( s )H( s )= ) Ka = limit ( s ^2* y ,s ,0) ; //Ka= p a r a b o l i c e r r o r coefficient Ess =1/ Ka // R e f e r i n g t h e t a b l e 7 . 1 g i v e n i n t h e book , For t y p e 2 s y s t e m Kp=%inf , E s s=0 & Kv=i n f , E s s=0 printf ( For t y p e 2 s y s t e m \ n s t e p i n p u t Kp= i n f E s s=0 \ n ramp i n p u t Kv= i n f E s s=0 \ n ) disp ( Ka , p a r a b o l i c i n p u t Ka= ) disp ( Ess , E s s= ) // t y p e 2 s y s t e m p = poly ([5 5] , s , c o e f f ) ; q = poly ([0 0 60 17 1] , s , c o e f f ) ; G = p / q ; //K=1 disp (G , G( s )= ) H =1; y=G*H; disp (y , G( s )H( s )= ) 45

38 Ka = limit ( s ^2* y ,s ,0) ; //Ka= p a r a b o l i c

error

coefficient
39 Ess =1/ Ka 40 // R e f e r i n g t h e t a b l e

7 . 1 g i v e n i n t h e book , For t y p e 2 s y s t e m Kp=%inf , E s s=0 & Kv=i n f , E s s=0 41 printf ( For t y p e 2 s y s t e m \ n s t e p i n p u t Kp= i n f E s s=0 \ n ramp i n p u t Kv= i n f E s s=0 \ n ) 42 disp ( Ka , p a r a b o l i c i n p u t Ka= ) 43 disp ( Ess , E s s= )

Scilab code Exa 7.3 steady state errors from closed loop tf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

// s t e a d y s t a t e e r r o r s from c l o s e d l o o p t r a n s f e r functions s = %s p = poly ([3.15 1 0] , s , c o e f f ) ; //K=1 q = poly ([3.15 1.75 2 1] , s , c o e f f ) ; M=p/q disp (M , M( s )= ) H =1; R =1; b = coeff ( p ) a = coeff ( q ) // s t e p i n p u t if ( a (1 ,1) == b (1 ,1) ) then printf ( f o r u n i t s t e p i n p u t E s s=0 ) else Ess =1/ H *(1 -( b (1 ,1) * H / a (1 ,1) ) ) * R disp ( Ess , f o r u n i t s t e p i n p u t E s s= ) end // ramp i n p u t c =0 for i =1:2 46

// p a r a b o l i c i n p u t c =0 for i =1:3 if ( a (1 , i ) -b (1 , i ) * H ==0) then c = c +1 end end if ( c ==3) printf ( f o r u n i t p a r a b o l i c i n p u t E s s=0 ) else if ( c ==2) then Ess =( a (1 ,3) -b (1 ,3) * H ) / a (1 ,1) * H disp ( Ess , f o r u n i t p a r a b o l i c i n p u t E s s= ) 48 else printf ( f o r u n i t p a r a b o l i c i n p u t E s s= i n f ) 49 end 50 end

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

if ( a (1 , i ) -b (1 , i ) * H ==0) then c = c +1 end end if ( c ==2) printf ( f o r u n i t ramp i n p u t E s s=0 ) else if ( c ==1) then Ess =( a (1 ,2) -b (1 ,2) * H ) / a (1 ,1) * H disp ( Ess , f o r u n i t ramp i n p u t E s s= ) else printf ( f o r u n i t ramp i n p u t E s s= i n f ) end end

Scilab code Exa 7.4 steady state errors from closed loop tf
1

// s t e a d y s t a t e e r r o r s from c l o s e d l o o p t r a n s f e r functions 47

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

s = %s p = poly ([5 5 0] , s , c o e f f ) ; q = poly ([5 5 60 17 1] , s , c o e f f ) ; M=p/q disp (M , M( s )= ) H =1; R =1; b = coeff ( p ) a = coeff ( q ) // s t e p i n p u t if ( a (1 ,1) == b (1 ,1) ) then printf ( f o r u n i t s t e p i n p u t E s s=0 \ n ) else Ess =1/ H *(1 -( b (1 ,1) * H / a (1 ,1) ) ) * R disp ( Ess , f o r u n i t s t e p i n p u t E s s= ) end

// ramp i n p u t c =0 for i =1:2 if ( a (1 , i ) -b (1 , i ) * H ==0) then c = c +1 end end if ( c ==2) printf ( f o r u n i t ramp i n p u t E s s=0 \ n ) else if ( c ==1) then Ess =( a (1 ,2) -b (1 ,2) * H ) / a (1 ,1) * H disp ( Ess , f o r u n i t ramp i n p u t E s s= ) else printf ( f o r u n i t ramp i n p u t E s s= i n f \ n ) 33 end 34 end
35 36 // p a r a b o l i c 37 c =0 38 for i =1:3

input

48

39 if ( a (1 , i ) -b (1 , i ) * H ==0) then 40 c = c +1 41 end 42 end 43 if ( c ==3) 44 printf ( f o r u n i t p a r a b o l i c i n p u t E s s=0 \ n ) 45 else if ( c ==2) then 46 Ess =( a (1 ,3) -b (1 ,3) * H ) / a (1 ,1) * H 47 disp ( Ess , f o r u n i t p a r a b o l i c i n p u t E s s= 48 49 50

) else printf ( f o r u n i t p a r a b o l i c i n p u t E s s= i n f \n) end end

Scilab code Exa 7.5 steady state errors from closed loop tf
1

2 3 4 5 6 7 8 9 10 11 12 // s t e p i n p u t 13 if ( a (1 ,1) == b (1 ,1) ) then 14 printf ( f o r u n i t s t e p i n p u t E s s=0 \ n ) 15 else 16 Ess =1/ H *(1 -( b (1 ,1) * H / a (1 ,1) ) ) * R 17 disp ( Ess , f o r u n i t s t e p i n p u t E s s= )

// s t e a d y s t a t e e r r o r s from c l o s e d l o o p t r a n s f e r functions s = %s p = poly ([5 1 0] , s , c o e f f ) ; q = poly ([5 5 60 17 1] , s , c o e f f ) ; M=p/q disp (M , M( s )= ) H =1; R =1; b = coeff ( p ) a = coeff ( q )

49

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

end

// ramp i n p u t c =0 for i =1:2 if ( a (1 , i ) -b (1 , i ) * H ==0) then c = c +1 end end if ( c ==2) printf ( f o r u n i t ramp i n p u t E s s=0 \ n ) else if ( c ==1) then Ess =( a (1 ,2) -b (1 ,2) * H ) / a (1 ,1) * H disp ( Ess , f o r u n i t ramp i n p u t E s s= ) else printf ( f o r u n i t ramp i n p u t E s s= i n f \ n ) 33 end 34 end

// p a r a b o l i c i n p u t c =0 for i =1:3 if ( a (1 , i ) -b (1 , i ) * H ==0) then c = c +1 end end if ( c ==3) printf ( f o r u n i t p a r a b o l i c i n p u t E s s=0 \ n ) else if ( c ==2) then Ess =( a (1 ,3) -b (1 ,3) * H ) / a (1 ,1) * H disp ( Ess , f o r u n i t p a r a b o l i c i n p u t E s s= ) 48 else printf ( f o r u n i t p a r a b o l i c i n p u t E s s= i n f \n) 49 end 50 end

35 36 37 38 39 40 41 42 43 44 45 46 47

50

Scilab code Exa 7.6 steady state errors from closed loop tf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

// s t e a d y s t a t e e r r o r s from c l o s e d l o o p t r a n s f e r functions s = %s p = poly ([5 1 0] , s , c o e f f ) ; q = poly ([10 10 60 17 1] , s , c o e f f ) ; M=p/q disp (M , M( s )= ) H =2; R =1; b = coeff ( p ) a = coeff ( q ) // s t e p i n p u t if ( a (1 ,1) == b (1 ,1) ) then printf ( f o r s t e p i n p u t E s s=0 \ n ) else Ess =1/ H *(1 -( b (1 ,1) * H / a (1 ,1) ) ) * R disp ( Ess , f o r s t e p i n p u t E s s= ) end // ramp i n p u t c =0 for i =1:2 if ( a (1 , i ) -b (1 , i ) * H ==0) then c = c +1 end end if ( c ==2) printf ( f o r ramp i n p u t E s s=0 \ n ) else if ( c ==1) then Ess =( a (1 ,2) -b (1 ,2) * H ) / a (1 ,1) * H disp ( Ess , f o r ramp i n p u t E s s= ) 51

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

else printf ( f o r ramp i n p u t E s s= i n f \ n ) end end

// p a r a b o l i c i n p u t c =0 for i =1:3 if ( a (1 , i ) -b (1 , i ) * H ==0) then c = c +1 end end if ( c ==3) printf ( f o r p a r a b o l i c i n p u t E s s=0 \ n ) else if ( c ==2) then Ess =( a (1 ,3) -b (1 ,3) * H ) / a (1 ,1) * H disp ( Ess , f o r p a r a b o l i c i n p u t E s s= ) else printf ( f o r p a r a b o l i c i n p u t E s s= i n f \ n ) 49 end 50 end

52

Chapter 8 Root Locus Technique

Scilab code Exa 8.1 poles and zeros


1 // p o l e s and z e r o e s 2 s = %s 3 sys = syslin ( c ,( s +1) /( s *( s +2) *( s +3) ) ) 4 plzr ( sys ) 5 printf ( t h r e e p o i n t s on t h e r o o t l o c i a t which K=0

and t h o s e a t which K= i n f a r e shown i n f i g )

Scilab code Exa 8.2 root locus


1 // r o o t l o c u s 2 s = %s 3 sys = syslin ( c ,( s +1) /( s *( s +2) *( s +3) ) ) 4 evans ( sys ) 5 printf ( number o f b r a n c h e s o f r o o t l o c i

i s 3 as

e q u a t i o n i s o f 3 rd o r d e r ) 53

Figure 8.1: poles and zeros

54

Figure 8.2: root locus

55

Figure 8.3: root locus

Scilab code Exa 8.3 root locus


1 // r o o t l o c u s 2 s = %s 3 sys = syslin ( c ,1/( s *( s +2) *( s +1) ) ) 4 clf 5 evans ( sys ) 6 printf ( r o o t l o c i i s s y m m e t i c a l t o b o t h a x i s )

56

Figure 8.4: root locus

Scilab code Exa 8.4 root locus


1 // r o o t l o c u s 2 s = %s 3 sys = syslin ( c ,1/( s *( s +2) *( s ^2+2* s +2) ) ) 4 clf 5 evans ( sys ) 6 printf ( when p o l e z e r o c o n f i g u r a t i o n i s s y m m e t r i c a l

wrt a p o i n t i n s p l a n e , t h e n r o o t l o c i symmetrical to that point )

is

57

Figure 8.5: root locus

Scilab code Exa 8.5 root locus


1 2 3 4 5 6 7 8 9

// r o o t l o c u s s = %s sys = syslin ( c ,( s +1) /( s *( s +4) *( s ^2+2* s +2) ) ) clf evans ( sys ) n =4; disp (n , no o f p o l e s= ) m =1; disp (m , no o f p o l e s= ) 58

10 // a n g l e o f a s y m p t o t e s 11 printf ( a n g l e o f a s y m p t o t e s o f RL ) 12 for i =0:( n -m -1) 13 O =((2* i ) +1) /( n - m ) *180 14 disp (O , q= ) 15 end 16 printf ( a n g l e o f a s y m p t o t e s o f CRL ) 17 for i =0:( n -m -1) 18 O =(2* i ) /( n - m ) *180 19 disp (O , q= ) 20 end 21 // c e n t r o i d 22 printf ( C e n t r o i d =(( sum o f a l l r e a l p a r t o f

G( s )H( s ) ) (sum o f a l l ( s ) ) / ( nm) \ n ) 23 C =((0 -4 -1 -1) -( -1) ) /( n - m ) ; 24 disp (C , c e n t r o i d= )

poles of r e a l p a r t o f z e r o s o f G( s )H

Scilab code Exa 8.8 angle of departure and angle of arrivals


1 // a n g l e o f d e p a r t u r e and a n g l e o f a r r i v a l s 2 s = %s 3 sys = syslin ( c ,1/( s *( s +3) *( s ^2+2* s +2) ) ) 4 clf 5 evans ( sys ) 6 printf ( a n g l e o f a r r i v a l and d e p a r t u r e o f r o o t

loci

on t h e r e a l a x i s a r e n o t a f f e c t e d by c o m p l e x p o l e s and z e r o e s o f G( s )H( s ) )

Scilab code Exa 8.9 multiple order pole 59

Figure 8.6: angle of departure and angle of arrivals

60

Figure 8.7: intersection of root loci with real axis


1 // m u l t i p l e o r d e r p o l e 2 s = %s 3 sys = syslin ( c ,( s +3) /( s *( s +2) ^3) ) 4 clf 5 evans ( sys ) 6 printf ( t h i s shows t h a t w h o l e r e a l

axis i s occupied

by RL and CRL )

Scilab code Exa 8.10 intersection of root loci with real axis
1

// i n t e r s e c t i o n o f r o o t l o c i w i t h r e a l a x i s 61

Figure 8.8: breakaway points


2 3 4 5 6 7 8 9 10 11 12

s = %s sys = syslin ( c ,1/( s *( s +3) *( s ^2+2* s +2) ) ) clf evans ( sys ) K = kpure ( sys ) disp (K , v a l u e o f K where RL c r o s s e s jw a x i s= ) p = poly ([ K 6 8 5 1] , s , c o e f f ) x = roots ( p ) x1 = clean ( x (1 ,1) ) x2 = clean ( x (2 ,1) ) disp ( x2 , x1 , c r o s s o v e r p o i n t s on jw a x i s= )

62

Scilab code Exa 8.11 breakaway points


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

// breakaway p o i n t s s = %s sys = syslin ( c ,( s +4) /( s *( s +2) ) ) evans ( sys ) syms s d = derivat ( sys ) n = numer ( d ) a = roots ( n ) // a=breakaway p o i n t s disp (a , breakaway p o i n t s= ) for i =1:2 K = - a (i ,1) *( a (i ,1) +2) /( a (i ,1) +4) disp ( a (i ,1) , s= ) disp (K , K= ) end printf ( i f K i s p o s i t i v e breakaway p o i n t l i e s on RL o r e l s e on CRL )

Scilab code Exa 8.12 breakaway points


1 2 3 4 5 6 7 8 9 10 11 12

// breakaway p o i n t s s = %s sys = syslin ( c ,( s +2) /( s ^2+2* s +2) ) evans ( sys ) syms s d = derivat ( sys ) n = numer ( d ) a = roots ( n ) // a=breakaway p o i n t s disp (a , breakaway p o i n t s= ) for i =1:2 K = -( a (i ,1) ^2+2* a (i ,1) +2) /( a (i ,1) +2) disp ( a (i ,1) , s= ) 63

Figure 8.9: breakaway points

64

Figure 8.10: breakaway points


13 disp (K , K= ) 14 end 15 printf ( i f K i s p o s i t i v e breakaway p o i n t

l i e s on RL

o r e l s e on CRL )

Scilab code Exa 8.13 breakaway points


1 // breakaway p o i n t s 2 s = %s 3 sys = syslin ( c ,1/( s *( s +4) *( s ^2+4* s +20) ) ) 4 evans ( sys )

65

Figure 8.11: breakaway points


5 6 7 8 9 10 11 12 13 14 15

syms s d = derivat ( sys ) n = numer ( d ) a = roots ( n ) // a=breakaway p o i n t s disp (a , breakaway p o i n t s= ) for i =1:3 K = - a (i ,1) *( a (i ,1) +4) *( a (i ,1) ^2+4* a (i ,1) +20) disp ( a (i ,1) , s= ) disp (K , K= ) end printf ( i f K i s p o s i t i v e breakaway p o i n t l i e s on RL o r e l s e on CRL )

66

Scilab code Exa 8.14 breakaway points


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

// breakaway p o i n t s s = %s sys = syslin ( c ,1/( s *( s ^2+2* s +2) ) ) evans ( sys ) syms s d = derivat ( sys ) n = numer ( d ) a = roots ( n ) // a=breakaway p o i n t s disp (a , breakaway p o i n t s= ) for i =1:2 K = - a (i ,1) ^2+2* a (i ,1) +2 disp ( a (i ,1) , s= ) disp (K , K= ) end printf ( i f K i s c o m p l e x t h e n p o i n t i s n o t a b r e a k away p o i n t )

Scilab code Exa 8.15 root sensitivity


1 // r o o t s e n s i t i v i t y 2 s = %s 3 sys1 = syslin ( c ,1/( s *( s +1) ) ) 4 evans ( sys1 ) 5 6 sys2 = syslin ( c ,( s +2) /( s ^2*( s +1) ^2) ) 7 evans ( sys2 ) 8 9 printf ( r o o t d e n s i t i v i t y a t breakaway p o i n t s

is

i n f i n i t e )

67

Figure 8.12: root sensitivity

Scilab code Exa 8.16 calculation of K on root loci


1 // c a l c u l a t i o n o f K on r o o t l o c i 2 s = %s 3 sys = syslin ( c ,( s +2) /( s ^2+2* s +2) ) 4 evans ( sys ) 5 // v a l u e o f K a t s =0

68

Figure 8.13: root sensitivity

69

Figure 8.14: calculation of K on root loci

70

7 8 9 10 11

printf ( K=AB/C \ n A and B a r e l e n t h s o f v e c t o r s drawn from p o l e s o f s y s \ n C i s l e n t h s o f v e c t o r drawn from z e r o o f s y s ) A = sqrt (( -1) ^2+1^2) B = sqrt (( -1) ^2+( -1) ^2) C = -2 K=A*B/C disp (K , v a l u e o f K a t s =0 i s )

Scilab code Exa 8.17 properties of root loci


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

// p r o p e r t i e s o f r o o t l o c i s = %s sys = syslin ( c ,( s +3) /( s *( s +5) *( s +6) *( s ^2+2* s +2) ) ) d = denom ( sys ) n = numer ( sys ) p = roots ( d ) z = roots ( n ) disp (p , p o l e s o f s y s= ) disp (z , z e r o e s o f s y s= ) n = length ( p ) m = length ( z ) disp (n , no o f p o l e s= ) disp (m , no o f z e r o e s= ) if (n > m ) then disp (n , no o f b r a n c h e s o f RL= ) else disp (m , no o f b r a n c h e s o f CRL= ) end printf ( t h e r o o t l o c i a r e s y m m e t r i c a l w i t h r e s p e c t to the r e a l a x i s of the plane )

Scilab code Exa 8.18 eect of addition of poles to system 71

Figure 8.15: eect of addition of poles to system


1 // e f f e c t o f a d d i t i o n o f p o l e s t o s y s 2 s = %s 3 sys = syslin ( c ,1/( s *( s +1) ) ) // a=1 4 evans ( sys ) 5 sys1 = syslin ( c ,1/( s *( s +1) *( s +2) ) ) // b=2 6 evans ( sys1 ) 7 printf ( a d d i n g a p o l e t o s y s h a s e f f e c t o f p u s h i n g

t h e r o o t l o c i t o w a r d s t h e RHP )

72

Figure 8.16: eect of addition of poles to system

73

Figure 8.17: eect of addition of zeroes to system Scilab code Exa 8.19 eect of addition of zeroes to system
1 // e f f e c t o f a d d i t i o n o f z e r o e s t o s y s 2 s = %s 3 sys = syslin ( c ,1/( s *( s +1) ) ) // a=1 4 evans ( sys ) 5 sys1 = syslin ( c ,( s +2) /( s *( s +1) ) ) // b=2 6 // e v a n s ( s y s 1 ) 7 printf ( a d d i n g a LHP z e r o t o s y s h a s e f f e c t

of moving and b e n d i n g t h e r o o t l o c i t o w a r d s t h e LHP )

74

Figure 8.18: eect of addition of zeroes to system

75

Scilab code Exa 8.20 eect of moving poles near jw axis


1 // e f f e c t o f moving p o l e n e a r jw a x i s 2 s = %s 3 sys1 = syslin ( c ,( s +1) /( s ^2*( s +10) ) ) 4 evans ( sys1 ) 5 sys2 = syslin ( c ,( s +1) /( s ^2*( s +9) ) ) 6 evans ( sys2 ) 7 sys3 = syslin ( c ,( s +1) /( s ^2*( s +8) ) ) 8 evans ( sys3 ) 9 sys4 = syslin ( c ,( s +1) /( s ^2*( s +3) ) ) 10 evans ( sys4 ) 11 sys5 = syslin ( c ,( s +1) /( s ^2*( s +1) ) ) 12 evans ( sys5 ) 13 printf ( a s p o l e i s moved t o w a r d s jw

// a=10 b=1 // a=9 // a=8 // a=3 // a=1 a x i s RL a l s o

moves t o w a r d s jw a x i s )

Scilab code Exa 8.21 eect of moving poles awat from jw axis
1 // e f f e c t o f moving p o l e away from jw a x i s 2 s = %s 3 sys1 = syslin ( c ,( s +2) /( s *( s ^2+2* s +1) ) ) // a=1 4 evans ( sys1 ) 5 sys2 = syslin ( c ,( s +1) /( s *( s ^2+2* s +1.12) ) ) // a =1.12 6 evans ( sys2 ) 7 sys3 = syslin ( c ,( s +1) /( s *( s ^2+2* s +1.185) ) ) // a 8

=1.185 evans ( sys3 ) 76

Figure 8.19: eect of moving poles near jw axis

77

Figure 8.20: eect of moving poles near jw axis

78

Figure 8.21: eect of moving poles awat from jw axis


9 10 11

sys4 = syslin ( c ,( s +1) /( s *( s ^2+2* s +3) ) ) // a=3 evans ( sys4 ) printf ( a s p o l e i s moved away from jw a x i s RL a l s o moves away from jw a x i s )

79

Figure 8.22: eect of moving poles awat from jw axis

80

Chapter 9 Frequency Domain Analysis

Scilab code Exa 9.1 nyquist plot


1 // n y q u i s t p l o t 2 s = %s ; 3 sys = syslin ( c ,1/( s *( s +2) *( s +10) ) ) 4 nyquist ( sys ) 5 show_margins ( sys , n y q u i s t ) 6 K = kpure ( sys ) 7 disp (K , s y s t e m i s s t a b l e f o r 0<K< )

Scilab code Exa 9.2 nyquist plot


1 // n y q u i s t p l o t 2 s = %s ; 3 sys = syslin ( c ,s *( s ^2+2* s +2) /( s ^2+5* s +1) ) 4 nyquist ( sys ) 5 show_margins ( sys , n y q u i s t )

81

Figure 9.1: nyquist plot

82

Figure 9.2: nyquist plot

83

Figure 9.3: stability of non minimum phase loop tf


6

printf ( S i n c e P=0( no o f p o l e s i n RHP)=P o l e s o f G( s )H ( s ) \ n h e r e t h e number o f z e r o s o f 1+G( s )H( s ) i n t h e RHP i s N>0 \ n h e n c e t h e s y s t e m i s u n s t a b l e )

Scilab code Exa 9.3 stability of non minimum phase loop tf


1

// s t a b i l i t y o f non minimum p h a s e l o o p transfer function 2 s = %s ; 3 sys = syslin ( c ,( s ^2 - s +1) / s *( s ^2 -6* s +5) ) 4 nyquist ( sys ) 84

Figure 9.4: stability of minimum phase loop tf


5 6

7 8 9 10 11 12

show_margins ( sys , n y q u i s t ) printf ( Z=0 h e n c e s y s i s c l o s e d l o o p s t a b l e but a s i t i s a non minimum p h a s e l o o p f u n c t i o n i t s h o u l d s a t i s f y angle c r i t e r i o n ) Z =0 // no o f z e r o e s o f 1+G( s )H( s ) i n RHP P =2 // no o f p o l e s i n RHP Pw =1 // no o f p o l e s on jw a x i s i n c l u d i n g o r i g i n theta =( Z -P -0.5* Pw ) *180 disp ( theta , t h e t a= ) printf ( t h e t a from n y q u i s t p l o t = 90 \ n h e n c e system i s unstabe )

85

Scilab code Exa 9.4 stability of minimum phase loop tf


1 2 3 4 5 6 7 8 9 10 11

// s t a b i l i t y o f minimum p h a s e l o o p t r a n s f e r f u n c t i o n s = %s ; sys = syslin ( c ,1/( s *( s +2) *( s +10) ) ) nyquist ( sys ) show_margins ( sys , n y q u i s t ) Z =0 // no o f z e r o e s o f 1+G( s )H( s ) i n RHP P =0 // no o f p o l e s i n RHP Pw =1 // no o f p o l e s on jw a x i s i n c l u d i n g o r i g i n theta =( Z -P -0.5* Pw ) *180 disp ( theta , t h e t a= ) printf ( t h e t a from n y q u i s t p l o t = 90 \ n h e n c e system i s stabe )

Scilab code Exa 9.5 stability of non minimum phase loop tf


1 2 3 4 5 6 7 8 9 10 11

// s t a b i l i t y o f non minimum p h a s e l o o p transfer function s = %s ; sys = syslin ( c ,(s -1) / s *( s +1) ) nyquist ( sys ) show_margins ( sys , n y q u i s t ) P =0 // no o f p o l e s i n RHP Pw =1 // no o f p o l e s on jw a x i s i n c l u d i n g o r i g i n theta =90 // a s s e e n from n y q u i s t p l o t Z =( theta /180) +0.5* Pw + P disp (Z , Z= ) printf ( Z i s n o t e q u a l t o 0 . \ n h e n c e s y s t e m i s unstabe )

86

Figure 9.5: stability of non minimum phase loop tf

87

Figure 9.6: stability of non minimum phase loop tf

88

Scilab code Exa 9.6 stability of non minimum phase loop tf


1 2 3 4 5 6

7 8 9 10 11 12

// s t a b i l i t y o f non minimum p h a s e l o o p transfer function s = %s ; sys = syslin ( c ,10*( s +2) /( s ^3+3* s ^2+10) ) nyquist ( sys ) show_margins ( sys , n y q u i s t ) printf ( Z=0 h e n c e s y s i s c l o s e d l o o p s t a b l e but a s i t i s a non minimum p h a s e l o o p f u n c t i o n i t s h o u l d s a t i s f y angle c r i t e r i o n ) Z =0 // no o f z e r o e s o f 1+G( s )H( s ) i n RHP P =2 // no o f p o l e s i n RHP Pw =0 // no o f p o l e s on jw a x i s i n c l u d i n g o r i g i n theta =( Z -P -0.5* Pw ) *180 disp ( theta , t h e t a f o r s t a b i l i t y = ) printf ( t h e t a from n y q u i s t p l o t = 360 \ n h e n c e system i s stabe )

Scilab code Exa 9.7 stability of non minimum phase loop tf


1 2 3 4 5 6 7

// s t a b i l i t y o f non minimum p h a s e l o o p transfer function s = %s ; sys = syslin ( c ,1/( s +2) *( s ^2+4) ) nyquist ( sys ) show_margins ( sys , n y q u i s t ) Z =0 // no o f z e r o e s o f 1+G( s )H( s ) i n RHP( f o r s y s t o be stable ) P =0 // no o f p o l e s i n RHP 89

Figure 9.7: stability of non minimum phase loop tf

90

8 Pw =2 // no o f p o l e s on jw a x i s i n c l u d i n g o r i g i n 9 theta =( Z -P -0.5* Pw ) *180 10 disp ( theta , f o r s t a b i l i t y t h e t a= ) 11 printf ( t h e t a from n y q u i s t p l o t = 135 \ n h e n c e

system i s unstabe )

Scilab code Exa 9.8 eect of addition of poles


1 // e f f e c t o f a d d i t i o n o f p o l e s 2 s = %s ; 3 sys1 = syslin ( c ,1/( s ^2*( s +1) ) ) // t a k i n g T1=1 4 nyquist ( sys1 ) 5 show_margins ( sys1 , n y q u i s t ) 6 sys2 = syslin ( c ,1/( s ^3*( s +1) ) ) 7 // n y q u i s t ( s y s 2 ) 8 // s h o w m a r g i n s ( s y s 2 , n y q u i s t ) 9 printf ( t h e s e two p l o t s show t h a t a d d i t i o n o f

poles

d e c r e a s e s s t a b i l i t y )

Scilab code Exa 9.9 eect of addition of zeroes


1 // e f f e c t o f a d d i t i o n o f z e r o e s 2 s = %s ; 3 sys1 = syslin ( c ,1/( s *( s +1) *(2* s +1) ) ) // t a k i n g T1=1 ,T2 4 5 6 7

=2 nyquist ( sys1 ) show_margins ( sys1 , n y q u i s t ) sys2 = syslin ( c ,(3* s +1) /( s *( s +1) *(2* s +1) ) ) //Td=3 // n y q u i s t ( s y s 2 ) 91

Figure 9.8: eect of addition of poles

92

Figure 9.9: eect of addition of poles

93

Figure 9.10: eect of addition of zeroes


8 9

// s h o w m a r g i n s ( s y s 2 , n y q u i s t ) printf ( t h e s e two p l o t s show t h a t a d d i t i o n o f p o l e s i n c r e a s e s s t a b i l i t y )

Scilab code Exa 9.10 multiple loop systems


1

// m u l t i p l e l o o p s y s t e m s 94

Figure 9.11: eect of addition of zeroes

95

Figure 9.12: multiple loop systems

96

2 s = %s 3 innerloop = syslin ( c ,6/ s *( s +1) *( s +2) ) 4 nyquist ( innerloop ) 5 show_margins ( innerloop , n y q u i s t ) 6 printf ( n y q u i s t p l o t i n t e r s e c t s jw a x i s a t 1 s o 7 8 9 10 11 12 13 14 15

i n n e r l o o p i s marginally s t a b l e ) outerloop = syslin ( c ,100*( s +0.1) /( s +10) *( s ^3+3* s ^2+2* s +6) ) // n y q u i s t ( o u t e r l o o p ) show_margins ( outerloop , n y q u i s t ) P =0 // no o f p o l e s on RHP Pw =2 // no o f p o l e s on jw a x i s theta = -(Z -P -0.5* Pw ) *180 Z =0 // f o r o u t e r l o o p t o be s t a b l e disp ( theta , t h e t a f o r s t a b i l i t y = ) printf ( t h e t a a s s e e n from n y q u i s t p l o t i s same a s t h a t r e q u i r e d f o r s t a b i l i t y \n hence o u t e r l o o p i s s t a b l e )

Scilab code Exa 9.14 gain margin and phase margin


1 2 3 4 5 6 7 8 9

// g a i n m a r g i n and p h a s e m a r g i n s = %s ; sys = syslin ( c ,(2500) /( s *( s +5) *( s +50) ) ) nyquist ( sys ) show_margins ( sys , n y q u i s t ) gm = g_margin ( sys ) pm = p_margin ( sys ) disp ( gm , g a i n m a r g i n= ) disp ( pm , p h a s e m a r g i n= )

97

Figure 9.13: gain margin and phase margin

98

Figure 9.14: bode plot

99

Scilab code Exa 9.15 bode plot


1 2 3 4 5 6 7 8 9 10 11 12 13 14

// bode p l o t s = %s ; sys = syslin ( c ,(2500) /( s *( s +5) *( s +50) ) ) bode ( sys ) show_margins ( sys , bode ) gm = g_margin ( sys ) pm = p_margin ( sys ) disp ( gm , g a i n m a r g i n= ) disp ( pm , p h a s e m a r g i n= ) if ( gm <=0 | pm <=0) printf ( s y s t e m i s u n s t a b l e ) else printf ( s y s t e m i s s t a b l e ) end

Scilab code Exa 9.17 relative stability


1 // r e l a t i v e s t a b i l i t y 2 s = %s ; 3 sys = syslin ( c ,(100) *( s +5) *( s +40) /( s ^3*( s +100) *( s 4 5 6 7 8 9 10

+200) ) ) //K=1 bode ( sys ) show_margins ( sys , bode ) gm = g_margin ( sys ) pm = p_margin ( sys ) disp ( gm , g a i n m a r g i n= ) disp ( pm , p h a s e m a r g i n= ) if ( gm <=0 | pm <=0) 100

Figure 9.15: relative stability

101

11 12 13 14

printf ( s y s t e m i s u n s t a b l e ) else printf ( s y s t e m i s s t a b l e ) end

102

Das könnte Ihnen auch gefallen