Automatic Control Systems - B. C. Kuo and F. Golnaraghi
Automatic Control Systems - B. C. Kuo and F. Golnaraghi
Created by
Arpita V Huddar
B.Tech (pursuing)
Electronics Engineering
NIT Karnataka
College Teacher
S.Rekha
Cross-Checked by
Sonanya Tatikola, IITB
Edition: 7
Year: 1995
ISBN: 81-203-0968-5
1
Scilab numbering policy used in this document and the relation to 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.
2
Contents
2 Mathematical Foundation 6
3
List of Scilab Codes
4
Exa 3.7 masons gain formula . . . . . . . . . . . . . 18
Exa 3.9 masons gain formula . . . . . . . . . . . . . 19
Exa 3.10 masons gain formula . . . . . . . . . . . . . 20
Exa 3.11 masons gain formula . . . . . . . . . . . . . 21
Exa 4.1 transfer fnuction of system . . . . . . . . . . 23
Exa 4.2 transfer fnuction of electric network . . . . . 24
Exa 4.3 gear trains . . . . . . . . . . . . . . . . . . . 24
Exa 4.4 mass spring system . . . . . . . . . . . . . . 25
Exa 4.5 mass spring system . . . . . . . . . . . . . . 25
Exa 4.9 incremental encoder . . . . . . . . . . . . . 26
Exa 5.1 state transition equation . . . . . . . . . . . 28
Exa 5.7 characteristic equation from transfer function 29
Exa 5.8 characteristic equation from state equation . 29
Exa 5.9 eigen values . . . . . . . . . . . . . . . . . . 29
Exa 5.12 ccf form . . . . . . . . . . . . . . . . . . . . 30
Exa 5.13 ocf form . . . . . . . . . . . . . . . . . . . . 30
Exa 5.14 dcf form . . . . . . . . . . . . . . . . . . . . 31
Exa 5.18 system with identical eigen values . . . . . . 32
Exa 5.19 controllability . . . . . . . . . . . . . . . . . 32
Exa 5.20 controllability . . . . . . . . . . . . . . . . . 32
Exa 5.21 observability . . . . . . . . . . . . . . . . . . 33
Exa 6.1 stability of open loop systems . . . . . . . . 34
Exa 6.2 rouths tabulation to determine stability . . 35
Exa 6.3 rouths tabulation to determine stability . . 35
Exa 6.4 first element in any row of rouths tabulation
is z . . . . . . . . . . . . . . . . . . . . . . . 36
Exa 6.5 elements in any row of rouths tabulations are
all . . . . . . . . . . . . . . . . . . . . . . . 36
Exa 6.6 determining critical value of K . . . . . . . . 37
Exa 6.7 determining critical value of K . . . . . . . . 38
Exa 6.8 stability of closed loop systems . . . . . . . 39
Exa 6.9 bilinear transformation method . . . . . . . 39
Exa 6.10 bilinear transformation method . . . . . . . 40
Exa 7.1 type of system . . . . . . . . . . . . . . . . 41
Exa 7.2 steady state errors from open loop tf . . . . 41
Exa 7.3 steady state errors from closed loop tf . . . 43
Exa 7.4 steady state errors from closed loop tf . . . 44
Exa 7.5 steady state errors from closed loop tf . . . 46
5
Exa 7.6 steady state errors from closed loop tf . . . 48
Exa 8.1 poles and zeros . . . . . . . . . . . . . . . . 50
Exa 8.2 root locus . . . . . . . . . . . . . . . . . . . 50
Exa 8.3 root locus . . . . . . . . . . . . . . . . . . . 53
Exa 8.4 root locus . . . . . . . . . . . . . . . . . . . 54
Exa 8.5 root locus . . . . . . . . . . . . . . . . . . . 55
Exa 8.8 angle of departure and angle of arrivals . . . 56
Exa 8.9 multiple order pole . . . . . . . . . . . . . . 56
Exa 8.10 intersection of root loci with real axis . . . . 58
Exa 8.11 breakaway points . . . . . . . . . . . . . . . 60
Exa 8.12 breakaway points . . . . . . . . . . . . . . . 60
Exa 8.13 breakaway points . . . . . . . . . . . . . . . 62
Exa 8.14 breakaway points . . . . . . . . . . . . . . . 64
Exa 8.15 root sensitivity . . . . . . . . . . . . . . . . 64
Exa 8.16 calculation of K on root loci . . . . . . . . . 65
Exa 8.17 properties of root loci . . . . . . . . . . . . 68
Exa 8.18 effect of addition of poles to system . . . . . 68
Exa 8.19 effect of addition of zeroes to system . . . . 69
Exa 8.20 effect of moving poles near jw axis . . . . . 73
Exa 8.21 effect of moving poles awat from jw axis . . 73
Exa 9.1 nyquist plot . . . . . . . . . . . . . . . . . . 78
Exa 9.2 nyquist plot . . . . . . . . . . . . . . . . . . 78
Exa 9.3 stability of non minimum phase loop tf . . . 81
Exa 9.4 stability of minimum phase loop tf . . . . . 83
Exa 9.5 stability of non minimum phase loop tf . . . 83
Exa 9.6 stability of non minimum phase loop tf . . . 86
Exa 9.7 stability of non minimum phase loop tf . . . 86
Exa 9.8 effect of addition of poles . . . . . . . . . . . 88
Exa 9.9 effect of addition of zeroes . . . . . . . . . . 88
Exa 9.10 multiple loop systems . . . . . . . . . . . . . 91
Exa 9.14 gain margin and phase margin . . . . . . . . 94
Exa 9.15 bode plot . . . . . . . . . . . . . . . . . . . 96
Exa 9.17 relative stability . . . . . . . . . . . . . . . . 97
6
List of Figures
7
9.1 nyquist plot . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
9.2 nyquist plot . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
9.3 stability of non minimum phase loop tf . . . . . . . . . . . . 81
9.4 stability of minimum phase loop tf . . . . . . . . . . . . . . 82
9.5 stability of non minimum phase loop tf . . . . . . . . . . . . 84
9.6 stability of non minimum phase loop tf . . . . . . . . . . . . 85
9.7 stability of non minimum phase loop tf . . . . . . . . . . . . 87
9.8 effect of addition of poles . . . . . . . . . . . . . . . . . . . . 89
9.9 effect of addition of poles . . . . . . . . . . . . . . . . . . . . 90
9.10 effect of addition of zeroes . . . . . . . . . . . . . . . . . . . 91
9.11 effect of addition of zeroes . . . . . . . . . . . . . . . . . . . 92
9.12 multiple loop systems . . . . . . . . . . . . . . . . . . . . . . 93
9.13 gain margin and phase margin . . . . . . . . . . . . . . . . . 95
9.14 bode plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
9.15 relative stability . . . . . . . . . . . . . . . . . . . . . . . . . 97
8
Chapter 2
Mathematical Foundation
1 // l a p l a c e t r a n s f o r m o f unit function
2 syms t s
3 y = laplace ( ’ 1 ’ ,t , s )
4 disp (y , ”F ( s )=” )
1 // 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
2 syms t s ;
3 y = laplace ( ’ %eˆ( −1∗ t ) ’ ,t , s ) ;
4 disp (y , ” a n s=” )
1 // f i n a l v a l u e t h e r e o m
2 syms s
9
3 d = poly ([0 2 1 1] , ’ s ’ , ’ c o e f f ’ )
4 n = poly ([5] , ’ s ’ , ’ c o e f f ’ )
5 f=n/d;
6 disp (f , ”F ( s )=” )
7 x=s*f;
8 y = limit (x ,s ,0) ; // f i n a l v a l u e t h e o r e m
9 disp (y , ” f ( i n f )=” )
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 ”)
1 // p a r t i a l f r a c t i o n s
2 n = poly ([3 5] , ’ s ’ , ’ c o e f f ’ )
3 d = poly ([6 11 6 1] , ’ s ’ , ’ c o e f f ’ )
4 f=n/d;
5 disp (f , ”F ( s )=” )
6 pf = pfss ( f )
7 disp ( pf )
10
Scilab code Exa 2.7 inverse laplace transform
1 // i n v e r s e l a p l a c e t r a n s f o r m
2 n = poly ([4] , ’ s ’ , ’ c o e f f ’ )
3 d = poly ([4 8 1] , ’ s ’ , ’ c o e f f ’ ) //w=2 , damping r a t i o =2
4 G=n/d;
5 disp (G , ”G( s )=” )
6 pf = pfss ( G )
7 disp ( pf , ”G( s )=” )
8 syms s t
9 g1 = ilaplace ( pf (1) ,s , t )
10 g2 = ilaplace ( pf (2) ,s , t )
11 disp ( g1 + g2 , ” g ( t )=” )
1 // i n v e r s e l a p l a c e t r a n s f o r m
2 n = poly ([5 -1 -1] , ’ s ’ , ’ c o e f f ’ )
3 d = poly ([0 -1 -2] , ’ s ’ , ’ r o o t s ’ )
4 Y=n/d;
5 disp (Y , ”Y( s )=” )
6 pf = pfss ( Y )
7 disp ( pf , ”Y( s )=” )
8 syms s t
9 y1 = ilaplace ( pf (1) ,s , t )
10 y2 = ilaplace ( pf (2) ,s , t )
11 y3 = ilaplace ( pf (3) ,s , t )
12 disp ( y1 + y2 + y3 , ” g ( t )=” )
13 l = limit ( Y *s ,s ,0)
14 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 =” )
11
1 // i n v e r s e l a p l a c e t r a n s f o r m
2 n = poly ([1000] , ’ s ’ , ’ c o e f f ’ )
3 d = poly ([0 1000 34.5 1] , ’ s ’ , ’ c o e f f ’ )
4 Y=n/d;
5 disp (Y , ”Y( s )=” )
6 pf = pfss ( Y )
7 disp ( pf , ”Y( s )=” )
8 syms s t
9 y1 = ilaplace ( pf (1) ,s , t )
10 y2 = ilaplace ( pf (2) ,s , t )
11 y3 = ilaplace ( pf (3) ,s , t )
12 disp ( y1 + y2 + y3 , ” y ( t )=” )
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 )
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 )
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 )
1 // e q u a l i t y o f m a t r i c e s
2 A =[1 2;3 4]
3 B =[1 2;3 4]
4 x =1;
5 for i =1:2
6 for j =1:2
7 if A (i , j ) ~= B (i , j ) then
8 x =0
9 end
10 end
11 end
12 if x ==1 then
13 disp ( ” m a t r i c e s a r e e q u a l ” )
14 else
15 disp ( ” m a t r i c e s a r e n o t e q u a l ” )
16 end
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 // 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
2 A =[1 2 3;4 5 6]
3 B =[1 2 3]
4 C = size ( A )
5 D = size ( B )
6 if C (1 ,2) == D (1 ,1) then
7 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” )
8 else
9 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” )
10 end
11 if D (1 ,2) == C (1 ,1) then
12 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” )
13 else
14 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” )
15 end
1 // m u l t i p l i c a t i o n o f m a t r i c e s
2 A =[3 -1;0 1;2 0]
3 B =[1 0 -1;2 1 0]
4 C = size ( A )
5 D = size ( B )
6 if C (1 ,2) == D (1 ,1) then
7 AB = A * B
8 disp ( AB , ”AB=” )
14
9 else
10 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
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 , ”Aˆ−1=” )
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
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 , ”Aˆ−1=” )
15
7 else
8 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
1 // r a n k o f a m a t r i x
2 A =[0 1;0 1]
3 [E ,Q , Z , stair , rk1 ]= ereduc (A ,1. d -15)
4 disp ( rk1 , ” r a n k o f A=” )
5 B =[0 5 1 4;3 0 3 2]
6 [E ,Q , Z , stair , rk2 ]= ereduc (B ,1. d -15)
7 disp ( rk2 , ” r a n k o f B=” )
8 C =[3 9 2;1 3 0;2 6 1]
9 [E ,Q , Z , stair , rk3 ]= ereduc (C ,1. d -15)
10 disp ( rk3 , ” r a n k o f C=” )
11 D =[3 0 0;1 2 0;0 0 1]
12 [E ,Q , Z , stair , rk4 ]= ereduc (D ,1. d -15)
13 disp ( rk4 , ” r a n k o f D=” )
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=” )
1 // z t r a n s f o r m
2 // t=k ∗T
3 syms k z ;
4 a =1;
5 T =1;
6 x = %e ^ -( a * k * T ) ;
7 X = symsum ( x *( z ^( - k ) ) ,k ,0 , %inf )
8 disp (X , ” a n s=” )
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
1 // 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
2 s = %s
3 G =[1/( s +1) -1/ s ;2 1/( s +2) ]
4 H =[1 0;0 1]
5 GH = G * H
6 disp ( GH , ”G( s )H( s )=” )
7 I =[1 0;0 1]
8 x = I + GH
9 y = inv ( x )
10 M=y*G
11 disp (M , ”M( s )=” )
Scilab code Exa 3.3 masons gain formula applied to SFG in figure 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
forward path
4 L11 = - G * H // o n l y one l o o p and no non t o u c h i n g
loops
5 delta =1 - L11
6 delta1 =1
7 Y = M1 * delta1 / delta
8 disp (Y , ”Y( s ) /R( s )=” )
19
22 disp (y , ” y2 / y1=” )
20
Scilab code Exa 3.6 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 // 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
3 //E a s o u t p u t node
4 syms G1 G2 G3 G4 H1 H2
5 M1 =1
6 L11 = - G1 * G2 * H1
7 L21 = - G2 * G3 * H2
8 L31 = - G1 * G2 * G3
9 L41 = - G1 * G4
10 L51 = - G4 * H2
11 delta =1 -( L11 + L21 + L31 + L41 + L51 )
12 delta1 =1 -( L21 + L51 + L11 )
13 x = M1 * delta1 / delta
14 disp (x , ”E( s ) /R( s )=” )
15 //Y a s o u t p u t node
16 M1 = G1 * G2 * G3
17 M2 = G1 * G4
18 delta1 =1
19 delta2 =1
20 y =( M1 * delta1 + M2 * delta2 ) / delta
21 disp (y , ”Y( s ) /R( s )=” )
1 // 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
2 // 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
3 syms s
4 // 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
5 M1 = s ^ -1* s ^ -1
6 L11 = -3* s ^ -1
7 L21 = -2* s ^ -1* s ^ -1
8 delta =1 -( L11 + L21 )
9 delta1 =1
10 x = M1 * delta1 / delta
11 disp (x , ”Y( s ) /R( s )=” )
22
Scilab code Exa 3.10 masons gain formula
1 // 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
2 // r ( t ) , x1 ( t ) and x2 ( 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
5
6 syms s r x1 x2
7 // r ( t ) a s i n p u t node and y ( t ) a s o u t p u t node
8 M1 =0
9 delta1 =1
10 delta =1
11 a =( M1 * delta1 ) / delta
12 y1 = a * r
13 disp ( y1 , ” y1 ( t )=” )
14
15 // x1 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node
16 M1 =1
17 delta1 =1
18 b =( M1 * delta1 ) / delta
19 y2 = b * x1
20 disp ( y2 , ” y2 ( t )=” )
21
22 // x2 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node
23 M1 =0
24 delta1 =1
25 c =( M1 * delta1 ) / delta
26 y3 = c * x2
27 disp ( y3 , ” y3 ( t )=” )
28
29 disp ( y1 + y2 + y3 , ” y ( t )=” )
23
Scilab code Exa 3.11 masons gain formula
1 // 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
5
6 syms s a0 a1 a2 a3 r x1 x2 x3
7 // r ( t ) a s i n p u t node and y ( t ) a s o u t p u t node
8 M1 =0
9 delta1 =1
10 L11 = - a0 * a3
11 delta =1 -( L11 )
12 a =( M1 * delta1 ) / delta
13 y1 = a * r
14 disp ( y1 , ” y1 ( t )=” )
15
16 // x1 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node
17 M1 =1
18 delta1 =1
19 b =( M1 * delta1 ) / delta
20 y2 = b * x1
21 disp ( y2 , ” y2 ( t )=” )
22
23 // x2 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node
24 M1 =0
25 delta1 =1
26 c =( M1 * delta1 ) / delta
27 y3 = c * x2
28 disp ( y3 , ” y3 ( t )=” )
29
30 // x3 ( t ) a s i n p u t node and y ( t ) a s o u t p u t node
31 M1 = a0
32 delta1 =1
33 d =( M1 * delta1 ) / delta
34 y4 = d * x3
35 disp ( y4 , ” y4 ( t )=” )
24
36
37 disp ( y1 + y2 + y3 + y4 , ” y ( t )=” )
25
Chapter 4
Mathematical Modelling of
Physical Systems
1 // 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
2 // from s t a t e d i a g r a m i n 4 −1(b )
3 // 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
4 // 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
5 syms R L C
6 s = %s
7 M1 =(1/ L ) *( s ^ -1) *(1/ C ) *( s ^ -1)
8 L11 = -( s ^ -1) *( R / L )
9 delta =1 -( L11 )
10 delta1 =1
11 x = M1 * delta1 / delta
12 disp (x , ” Ec ( s ) /E( s )=” )
13 // 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
14 M1 =(1/ L ) *( s ^ -1)
15 delta1 =1
16 y = M1 * delta1 / delta
17 disp (y , ” I ( s ) /E( s )=” )
26
Scilab code Exa 4.2 transfer fnuction of electric network
1 // 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
2 // from s t a t e d i a g r a m i n 4 −2(b )
3 // 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
4 // c o n s i d e r i n g i 1 a s o u t p u t
5 syms R1 R2 L1 L2 C
6 s = %s
7 M1 =(1/ L1 ) *( s ^ -1)
8 L11 = -( s ^ -1) *( R1 / L1 )
9 L21 = -( s ^ -1) *(1/ C ) *( s ^ -1) *(1/ L1 )
10 L31 = -( s ^ -1) *(1/ L2 ) *( s ^ -1) *(1/ C )
11 L41 = -( s ^ -1) *( R2 / L2 )
12 L12 = L11 * L31
13 L22 = L11 * L41
14 L32 = L21 * L41
15 delta =1 -( L11 + L21 + L31 + L41 ) +( L12 + L22 + L32 )
16 delta1 =1 -( L31 + L41 )
17 x = M1 * delta1 / delta
18 disp (x , ” I 1 ( s ) /E( s )=” )
19 // c o n s i d e r i n g i 2 a s o u t p u t
20 M1 =(1/ L1 ) *( s ^ -1) *(1/ C ) *( s ^ -1) *(1/ L2 ) *( s ^ -1)
21 delta1 =1
22 y = M1 * delta1 / delta
23 disp (y , ” I 2 ( s ) /E( s )=” )
24 // 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
25 M1 =(1/ L1 ) *( s ^ -1) *(1/ C ) *( s ^ -1)
26 delta1 =1 - L41
27 z = M1 * delta1 / delta
28 disp (z , ” Ec ( s ) /E( s )=” )
27
1 // g e a r t r a i n s
2 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 ” )
3 J2 =0.05;
4 disp ( J2 , ” J2=” )
5 T2 =2;
6 disp ( T2 , ”T2=” )
7 r =1/5
8 disp (r , ”N1/N2=” )
9 printf ( ” J1 =(N1/N2 ) ˆ2∗ J2 \n T1=(N1/N2 ) ∗T2” )
10 J1 =( r ) ^2* J2 ;
11 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=” )
12 T1 =( r ) * T2
13 disp ( T1 , ” The r e f l e c t e d coulumb f r i c t i o n i s =” )
1 // mass−s p r i n g s y s t e m
2 // 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 )
3 // 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
4 syms K M B
5 s = %s
6 M1 =(1/ M ) *( s ^ -2)
7 L11 = -( B / M ) *( s ^ -1)
8 L21 = -( K / M ) *( s ^ -2)
9 delta =1 -( L11 + L21 )
10 delta1 =1
11 x = M1 * delta1 / delta
12 disp (x , ”Y( s ) /F ( s )=” )
28
1 // mass−s p r i n g s y s t e m
2 // 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 )
3 // 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
4 syms K M B
5 s = %s
6 // c o n s i d e r i n g y1 a s o u t p u t
7 M1 =(1/ M )
8 L11 = -( B / M ) *( s ^ -1)
9 L21 = -( K / M ) *( s ^ -2)
10 L31 =( K / M ) *( s ^ -2)
11 delta =1 -( L11 + L21 + L31 )
12 delta1 =1 -( L11 + L21 )
13 x = M1 * delta1 / delta
14 disp (x , ”Y1 ( s ) /F ( s )=” )
15 // c o n s i d e r i n g y2 a s o u t p u t
16 M1 =(1/ K ) *( K / M ) *( s ^ -2)
17 delta1 =1
18 y = M1 * delta1 / delta
19 disp (y , ”Y2 ( s ) /F ( s )=” )
1 // i n c r e m e n t a l e n c o d e r
2 // 2 s i n u s o i d a l s i g n a l s
3 // 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 )
4 // 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 )
5 zc =4
6 ch =96
7 cyc =480
8 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
9 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 =” )
10 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
11 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
1 // s t a t e t r a n s i t i o n e q u a t i o n
2 // 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;
3 A =[0 1; -2 -3]
4 B =[0;1]
5 s = poly (0 , ’ s ’ ) ;
6 [ Row Col ]= size ( A ) // S i z e o f a m a t r i x
7 m = s * eye ( Row , Col ) -A // s I −A
8 n = det ( m ) //To Find The D e t e r m i n a n t o f s i
−A
9 p = inv ( m ) ; // To Find The I n v e r s e Of s I −A
10 U =1/ s
11 p=p*U
12 syms t s ;
13 disp (p , ” p h i ( s )=” ) // R e s o l v e n t M a t r i x
14 for i =1: Row
15 for j =1: Col
16 // 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 )
17 q (i , j ) = ilaplace ( p (i , j ) ,s , t ) ;
18 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 .= ” )
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 function
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=” )
1 // 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
2 A =[0 1 0;0 0 1; -2 -1 -5]
3 B =[0;0;1]
4 C =[1 0 0]
5 D =[0]
6 [ Row Col ]= size ( A )
7 Gr = C * inv ( s * eye ( Row , Col ) -A ) * B + D
8 c = denom ( Gr )
9 disp (c , ” c h a r a c t e r i s t i c e q u a t i o n=” )
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 eigen values of matrix
4 disp (e , ” e i g e n v a l u e s=” )
32
Scilab code Exa 5.12 ccf form
1 //OCF form
2 s = %s
3 A =[1 2 1;0 1 3;1 1 1]
4 B =[1;0;1]
5 [ row , col ]= size ( A )
6 c = s * eye ( row , col ) -A
7 x = det ( c )
8 r = coeff ( x )
9 M =[ r (1 ,2) r (1 ,3) 1; r (1 ,3) 1 0;1 0 0]
10 S =[ B A * B A ^2* B ]
11 disp (S , ” c o n t r o l l a b i l i t y m a t r i x=” )
12 if ( det ( S ) ==0) then
13 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 ” )
14 else
15 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 ”
)
16 end
17 P=S*M
18 disp (P , ”P=” )
19 Accf = inv ( P ) * A * P
20 Bccf = inv ( P ) * B
21 disp ( Accf , ” A c c f=” )
22 disp ( Bccf , ” B c c f=” )
1 //OCF form
2 A =[1 2 1;0 1 3;1 1 1]
33
3 B =[1;0;1]
4 C =[1 1 0]
5 D =0
6 [ row , col ]= size ( A )
7 c = s * eye ( row , col ) -A
8 x = det ( c )
9 r = coeff ( x )
10 M =[ r (1 ,2) r (1 ,3) 1; r (1 ,3) 1 0;1 0 0]
11 V =[ C ; C * A ; C * A ^2]
12 disp (V , ” o b s e r v a b i l i t y m a t r i x=” )
13 if ( det ( V ) ==0) then
14 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 ” )
15 else
16 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 ”
)
17 end
18 Q = inv ( M * V )
19 disp (Q , ”Q=” )
20 Aocf = inv ( Q ) * A * Q
21 Cocf = C * Q
22 B = inv ( Q ) * B
23 disp ( Aocf , ” A o c f=” )
24 disp ( Cocf , ” C o c f=” )
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 // 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
2 A =[1 0;0 1] // lamda1=1
3 B =[2;3] // b11=2 b21=3
4 S =[ B A * B ]
5 if det ( S ) ==0 then
6 printf ( ” s y s t e m i s u n c o n t r o l l a b l e ” )
7 else
8 printf ( ” s y s t e m i s c o n t o l l a b l e ” )
9 end
1 // c o n t r o l l a b i l i t y
2 A =[ -2 1;0 -1]
3 B =[1;0]
4 S =[ B A * B ]
5 if det ( S ) ==0 then
6 printf ( ” s y s t e m i s u n c o n t r o l l a b l e ” )
7 else
8 printf ( ” s y s t e m i s c o n t o l l a b l e ” )
9 end
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 i s u n c o n t r o l l a b l e ”)
7 else
8 printf ( ” s y s t e m i s c o n t o l l a b l e ”)
9 end
1 // o b s e r v a b i l i t y
2 A =[ -2 0;0 -1]
3 B =[3;1]
4 C =[1 0]
5 V =[ C ; C * A ]
6 if det ( V ) ==0 then
7 printf ( ” s y s t e m i s u n o b s e r v a b l e ” )
8 else
9 printf ( ” s y s t e m i s o b s e r v a b l e ” )
10 end
36
Chapter 6
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
z e r o e s i n RHP” )
6 sys2 = syslin ( ’ c ’ ,20*( s +1) /(( s -1) *( s ^2+2* s +2) ) )
7 disp ( sys2 , ”M( s )=” )
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 s =1” )
9 sys3 = syslin ( ’ c ’ ,20*( s -1) /(( s +2) *( s ^2+4) ) )
10 disp ( sys3 , ”M( s )=” )
11 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 ” )
12 sys4 = syslin ( ’ c ’ ,10/(( s +10) *( s ^2+4) ^2) )
13 disp ( sys4 , ”M( s )=” )
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 s=j 2 and s=−j 2 ” )
15 sys5 = syslin ( ’ c ’ ,10/( s ^4+30* s ^3+ s ^2+10* s ) )
16 disp ( sys5 , ”M( s )=” )
37
17 printf ( ” s y s 5 i s s t a b l e i f p o l e a t s =0 i s p l a c e d
i n t e n t i o n a l l y ”)
1 // 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
2 s = %s ;
3 m = s ^3 -4* s ^2+ s +6;
4 disp ( m )
5 r = coeff ( m )
6 n = length ( r )
7 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
8 disp ( routh , ” r o u t h s t a b u l a t i o n=” )
9 c =0;
10 for i =1: n
11 if ( routh (i ,1) <0)
12 c = c +1;
13 end
14 end
15 if (c >=1)
16 printf ( ” s y s t e m i s u n s t a b l e ” )
17 else printf ( ” s y s t e m i s s t a b l e ” )
18 end
1 // 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
2 s = %s ;
3 m =2* s ^4+ s ^3+3* s ^2+5* s +10;
4 disp ( m )
5 r = coeff ( m )
6 n = length ( r )
38
7 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
8 disp ( routh , ” r o u t h s t a b u l a t i o n=” )
9 c =0;
10 for i =1: n
11 if ( routh (i ,1) <0)
12 c = c +1;
13 end
14 end
15 if (c >=1)
16 printf ( ” s y s t e m i s u n s t a b l e ” )
17 else printf ( ” s y s t e m i s s t a b l e ” )
18 end
Scilab code Exa 6.4 first element in any row of rouths tabulation is z
1 // 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
2 s = %s
3 m = s ^4+ s ^3+2* s ^2+2* s +3
4 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
5 n = length ( r ) ;
6 routh = routh_t ( m )
7 disp ( routh , ” r o u t h=” )
8 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
1 // 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 ;
39
3 m = s ^5+4* s ^4+8* s ^3+8* s ^2+7* s +4;
4 disp ( m )
5 r = coeff ( m )
6 n = length ( r )
7 routh = routh_t ( m )
8 disp ( routh , ” r o u t h s t a b u l a t i o n s=” )
9 c =0;
10 for i =1: n
11 if ( routh (i ,1) <0)
12 c = c +1;
13 end
14 end
15 if (c >=1)
16 printf ( ” s y s t e m i s u n s t a b l e ” )
17 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 ” )
18 end
1 // 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
2 s = %s
3 syms K
4 m = s ^3+3408.3* s ^2+1204000* s +1.5*10^7* K
5 cof_a_0 = coeffs (m , ’ s ’ ,0) ;
6 cof_a_1 = coeffs (m , ’ s ’ ,1) ;
7 cof_a_2 = coeffs (m , ’ s ’ ,2) ;
8 cof_a_3 = coeffs (m , ’ s ’ ,3) ;
9
10 r =[ cof_a_0 cof_a_1 cof_a_2 cof_a_3 ]
11
12 n = length ( r ) ;
13 routh =[ r ([4 ,2]) ; r ([3 ,1]) ];
14 routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0];
15 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 )=” )
1 // 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
2 s = %s
3 syms K
4 m = s ^3+3* K * s ^2+( K +2) * s +4
5 cof_a_0 = coeffs (m , ’ s ’ ,0) ;
6 cof_a_1 = coeffs (m , ’ s ’ ,1) ;
7 cof_a_2 = coeffs (m , ’ s ’ ,2) ;
8 cof_a_3 = coeffs (m , ’ s ’ ,3) ;
9
10 r =[ cof_a_0 cof_a_1 cof_a_2 cof_a_3 ]
11
12 n = length ( r ) ;
13 routh =[ r ([4 ,2]) ; r ([3 ,1]) ];
14 routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0];
15 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
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 ’ ,s *(3* s +1) /( s ^3+2* s +4) )
20 k = kpure ( sys )
41
21 disp (k , ”K( m a r g i n a l )=” )
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” )
1 // b i l i n e a r t r a n s f o r m a t i o n method
2 r = %s
3 // p=z ˆ 3 + 5 . 9 4 ∗ z ˆ 2 + 7 . 7 ∗ z −0.368
4 // s u b s t i t u t i n g z =(1+ r ) /(1 − r ) we g e t
5 m =3.128* r ^3 -11.47* r ^2+2.344* r +14.27
6 x = coeff ( m )
7 n = length ( x )
8 routh = routh_t ( m )
9 disp ( routh , ” r o u t h s t a b u l a t i o n s ” )
10 c =0;
11 for i =1: n
42
12 if ( routh (i ,1) <0) then
13 c = c +1
14 end
15 end
16 if (c >=1) then
17 printf ( ” s y s t e m i s u n s t a b l e ” )
18 else printf ( ” s y s t e m i s s t a b l e ” )
19 end
1 // b i l i n e a r t r a n s f o r m a t i o n method
2 s = %s
3 syms K
4 // p=z ˆ3+ z ˆ2+ z+K
5 // s u b s t i t u t i n g z =(1+ r ) /(1 − r ) we g e t
6 m =(1 - K ) * s ^3+(1+3* K ) * s ^2+3*(1 - K ) * s +3+ K
7 cof_a_0 = coeffs (m , ’ s ’ ,0) ;
8 cof_a_1 = coeffs (m , ’ s ’ ,1) ;
9 cof_a_2 = coeffs (m , ’ s ’ ,2) ;
10 cof_a_3 = coeffs (m , ’ s ’ ,3) ;
11
12 r =[ cof_a_0 cof_a_1 cof_a_2 cof_a_3 ]
13
14 n = length ( r ) ;
15 routh =[ r ([4 ,2]) ; r ([3 ,1]) ];
16 routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0];
17 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
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
1 // 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
44
5 disp (G , ”G( s )=” )
6 H =1;
7 y=G*H;
8 disp (y , ”G( s )H( s )=” )
9 syms s ;
10 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
11 Ess =1/ Kv
12 // 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
13 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 ” )
14 disp ( Kv , ” ramp i n p u t Kv=” )
15 disp ( Ess , ” E s s=” )
16 // t y p e 2 s y s t e m
17 p = poly ([1] , ’ s ’ , ’ c o e f f ’ ) ;
18 q = poly ([0 0 12 1] , ’ s ’ , ’ c o e f f ’ ) ;
19 G = p / q ; //K=1
20 disp (G , ”G( s )=” )
21 H =1;
22 y=G*H;
23 disp (y , ”G( s )H( s )=” )
24 Ka = limit ( s ^2* y ,s ,0) ; //Ka= p a r a b o l i c e r r o r
coefficient
25 Ess =1/ Ka
26 // 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
27 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 ” )
28 disp ( Ka , ” p a r a b o l i c i n p u t Ka=” )
29 disp ( Ess , ” E s s=” )
30 // t y p e 2 s y s t e m
31 p = poly ([5 5] , ’ s ’ , ’ c o e f f ’ ) ;
32 q = poly ([0 0 60 17 1] , ’ s ’ , ’ c o e f f ’ ) ;
33 G = p / q ; //K=1
34 disp (G , ”G( s )=” )
35 H =1;
36 y=G*H;
37 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 // 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
2 s = %s
3 p = poly ([3.15 1 0] , ’ s ’ , ’ c o e f f ’ ) ; //K=1
4 q = poly ([3.15 1.75 2 1] , ’ s ’ , ’ c o e f f ’ ) ;
5 M=p/q
6 disp (M , ”M( s )=” )
7 H =1;
8 R =1;
9 b = coeff ( p )
10 a = coeff ( q )
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” )
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=” )
18 end
19
20 // ramp i n p u t
21 c =0
22 for i =1:2
46
23 if ( a (1 , i ) -b (1 , i ) * H ==0) then
24 c = c +1
25 end
26 end
27 if ( c ==2)
28 printf ( ” f o r u n i t ramp i n p u t E s s=0” )
29 else if ( c ==1) then
30 Ess =( a (1 ,2) -b (1 ,2) * H ) / a (1 ,1) * H
31 disp ( Ess , ” f o r u n i t ramp i n p u t E s s=” )
32 else printf ( ” f o r u n i t ramp i n p u t E s s= i n f ” )
33 end
34 end
35
36 // p a r a b o l i c i n p u t
37 c =0
38 for i =1:3
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” )
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 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
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 s = %s
3 p = poly ([5 5 0] , ’ s ’ , ’ c o e f f ’ ) ;
4 q = poly ([5 5 60 17 1] , ’ s ’ , ’ c o e f f ’ ) ;
5 M=p/q
6 disp (M , ”M( s )=” )
7 H =1;
8 R =1;
9 b = coeff ( p )
10 a = coeff ( q )
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=” )
18 end
19
20 // ramp i n p u t
21 c =0
22 for i =1:2
23 if ( a (1 , i ) -b (1 , i ) * H ==0) then
24 c = c +1
25 end
26 end
27 if ( c ==2)
28 printf ( ” f o r u n i t ramp i n p u t E s s=0 \n ” )
29 else if ( c ==1) then
30 Ess =( a (1 ,2) -b (1 ,2) * H ) / a (1 ,1) * H
31 disp ( Ess , ” f o r u n i t ramp i n p u t E s s=” )
32 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 input
37 c =0
38 for i =1:3
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 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
Scilab code Exa 7.5 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
2 s = %s
3 p = poly ([5 1 0] , ’ s ’ , ’ c o e f f ’ ) ;
4 q = poly ([5 5 60 17 1] , ’ s ’ , ’ c o e f f ’ ) ;
5 M=p/q
6 disp (M , ”M( s )=” )
7 H =1;
8 R =1;
9 b = coeff ( p )
10 a = coeff ( q )
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=” )
49
18 end
19
20 // ramp i n p u t
21 c =0
22 for i =1:2
23 if ( a (1 , i ) -b (1 , i ) * H ==0) then
24 c = c +1
25 end
26 end
27 if ( c ==2)
28 printf ( ” f o r u n i t ramp i n p u t E s s=0 \n ” )
29 else if ( c ==1) then
30 Ess =( a (1 ,2) -b (1 ,2) * H ) / a (1 ,1) * H
31 disp ( Ess , ” f o r u n i t ramp i n p u t E s s=” )
32 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 i n p u t
37 c =0
38 for i =1:3
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 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
50
Scilab code Exa 7.6 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
2 s = %s
3 p = poly ([5 1 0] , ’ s ’ , ’ c o e f f ’ ) ;
4 q = poly ([10 10 60 17 1] , ’ s ’ , ’ c o e f f ’ ) ;
5 M=p/q
6 disp (M , ”M( s )=” )
7 H =2;
8 R =1;
9 b = coeff ( p )
10 a = coeff ( q )
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 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 s t e p i n p u t E s s=” )
18 end
19
20 // ramp i n p u t
21 c =0
22 for i =1:2
23 if ( a (1 , i ) -b (1 , i ) * H ==0) then
24 c = c +1
25 end
26 end
27 if ( c ==2)
28 printf ( ” f o r ramp i n p u t E s s=0 \n ” )
29 else if ( c ==1) then
30 Ess =( a (1 ,2) -b (1 ,2) * H ) / a (1 ,1) * H
31 disp ( Ess , ” f o r ramp i n p u t E s s=” )
51
32 else printf ( ” f o r 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 i n p u t
37 c =0
38 for i =1:3
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 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 p a r a b o l i c i n p u t E s s=” )
48 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
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 ” )
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
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
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 is
symmetrical to that point ”)
57
Figure 8.5: root locus
1 // r o o t l o c u s
2 s = %s
3 sys = syslin ( ’ c ’ ,( s +1) /( s *( s +4) *( s ^2+2* s +2) ) )
4 clf
5 evans ( sys )
6 n =4;
7 disp (n , ” no o f p o l e s=” )
8 m =1;
9 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 poles of
G( s )H( s ) ) −(sum o f a l l r e a l p a r t o f z e r o s o f G( s )H
( s ) ) / ( n−m) \n ” )
23 C =((0 -4 -1 -1) -( -1) ) /( n - m ) ;
24 disp (C , ” c e n t r o i d=” )
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 ) ” )
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 s = %s
3 sys = syslin ( ’ c ’ ,1/( s *( s +3) *( s ^2+2* s +2) ) )
4 clf
5 evans ( sys )
6 K = kpure ( sys )
7 disp (K , ” v a l u e o f K where RL c r o s s e s jw a x i s=” )
8 p = poly ([ K 6 8 5 1] , ’ s ’ , ’ c o e f f ’ )
9 x = roots ( p )
10 x1 = clean ( x (1 ,1) )
11 x2 = clean ( x (2 ,1) )
12 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 // breakaway p o i n t s
2 s = %s
3 sys = syslin ( ’ c ’ ,( s +4) /( s *( s +2) ) )
4 evans ( sys )
5 syms s
6 d = derivat ( sys )
7 n = numer ( d )
8 a = roots ( n ) // a=breakaway p o i n t s
9 disp (a , ” breakaway p o i n t s=” )
10 for i =1:2
11 K = - a (i ,1) *( a (i ,1) +2) /( a (i ,1) +4)
12 disp ( a (i ,1) ,” s=” )
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” )
1 // breakaway p o i n t s
2 s = %s
3 sys = syslin ( ’ c ’ ,( s +2) /( s ^2+2* s +2) )
4 evans ( sys )
5 syms s
6 d = derivat ( sys )
7 n = numer ( d )
8 a = roots ( n ) // a=breakaway p o i n t s
9 disp (a , ” breakaway p o i n t s=” )
10 for i =1:2
11 K = -( a (i ,1) ^2+2* a (i ,1) +2) /( a (i ,1) +2)
12 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” )
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 syms s
6 d = derivat ( sys )
7 n = numer ( d )
8 a = roots ( n ) // a=breakaway p o i n t s
9 disp (a , ” breakaway p o i n t s=” )
10 for i =1:3
11 K = - a (i ,1) *( a (i ,1) +4) *( a (i ,1) ^2+4* a (i ,1) +20)
12 disp ( a (i ,1) ,” s=” )
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” )
66
Scilab code Exa 8.14 breakaway points
1 // breakaway p o i n t s
2 s = %s
3 sys = syslin ( ’ c ’ ,1/( s *( s ^2+2* s +2) ) )
4 evans ( sys )
5 syms s
6 d = derivat ( sys )
7 n = numer ( d )
8 a = roots ( n ) // a=breakaway p o i n t s
9 disp (a , ” breakaway p o i n t s=” )
10 for i =1:2
11 K = - a (i ,1) ^2+2* a (i ,1) +2
12 disp ( a (i ,1) ,” s=” )
13 disp (K , ”K=” )
14 end
15 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 ” )
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
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
6 printf ( ”K=A∗B/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 ” )
7 A = sqrt (( -1) ^2+1^2)
8 B = sqrt (( -1) ^2+( -1) ^2)
9 C = -2
10 K=A*B/C
11 disp (K , ” v a l u e o f K a t s =0 i s ” )
1 // p r o p e r t i e s o f r o o t l o c i
2 s = %s
3 sys = syslin ( ’ c ’ ,( s +3) /( s *( s +5) *( s +6) *( s ^2+2* s +2) ) )
4 d = denom ( sys )
5 n = numer ( sys )
6 p = roots ( d )
7 z = roots ( n )
8 disp (p , ” p o l e s o f s y s=” )
9 disp (z , ” z e r o e s o f s y s=” )
10 n = length ( p )
11 m = length ( z )
12 disp (n , ” no o f p o l e s=” )
13 disp (m , ” no o f z e r o e s=” )
14 if (n > m ) then
15 disp (n , ” no o f b r a n c h e s o f RL=” )
16 else
17 disp (m , ” no o f b r a n c h e s o f CRL=” )
18 end
19 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 ”)
71
Figure 8.15: effect 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: effect of addition of poles to system
73
Figure 8.17: effect 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: effect of addition of zeroes to system
75
Scilab code Exa 8.20 effect 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) ) ) // a=10 b=1
4 evans ( sys1 )
5 sys2 = syslin ( ’ c ’ ,( s +1) /( s ^2*( s +9) ) ) // a=9
6 evans ( sys2 )
7 sys3 = syslin ( ’ c ’ ,( s +1) /( s ^2*( s +8) ) ) // a=8
8 evans ( sys3 )
9 sys4 = syslin ( ’ c ’ ,( s +1) /( s ^2*( s +3) ) ) // a=3
10 evans ( sys4 )
11 sys5 = syslin ( ’ c ’ ,( s +1) /( s ^2*( s +1) ) ) // a=1
12 evans ( sys5 )
13 printf ( ” a s p o l e i s moved t o w a r d s jw 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 effect of moving poles awat from jw axis
76
Figure 8.19: effect of moving poles near jw axis
77
Figure 8.20: effect of moving poles near jw axis
78
Figure 8.21: effect of moving poles awat from jw axis
79
Figure 8.22: effect of moving poles awat from jw axis
80
Chapter 9
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<” )
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
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 show_margins ( sys , ’ n y q u i s t ’ )
6 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 ”)
7 Z =0 // no o f z e r o e s o f 1+G( s )H( s ) i n RHP
8 P =2 // no o f p o l e s i n RHP
9 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
10 theta =( Z -P -0.5* Pw ) *180
11 disp ( theta , ” t h e t a=” )
12 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 // 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
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 Z =0 // no o f z e r o e s o f 1+G( s )H( s ) i n RHP
7 P =0 // no o f p o l e s i n RHP
8 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
9 theta =( Z -P -0.5* Pw ) *180
10 disp ( theta , ” t h e t a=” )
11 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 ”)
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 -1) / s *( s +1) )
4 nyquist ( sys )
5 show_margins ( sys , ’ n y q u i s t ’ )
6 P =0 // no o f p o l e s i n RHP
7 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
8 theta =90 // a s s e e n from n y q u i s t p l o t
9 Z =( theta /180) +0.5* Pw + P
10 disp (Z , ”Z=” )
11 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 // 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 ’ ,10*( s +2) /( s ^3+3* s ^2+10) )
4 nyquist ( sys )
5 show_margins ( sys , ’ n y q u i s t ’ )
6 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 ”)
7 Z =0 // no o f z e r o e s o f 1+G( s )H( s ) i n RHP
8 P =2 // no o f p o l e s i n RHP
9 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
10 theta =( Z -P -0.5* Pw ) *180
11 disp ( theta , ” t h e t a f o r s t a b i l i t y =” )
12 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 ”)
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 ’ ,1/( s +2) *( s ^2+4) )
4 nyquist ( sys )
5 show_margins ( sys , ’ n y q u i s t ’ )
6 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 )
7 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 ”)
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 ”)
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
=2
4 nyquist ( sys1 )
5 show_margins ( sys1 , ’ n y q u i s t ’ )
6 sys2 = syslin ( ’ c ’ ,(3* s +1) /( s *( s +1) *(2* s +1) ) ) //Td=3
7 // n y q u i s t ( s y s 2 )
91
Figure 9.8: effect of addition of poles
92
Figure 9.9: effect of addition of poles
93
Figure 9.10: effect of addition of zeroes
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 p o l e s
i n c r e a s e s s t a b i l i t y ”)
1 // m u l t i p l e l o o p s y s t e m s
94
Figure 9.11: effect of addition of zeroes
95
Figure 9.12: multiple loop systems
96
2 s = %s ;
3 Z = 0;
4 innerloop = syslin ( ’ c ’ ,6/ s *( s +1) *( s +2) )
5 nyquist ( innerloop )
6 show_margins ( innerloop , ’ n y q u i s t ’ )
7 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
i n n e r l o o p i s marginally s t a b l e ”)
8 outerloop = syslin ( ’ c ’ ,100*( s +0.1) /( s +10) *( s ^3+3* s
^2+2* s +6) )
9 // n y q u i s t ( o u t e r l o o p )
10 show_margins ( outerloop , ’ n y q u i s t ’ )
11 P =0 // no o f p o l e s on RHP
12 Pw =2 // no o f p o l e s on jw a x i s
13 theta = -(Z -P -0.5* Pw ) *180
14 Z =0 // f o r o u t e r l o o p t o be s t a b l e
15 disp ( theta , ” t h e t a f o r s t a b i l i t y =” )
16 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 h e n c e o u t e r l o o p
i s s t a b l e ”)
1 // g a i n m a r g i n and p h a s e m a r g i n
2 s = %s ;
3 sys = syslin ( ’ c ’ ,(2500) /( s *( s +5) *( s +50) ) )
4 nyquist ( sys )
5 show_margins ( sys , ’ n y q u i s t ’ )
6 gm = g_margin ( sys )
7 pm = p_margin ( sys )
8 disp ( gm , ” g a i n m a r g i n=” )
9 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
1 // bode p l o t
2 s = %s ;
3 sys = syslin ( ’ c ’ ,(2500) /( s *( s +5) *( s +50) ) )
4 bode ( sys )
5 show_margins ( sys , ’ bode ’ )
6 gm = g_margin ( sys )
7 pm = p_margin ( sys )
8 disp ( gm , ” g a i n m a r g i n=” )
99
Figure 9.15: relative stability
9 disp ( pm , ” p h a s e m a r g i n=” )
10 if ( gm <=0 | pm <=0)
11 printf ( ” s y s t e m i s u n s t a b l e ” )
12 else
13 printf ( ” s y s t e m i s s t a b l e ” )
14 end
1 // r e l a t i v e stability
2 s = %s ;
100
3 sys = syslin ( ’ c ’ ,(100) *( s +5) *( s +40) /( s ^3*( s +100) *( s
+200) ) ) //K=1
4 bode ( sys )
5 show_margins ( sys , ’ bode ’ )
6 gm = g_margin ( sys )
7 pm = p_margin ( sys )
8 disp ( gm , ” g a i n m a r g i n=” )
9 disp ( pm , ” p h a s e m a r g i n=” )
10 if ( gm <=0 | pm <=0)
11 printf ( ” s y s t e m i s u n s t a b l e ” )
12 else
13 printf ( ” s y s t e m i s s t a b l e ” )
14 end
101