Professional Documents
Culture Documents
Control Systems Engineering - I. J. Nagrath and M. Gopal PDF
Control Systems Engineering - I. J. Nagrath and M. Gopal PDF
1 Funded
Book Description
Title: Control Systems Engineering
Author: I. J. Nagrath And M. Gopal
Publisher: New Age Publisher, New Delhi
Edition: 3
Year: 2007
ISBN: 81-224-1192-4
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
11
21
30
42
10 Introduction to Design
61
75
2.3
2.4
3.2
3.3.a
3.3.b
3.3.c
3.3.d
3.3.f
3.3.g
5.2
5.2.2
5.3
5.3.2
5.4.1
5.4.2
5.4.3
5.8
5.9
6.1
6.2
6.3
6.4
6.5
6.6
6.7
6.8
6.9
6.10
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
9
9
11
11
12
12
13
13
14
15
16
16
17
17
18
18
19
19
21
22
22
23
23
24
25
26
26
27
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
6.11.a
6.11.b
7.1
7.2
7.3
7.4
7.6
7.8
7.9
7.10
9.1
9.2
9.3
9.4
9.5
9.6
9.7.a
9.7.b
9.8.a
9.8.b
9.10
9.11
9.13.a
9.13.b
9.14
9.15
10.6
10.7
10.8
10.9
12.3
12.4
12.5
12.6
12.7
12.12
12.13
12.14
routh array . . . . . . . . . . . . . . . . .
routh array . . . . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . . . . . .
nyquist plot . . . . . . . . . . . . . . . . .
nyquist plot . . . . . . . . . . . . . . . . .
nyquist plot . . . . . . . . . . . . . . . . .
nyquist plot . . . . . . . . . . . . . . . . .
nyquist plot . . . . . . . . . . . . . . . . .
stability using nyquist plot . . . . . . . .
stability using nyquist plot . . . . . . . .
stability using nyquist plot . . . . . . . .
nyquist criterion . . . . . . . . . . . . . .
nyquist criterion . . . . . . . . . . . . . .
gm and pm using nyquist plot . . . . . . .
bode plot . . . . . . . . . . . . . . . . . .
bode plot . . . . . . . . . . . . . . . . . .
bode plot . . . . . . . . . . . . . . . . . .
m circles . . . . . . . . . . . . . . . . . .
m circles . . . . . . . . . . . . . . . . . .
lead compensation . . . . . . . . . . . . .
lead compensation . . . . . . . . . . . . .
lag compnsation . . . . . . . . . . . . . .
lag and lead compensation . . . . . . . .
state matrix . . . . . . . . . . . . . . . .
modal matrix . . . . . . . . . . . . . . . .
obtain time response . . . . . . . . . . . .
resolvant matrix . . . . . . . . . . . . . .
state transition matrix and state response
check for controllability . . . . . . . . . .
check for controllability . . . . . . . . . .
check for observability . . . . . . . . . . .
5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
27
28
30
30
32
33
35
37
39
39
42
42
44
45
47
49
51
52
53
53
53
55
56
57
58
59
61
64
67
70
75
75
76
77
77
78
79
79
80
List of Figures
7.1
7.2
7.3
7.4
7.5
7.6
7.7
7.8
root
root
root
root
root
root
root
root
locus
locus
locus
locus
locus
locus
locus
locus
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
31
32
33
34
35
36
38
40
9.1
9.2
9.3
9.4
9.5
9.6
9.7
9.8
9.9
9.10
9.11
9.12
9.13
9.14
9.15
nyquist plot . . . . . . . . . .
nyquist plot . . . . . . . . . .
nyquist plot . . . . . . . . . .
nyquist plot . . . . . . . . . .
nyquist plot . . . . . . . . . .
nyquist plot . . . . . . . . . .
stability using nyquist plot . .
stability using nyquist plot . .
stability using nyquist plot . .
gm and pm using nyquist plot
bode plot . . . . . . . . . . .
bode plot . . . . . . . . . . .
bode plot . . . . . . . . . . .
m circles . . . . . . . . . . . .
m circles . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
43
44
45
46
47
48
50
51
52
54
55
56
57
58
60
10.1
10.2
10.3
10.4
lead
lead
lead
lead
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
62
63
65
66
compensation
compensation
compensation
compensation
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
7
10.5
10.6
10.7
10.8
lag
lag
lag
lag
compnsation . . . . . .
compnsation . . . . . .
and lead compensation
and lead compensation
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
68
69
71
72
Chapter 2
Mathematical Models of
Physical Systems
s o on
// p a t h f a c t o r by D1 and g r a p h d e t e r m i n a n t by D
P1 =1/( s * L * s * C ) ;
L1 = - R1 /( s * L ) ;
L2 = -1/( s * R2 * C ) ;
L3 = -1/( s ^2* L * C ) ;
D1 =1;
D =1 -( L1 + L2 + L3 ) ;
Y =( P1 * D1 ) / D ;
disp (Y , T r a n s f e r f u n c t i o n= )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
syms xv Qf Qo Cf Co V Qw Kv
Qo = Qw + Qf ;
// r a t e o f s a l t i n f l o w
mi = Qf * Cf ;
// r a t e o f s a l t o u t f l o w
mo = Qo * Co ;
// r a t e o f s a l t a c c u m u l a t i o n
ma = diff ( V * Co , t ) ;
mi = ma + mo ;
Qf * Cf = V * diff ( Co , t ) + Qo * Co ;
Qf = Kv * xv ;
K = Cf * Kv / Qo ;
G = V / Qo ;
G * diff ( Co , t ) + Co = K * xv ;
// t a k i n g l a p l a c e
G * s * Co + Co = K * xv ;
// t r a n s f e r f u n c t i o n= Co/ xv
Co / xv = K /( G * s +1) ;
10
Chapter 3
Feedback Characteristics of
control sytems
syms K ;
s = %s ;
G = syslin ( c ,25( s +1) /( s +5) ) ;
p=K;
q = s ^2+ s ;
J=p/q;
F=G*J;
T = F /(1+ F ) ; // 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
disp (T , C( s ) /R( s ) )
// s e n s i t i v i t y w . r . t K = dT/dKK/T
S =( diff (T , K ) ) *( K / T )
disp (S , S e n s i t i v i t y )
syms K1 K t ;
11
2
3
4
5
6
7
8
9
10
11
12
13
14
15
s = %s ;
p = K1 * K ;
q = t * s +1+( K1 * K ) ;
T=p/q;
disp (T , V( s ) /R( s ) )
// s e n s i t i v i t y w . r . t K i s dT/dKK/T
S =( diff (T , K ) ) *( K / T )
// g i v e n K1=50 K=1.5
s =0
S = horner (S , s )
K1 =50;
K =1.5;
S =1/(1+ K1 * K )
disp (S , s e n s i t i v i t y = )
syms A K K1 t
s = %s ;
p = K1 * K * A ;
q = s *(1+( t * s ) +( K1 * K ) ) ;
K =1.5;
K1 =50;
V=p/q
v = limit ( s *V ,s ,0)
// g i v e n s t e a d y s t a t e s p e e d = 60km/ h r
A =60*(1+( K1 * K ) ) /( K1 * K )
// s t e a d y e r r o r e ( s s )=Av
v =60;
e =A - v ;
disp (e , e ( s s )= )
1
2
3
4
5
6
7
8
9
// u n d e r s t a l l e d c o n d i t i o n s
syms Kg K1 D ;
A =60.8;
A * K1 = Kg * D ;
// g i v e n Kg=100
Kg =100;
K1 =50;
D =( A * K1 ) / Kg ;
disp (D , u p s l o p e= )
// s t e a d y s p e e d =10km/ h r
syms K Kg D
((( A -10) * K1 ) -( - D * Kg ) ) K =100;
A =(60.8*10) /60;
K =1.5;
Kg =100;
D =((100/ K ) -((A -10) * K ) ) / Kg ;
disp (D , Down s l o p e= )
// f o r open l o o p s y s t e m
// g i v e n s p e e d =60km/ h r
syms R K1 K ;
( R * K1 * K ) =60
K1 =50;
K =1.5;
R =60/( K1 * K )
disp (R , I n p u t open= )
// f o r c l o s e d l o o p
R =60(1+( K1 * K ) ) /( K1 * K )
13
11
disp (R , I n p u t c l o s e d= )
// f o r open l o o p
syms t g s ;
s = %s ;
K1 =50;
K =1.5;
g =20;
V = syslin ( c ,(( K1 * K ) *0.8) /( s *(( g * s ) +1) ) )
// t a k i n g i n v e r s e l a p l a c e
v = ilaplace (V ,s , t )
v =60(11 - %e ^( - t /20) )
// g i v e n v=90%
v =0.9;
t = -20* log (1 - v ) ;
disp (t , t i m e open= )
// f o r c l o s e d l o o p
syms K g
s = %s ;
V = syslin ( c ,(60.8* K ) /( s *(( g * s ) +1) ) )
// t a k i n g i n v e r s e l a p l a c e
v = ilaplace (V ,s , t )
// g i v e n
K =75/76;
g =.263;
v =60(1 - %e ^( - t /.263) )
// a t v=90%
v =0.9;
t = -.263* log (1 -( v /60) ) ;
disp (t , t i m e c l o s e d= )
14
Chapter 5
Time Response analysis design
specifications and performance
indices
s = %s
syms K J f
K =60; // g i v e n
J =10; // g i v e n
p=K/J
q = K / J +( f / J ) * s + s ^2
G=p/q;
disp (G , Qo ( s ) / Qi ( s )= )
zeta =0.3; // g i v e n
cof1 = coeffs (q , s ,0)
// on c o m p a r i n g t h e c o e f f i c i e n t s
Wn = sqrt ( cof1 )
cof2 = coeffs (q , s ,1)
// 2 z e t a Wn=c o f 2
f / J =2* zeta * Wn
r = s ^2+ f / J
s = s ^2+ f / J + K / J
15
18 H = r / s ;
19 disp (H , Qe ( s ) / Qi ( s )= )
s = %s ;
syms Kp Ka Kt J f
// g i v e n
J =0.4;
Kp =0.6;
Kt =2;
f =2;
p = Kp * Ka * Kt
q = s ^2+ f / J +( Kp * Ka * Kt ) / J
G=p/q;
disp (G , Qm( s ) /Qr ( s )= )
cof_1 = coeffs (q , s ,0)
// on c o m p a r i n g t h e c o e f f i c i e n t s
// Wn=s q r t ( c o f 1 )
Wn =10;
Ka =( Wn ) ^2* J /( Kp * f )
disp ( Ka , A m p l i f i e r C o n s t a n t= )
16
s = %s ;
syms Kp Ka Kt Kd J f
// g i v e n
J =0.4;
Kp =0.6;
Kt =2;
f =2;
Ka =5;
p = Kp * Ka * Kt
q = s ^2+(( f + Ka * Kd * Kt ) / J ) * s +( Kp * Ka * Kt ) / J
G=p/q;
disp (G , Qm( s ) /Qr ( s )= )
cof_1 = coeffs (q , s ,0)
// on c o m p a r i n g t h e c o e f f i c i e n t s
Wn = sqrt ( cof_1 )
zeta =1 // g i v e n
cof_2 = coeffs (q , s ,1)
// 2 z e t a Wn=c o f 2
Kd =(2* zeta * sqrt ( Kp * J * Ka * Kt ) -f ) /( Ka * Kt )
disp ( Kd , T a c h o g e n e r t o r c o n s t a n t= )
equation
z = coeff ( p ) ;
Wn = sqrt ( z (1 ,1) )
zeta = z (1 ,2) /(2* Wn )
Kv = z (1 ,1) / z (1 ,2)
Ess =1/ Kv // S t e a d y s t a t e e r r o r f o r u n i t ramp i / p
disp ( Ess , S t e a d y s t a t e E r r o r= )
17
// w i t h d e r i v a t i v e f e e d b a c k
// c h a r a c t e r i s t i c e q u a t i o n i s
syms a
s = %s ;
p = s ^2+(2+(8* a ) ) * s +8=0
zeta =0.7 // g i v e n
Wn =2.828;
cof_1 = coeffs (p , s ,1)
// on c o m p a r i n g 2 z e t a Wn=c o f 1
a =((2* zeta * Wn ) -2) /8
disp (a , D e r i v a t i v e f e e d b a c k= )
cof_2 = coeffs (p , s ,0)
cof_1 =2+8*0.245;
Kv = cof_2 / cof_1 ;
Ess =1/ Kv
disp ( Ess , S t e a d y s t a t e e r r o r= )
// l e t t h e c h a r e q u a t i o n be
syms Ka
s = %s ;
p = s ^2+(2+( a * Ka ) ) * s + Ka =0
cof_1 = coeffs (p , s ,0)
// Wn2= c o f 1
Wn = sqrt ( cof_1 )
cof_2 = coeffs (p , s ,1)
// 2 z e t a Wn=c o f 2
Kv = cof_1 / cof_2 ;
18
11 Ess =1/ Kv ;
12 // g i v e n E s s =0.25
13 Ess =0.25;
14 Ka =2/( Ess - a )
15 disp ( Ka . Ka= )
s = %s ;
syms K V
p = s ^2+(100* K ) * s +100=0
cof_1 = coeffs (p , s ,0)
Wn = sqrt ( cof_1 )
zeta =1 // g i v e n
cof_2 = coeffs (p , s ,1)
// 2 z e t a Wn=c o f 2
K =(2* Wn * zeta ) /100
// For ramp i n p u t
R = V / s ^2
E=R/p
// s t e a d y s t a t e e r r o r
e = limit ( s * E ( s ) ,s ,0)
disp (e , e ( s s )= )
s = %s ;
syms t m
A =[0 1; -100 -20];
B =[0;100];
C =[1 0];
x =[0;0];
[ r c ]= size ( A )
19
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
p = s * eye (r , c ) -A
q = inv ( p ) ;
disp (q , p h i ( s )= ) // R e s o l v a n t m a t r i x
for i =1: r ;
for j =1: c ;
q (i , j ) = ilaplace ( q (i , j ) ,s , t )
end
end
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
t =t - m ;
q = eval ( q )
// I n t e g r a t e q w . r . t m
r = integrate ( q *B , m )
m =0
// Upper l i m i t i s t
g = eval ( r ) // P u t i n g u p p e r l i m i t i n q
m = t // Lower l i m i t i s 0
h = eval ( r )
// P u t t i n g l o w e r l i m i t i n q
y =( h - g ) ;
disp (y , y= )
printf ( x ( t )=p h i ( t ) x ( 0 )+ i n t e g r a t e ( p h i ( tmB) w . r . t
m from 0 t o t ) )
y1 =( q * x ) + y ;
disp ( y1 , x ( t )= )
// t r a n s f e r f u n c t i o n
t=C*q*B;
disp (t , T( s )= )
20
Chapter 6
Concepts of stability and
Algebraic Criteria
s = %s ;
p = s ^4+8* s ^3+18* s ^2+16* s +5
r = coeff ( p )
D1 = r (4)
d2 =[ r (4) r (5) ; r (2) r (3) ]
D2 = det ( d2 ) ;
d3 =[ r (4) r (5) 0; r (2) r (3) r (4) ;0 r (1) r (2) ]
D3 = det ( d3 ) ;
d4 =[ r (4) r (5) 0 0; r (2) r (3) r (4) r (5) ;0 r (1) r (2) r
(3) ;0 0 0 r (1) ]
D4 = det ( d4 ) ;
disp ( D1 , D1= )
disp ( D2 , D2= )
disp ( D3 , D3= )
disp ( D4 , D4= )
printf ( S i n c e a l l t h e d e t e r m i n a n t s a r e p o s i t i v e t h e
system i s s t a b l e )
21
s = %s ;
p = s ^4+8* s ^3+18* s ^2+16* s +5
r = routh_t ( p )
m = coeff ( p )
l = length ( m )
c =0;
for i =1: l
if ( r (i ,1) <0)
c = c +1;
end
end
if (c >=1)
printf ( System i s u n s t a b l e )
else ( Sysem i s s t a b l e )
end
s = %s ;
p =3* s ^4+10* s ^3+5* s ^2+5* s +2
r = routh_t ( p )
m = coeff ( p )
l = length ( m )
c =0;
for i =1: l
if ( r (i ,1) <0)
c = c +1;
end
end
if (c >=1)
22
13 printf ( System i s u n s t a b l e )
14 else ( Sysem i s s t a b l e )
15 end
s = %s ;
syms Kv Kd Kp Kt
p = s ^3+(1+( Kv * Kd ) ) * s ^2+( Kv * Kp ) * s +( Kp * Kt )
cof_a_0 = coeffs (p , s ,0) ;
cof_a_1 = coeffs (p , s ,1) ;
cof_a_2 = coeffs (p , s ,2) ;
cof_a_3 = coeffs (p , 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) ;
routh =[ routh ; - det ( t ) / routh (3 ,1) ,0]
disp ( routh , r o u t h= ) ;
// f o r s t a b i l i t y r ( : , 1 ) >0
// f o r t h e g i v e n t a b l e
b = routh (3 ,1)
disp ( f o r s t a b i l i t y b , >0 )
23
s = %s ;
syms K
p = s ^2 -( K +2) * s +((2* K ) +5)
cof_a_0 = coeffs (p , s ,0) ;
cof_a_1 = coeffs (p , s ,1) ;
cof_a_2 = coeffs (p , s ,2) ;
r =[ cof_a_0 cof_a_1 cof_a_2 ]
n = length ( r ) ;
routh =[ r ([3 ,1]) ; r (2) ,0];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0];
disp ( routh , r o u t h= )
// f o r s y s t e m t o be s t a b l e
routh (2 ,1) >0
24
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
K < -2;
routh (3 ,1) >0
K > -2.5;
disp ( For s t a b l e system , 2>K>2.5 )
// f o r l i m i t e d s t a b i l i t y
routh (2 ,1) =0
K = -2
routh (3 ,1) =0
K = -2.5
disp ( For l i m t e d s t a b l e s y s t e m K=2 and K=2.5 )
// f o r u n s t a b l e s y s t e m
disp ( For u n s t a b l e s y s t e m K<2 o r K>2.5 )
roots ( p ) // g i v e s t h e r o o t s o f t h e p o l y n o m i a l m
// f o r c r i t i c a l l y damped c a s e
g =( K +2) ^2 -4*((2* K ) +5)
roots ( g )
// f o r s t a b l i t y K=6.47 i s u n s t a b l e
// f o r c r i t i c a l damping K= 2.47
disp ( For underdamded c a s e , 2>K> 2.47 )
disp ( f o r overdamped c a s e , 2.47>K>2.5 )
s = %s ;
syms eps
p = s ^5+ s ^4+2* s ^3+2* s ^2+3* s +5
r = coeff ( p ) ;
n = length ( r ) ;
routh =[ r ([6 ,4 ,2]) ; r ([5 ,3 ,1]) ]
syms eps ;
routh =[ routh ; eps , - det ( routh (1:2 ,2:3) ) / routh (2 ,2) ,0];
routh =[ routh ; - det ( routh (2:3 ,1:2) ) / routh (3 ,1) ,- det (
routh (2:3 ,2:3) ) / routh (4 ,2) ,0];
10 routh =[ routh ; - det ( routh (4:5 ,1:2) ) / routh (5 ,1) ,0 ,0];
11 disp ( routh , r o u t h= )
25
12
13
14
15
16
17
// t o c h e c k s t a b i l i t y
routh (4 ,1) =8 - limit (5/ eps , eps ,0) ;
disp ( routh (4 ,1) , r o u t h ( 4 , 1 )= )
routh (5 ,1) = limit ( routh (5 ,1) ,eps ,0) ;
disp ( routh (5 ,1) , r o u t h ( 5 , 1 )= )
printf ( There a r e two s i g n c h a n g e s o f f i r s t column
hence the system i s u n s t a b l e )
lying in
the r i g h t h a l f )
6 printf ( System i s s t a b l e )
s = %s ;
syms K a
p = s ^4+10* s ^3+32* s ^2+( K +32) * s +( K * a )
cof_a_0 = coeffs (p , s ,0) ;
cof_a_1 = coeffs (p , s ,1) ;
cof_a_2 = coeffs (p , s ,2) ;
cof_a_3 = coeffs (p , s ,3) ;
cof_a_4 = coeffs (p , s ,4) ;
r =[ cof_a_0 cof_a_1 cof_a_3 cof_a_4 ]
n = length ( r ) ;
routh =[ r ([5 ,3 ,1]) ; r ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) ,- det (
routh (1:2 ,2:3) ) / routh (2 ,2) ,0];
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
s = %s ;
p = s ^3+7* s ^2+25* s +39
// t o c h e c k i f t h e r o o t s l i e l e f t o f s=1
// s u b s t i t u t e s=s 1
p =( s -1) ^3+7*( s -1) ^2+25*( s -1) +20
r = routh_t ( p )
printf ( A l l t h e s i g n s o f e l e m e n t s f i r s t column a r e
p o s i t i v e h e n c e t h e r o o t s l i e l e f t o f s=1 )
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
syms K
// t h e s y s t e m c h a r a c t e r i s t i c eq can be w r i t t e n a s
p = s ^3+8.5* s ^2+20* s +12.5(1+ K )
cof_a_0 = coeffs (p , s ,0) ;
cof_a_1 = coeffs (p , s ,1) ;
cof_a_2 = coeffs (p , s ,2) ;
cof_a_3 = coeffs (p , 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) ;
routh =[ routh ; - det ( t ) / routh (3 ,1) ,0]
disp ( routh , r o u t h= ) ;
// f o r l i m i t i n g v a l u e o f K
routh (3 ,1) =0
K =12.6;
disp (K , L i m i t i n g v a l u e o f K )
1 o r more )
// s u b s t i t u t i n g s=s 1
p =( s -1) ^3+8.5*( s -1) ^2+20*( s -1) +12.5*(1+ K )
cof_a_0 = coeffs (p , s ,0) ;
cof_a_1 = coeffs (p , s ,1) ;
cof_a_2 = coeffs (p , s ,2) ;
cof_a_3 = coeffs (p , s ,3) ;
r =[ cof_a_0 cof_a_1 cof_a_2 cof_a_3 ]
28
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) ;
18 routh =[ routh ; - det ( t ) / routh (3 ,1) ,0]
19 disp ( routh , r o u t h= ) ;
20 // f o r l i m i t i n g v a l u e o f K
21 routh (3 ,1) =0
22 K =2.64
23 disp (K , L i m i t i n g v a l u e o f K f o r s e t t l i n g
)
24 // r o o t s o f c h a r eq a t K=2.64
25 g = s ^3+8.5* s ^2+20* s +12.5*(1+2.64)
26 roots ( g )
29
t i m e o f 4 s=
Chapter 7
The Root Locus Technique
s t a r t i n g w i t h K=0 and p o l e s s =0 , 3 , 4. )
6 printf ( As k i n c r e a s e s two b r a n c h e s t e r m i n a t e a t
z e r o s s =1,2 and one a t i n f i n i t y )
30
31
s = %s ;
syms k
H = syslin ( c ,1+( k /( s *( s +1) *( s +2) ) ) )
evans (H ,5)
d = derivat ( H )
p = numer ( d )
32
branches terminate at i n f i m i t y )
33
all
34
35
36
21
22
23
24
25
syms K
s = %s ;
G = syslin ( c ,( K *( s +1) *( s +2) ) /(( s +0.1) *( s -1) ) )
evans ( G )
n =2;
disp (n , no o f p o l e s= )
m =2;
disp (m , no o f z e r o e s= )
K = kpure ( G )
disp (K , v a l u e o f K where RL c r o s s e s jw a x i s= )
d = derivat ( G )
p = numer ( d )
a = roots ( p ) ;
// 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) +0.1) *( a (i ,1) -1) /(( a (i ,1) +1) *( a (i ,1)
+2) )
disp ( a (i ,1) , s= )
disp (K , K= )
end
printf ( z e t a =1 i s a c h i e v e d when t h e two r o o t s a r e
e q u a l and n e g a t i v e ( r e a l ) . T h i s h a p p e n s a t t h e
breakaway p o i n t i n t h e l e f t h a l f sp l a n e / n )
zeta =1;
wn =0.6;
sgrid ( zeta , wn )
K = -1/ real ( horner (G ,[1 %i ]* locate (1) ) ) ;
disp (K , The c o r r e s p o n d i n g v a l u e o f g a i n i s = )
37
38
syms K
s = %s ;
G = syslin ( c ,( K *( s +4/3) ) /( s ^2*( s +12) ) )
evans (G ,60)
d = derivat ( G )
p = numer ( d )
a = roots ( p )
// a=breakaway p o i n t s
disp (a , Breakaway p o i n t s= )
printf ( Equal r o o t s a r e a t s=4 )
printf ( / n V a l u e o f K a t s=4= )
K =4*4*8/(4 -(4/3) )
disp ( K )
40
12
13
14
15
16
17
18
19
20
21
22
23
24
Kh1 =0.156;
Kh2 =0.079;
// from t h e b l o c k d i a g r a m
Td ( s ) =1/ s ;
E ( s ) = C ( s ) = G /(1+( G * Kh *( s +1) ) /( s +8) ) * Td ( s ) ;
// s u b s t i t u t i n g v a l u e o f G
F = s * E ( s ) =10* Kh /(1+(10* Kh ) ) ;
// s t e a y s t a t e e r r o r
ess = limit (F ,s ,0)
// f o r Kh1 = 0 . 1 5 6
ess =0.609;
// f o r Kh2 = 0 . 0 7 9
ess =0.44;
41
Chapter 9
Stability in Frequency Domain
n y q u i s t c o n t o u r d o e s n o t e n c i r c l e t h e p o i n t 1+ j 0
)
7 printf ( System i s s t a b l e )
42
43
44
45
46
is
47
48
1 s = %s ;
2 syms K a
3 H = syslin ( c ,( K *( s + a ) ) /( s *( s -1) ) )
4 // f o r K>1
5 nyquist ( H )
6 show_margins (H , n y q u i s t )
7 mtlb_axis ([ -5 5 -5 5])
8 xtitle ( For K>1 )
9 printf ( P=1( p o l e i n RHP) )
10 p r i n t f ( Nyquist plot encircles the the point -1+ j0
11
12
13
14
15
16
17
18
19
20
49
50
printf ( T h e r e f o r e , System i s u n s t a b l e )
51
the
i n t e r c e p t o f k /4
52
o f r e a l s with
// f o r k/4>1 o r k>4
printf ( N=2 a s i t e n c i r c l e s t h e p o i n t t w i c e i n
c l o c k w i s e d i r e c t i o n )
8 printf ( P=0 and h e n c e Z=2 )
9 printf ( System i s u n s t a b l e f o r k>4 )
6
7
of the
c h a r a c t e r i s t i c equation l i e s in the r i g h t h a l f of
sp l a n e , h e n c e t h e s y s t e m i s u n s t a b l e )
encirclement
3 P =0;
// g i v e n
4 Z =N - P
5 printf ( S i n c e Z=0 no r o o t o f t h e c h a r a c t e r i s i c
equation l i e s in the r i g h t h a l f hence the system
i s s t a b l e )
54
s = %s ;
syms K
H = syslin ( c ,K /( s *(0.2* s +1) *(0.05* s +1) ) )
nyquist ( H )
show_margins (H , n y q u i s t )
mtlb_axis ([ -1 1 -5 1])
gm = g_margin ( H ) // g a i n m a r g i n
pm = p_margin ( H ) // p h a s e m a r g i n
55
s = %s ;
H = syslin ( c ,10/( s *(0.1* s +1) *(0.05* s +1) ) )
fmin =0.1;
fmax =100;
bode (H , fmin , fmax )
show_margins ( H )
gm = g_margin ( H )
pm = p_margin ( H )
56
s = %s ;
H = syslin ( c ,(8*( s +4) ) /(( s -1) *( s -2) ) )
fmin =0.1;
fmax =100;
bode (H , fmin , fmax )
show_margins ( H )
gm = g_margin ( H )
pm = p_margin ( H )
57
s h o u l d be r e d u c e d by 4 db )
1
2
3
4
5
6
7
8
9
10
s = %s ;
H = syslin ( c ,10/( s *((0.1* s ) +1) *((0.5* s ) +1) ) )
fmin =0.1;
fmax =100;
clf ()
black (H ,0.1 ,100)
chart ( list (1 ,0) )
gm = g_margin ( H )
pm = p_margin ( H )
printf ( For g a i n m a r g i n o f 20 db p l o t i s s h i f t e d
downwards by 8 db and a p h a s e m a r g i n o f 24
d e g r e e s i s o b t a i n e d i f c u r v e i s s h i f t e d upwards
by 3 . 5 db )
s = %s ;
H = syslin ( c ,10/( s *((0.1* s ) +1) *((0.05* s ) +1) ) )
fmin =0.1;
fmax =100;
clf ()
black (H ,0.1 ,100)
chart ( list (1 ,0) )
gm = g_margin ( H )
pm = p_margin ( H )
printf ( For g a i n m a r g i n o f 20 db p l o t i s s h i f t e d
downwards by 8 db and a p h a s e m a r g i n o f 24
d e g r e e s i s o b t a i n e d i f c u r v e i s s h i f t e d upwards
by 3 . 5 db )
59
60
Chapter 10
Introduction to Design
s = %s ;
syms Kv ;
g =( Kv /( s *( s +1) ) ) ;
// g i v e n Kv=12
Kv =12;
g =(12/( s *( s +1) ) ) ;
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
xtitle ( u n c o m p e n s a t e d s y s t e m )
[ gm , freqGM ]= g_margin ( G )
[ pm , freqPM ]= p_margin ( G )
disp ( gm , g a i n m a r g i n= )
disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
disp ( pm , p h a s e m a r g i n= )
61
62
63
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
s = %s ;
syms Ka ;
g =( Ka /( s ^2*(1+0.2* s ) ) ) ;
// g i v e n Ka=10
Ka =10;
g =(10/( s ^2*(1+0.2* s ) ) ) ;
G = syslin ( c ,g )
fmin =0.01;
64
65
66
9 fmax =100;
10 bode (G , fmin , fmax )
11 show_margins ( G )
12 xtitle ( u n c o m p e n s a t e d s y s t e m )
13 [ gm , freqGM ]= g_margin ( G )
14 [ pm , freqPM ]= p_margin ( G )
15 disp ( gm , g a i n m a r g i n= )
16 disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
17 disp ( pm , p h a s e m a r g i n= )
18 disp (( freqPM *2* %pi ) , p h a s e m a r g i n f r e q= ) ;
19 disp ( s i n c e P .M i s n e g a t i v e s o s y s t e m i s u n s t a b l e )
20 disp ( s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t
21
22
23
24
25
26
27
28
29
30
31
32
33
34
67
68
s = %s ;
syms K ;
g =( K /( s *( s +1) *( s +4) ) ) ;
g =(( K /4) /( s *( s +1) *(0.25* s +1) ) )
// g i v e n Kv=5 : v e l o c i t y e r r o r c o n s t a n t
K =20;
g =(5/( s *( s +1) *(0.25* s +1) ) )
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
xtitle ( u n c o m p e n s a t e d s y s t e m )
[ gm , freqGM ]= g_margin ( G )
[ pm , freqPM ]= p_margin ( G )
disp ( gm , g a i n m a r g i n= )
disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
disp ( pm , p h a s e m a r g i n= )
69
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
s = %s ;
syms K ;
g =( K /( s *(0.1* s +1) *(0.2* s +1) ) ) ;
// g i v e n Kv=30 : v e l o c i t y e r r o r c o n s t s n t
K =30;
g =(30/( s *(0.1* s +1) *(0.2* s +1) ) )
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
70
71
72
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
i n c r e a s e r e s u l t i n g in u n d e s i r a b l e system
s e n s i t i v e to n o i s e . I f l a g compensation i s used
bandwidth d e c r e a s e s s o a s t o f a l l s h o r t o f
s p e c i f i e d v a l u e o f 12 r a d / s e c r e s u l t i n g i n
s l u g g i s h system )
disp ( / n h e n c e we u s e a l a g l e a d c o m p e n s a t o r )
// l a g c o m p e n s a t o r
disp ( s e l e c t i n g z e r o o f p h a s e l a g n e t w o r k w=1 r a d /
s e c and p o l e a t w=0.1 r a d / s e c and a p p l y i n g g a i n
to account a t t e n u a t i o n f a c t o r )
gc1 =(( s +1) /(10* s +1) ) ;
Gc1 = syslin ( c , gc1 )
disp ( Gc1 , t r a n s f e r f u n c t i o n o f l a g c o m p e n s a t o r )
// l e a d c o m p e n s a t o r
disp ( s e l e c t i n g z e r o o f l e a d c o m p e n s a t o r a t w= 0 . 4 2 5
r a d / s e c and p o l e a t w= 0 . 0 4 2 5 r a d / s e c )
gc2 =((0.425* s +1) /(0.0425* s +1) ) ;
Gc2 = syslin ( c , gc2 )
disp ( Gc2 , t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r )
Gc = Gc1 * Gc2 // t r a n s f e r f u n c t i o n o f l a g and l e a d
sections
disp ( Gc , t r a n s f e r f u n c t i o n o f l a g and l e a d s e c t i o n s
)
G1 = G * Gc
disp ( G1 , o v e r a l l t r a n s f e r f u n c t i o n= ) ;
fmin =0.01;
fmax =100;
73
74
Chapter 12
State Variable Analysis and
Design
s = %s ;
H = syslin ( c ,(2* s ^2+6* s +7) /(( s +1) ^2*( s +2) ) )
SS = tf2ss ( H )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
syms m11 m12 m13 m21 m22 m23 m31 m32 m33 ^
s = %s ;
poly (0 , l ) ;
A =[0 1 0;3 0 2; -12 -7 -6]
[ r c ]= size ( A )
I = eye (r , c ) ;
p = l *I - A ;
q = det ( p ) ; // d e t e r m i n a n t o f l i p
// r o o t s o f q a r e
75
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
l1 = -1;
l2 = -2;
l3 = -3;
x1 =[ m11 ; m21 ; m31 ];
q1 =( l1 *I - A ) *1
// on s o l v i n g we f i n d m11=1 m21=1 31=1
m11 =1; m21 = -1; m31 = -1;
x2 =[ m12 ; m22 ; m32 ];
q2 =( l2 *I - A ) *1
// on s o l v i n g we f i n d m12=2 m22=4 m32=1
m12 =2; m22 = -4; m32 =1;
x3 =[ m13 ; m23 ; m33 ];
q3 =( l3 *I - A ) *1
// on s o l v i n g we g e t m13=1 m23=3 m33=3
m13 =1; m23 = -3; m33 =3;
// modal m a t r i x i s
M =[ m11 m12 m13 ; m21 m22 23; m31 m32 m33 ]
syms t m
s = %s ;
A =[1 0;1 1];
B =[1;1];
x =[1;0];
[ r c ]= size ( A )
p = s * eye (r , c ) -A // s IA
q = inv ( p )
for i =1: r
for j =1: c
// 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 q
q (i , j ) = ilaplace ( q (i , j ) ,s , t ) ;
end
end
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
76
16
17
18
19
20
21
22
23
24
25
26
t =t - m ;
q = eval ( q )
// I n t e g r a t e q w . r . t m
r = integrate ( q *B , m )
m =0
// Upper l i m i t i s t
g = eval ( r ) // P u t i n g u p p e r l i m i t i n q
m = t // Lower l i m i t i s 0
h = eval ( r )
// P u t t i n g l o w e r l i m i t i n q
y =( h - g ) ;
disp (y , y= )
printf ( x ( t )=p h i ( t ) x ( 0 )+ i n t e g r a t e ( p h i ( tmB) w . r . t
m from 0 t o t ) )
27 y1 =( q * x ) + y ;
28 disp ( y1 , x ( t )= )
syms t
s = %s ;
A =[1 0;1 1];
[ r c ]= size ( A )
p = s * eye (r , c ) -A
// r e s o l v e n t m a t r i x
q = inv ( p )
disp (q , p h i ( s )= )
for i =1: r
for j =1: c
q (i , j ) = ilaplace ( q (i , j ) ,s , t )
end
end
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
Scilab code Exa 12.7 state transition matrix and state response
77
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
syms t m
s = %s ;
A =[0 1; -2 -3];
B =[0;2];
x =[0;1];
[ r c ]= size ( A )
p = s * eye (r , c ) -A
q = inv ( p )
for i =1: r
for j =1: c
q (i , j ) = ilaplace ( q (i , j ) ,s , t )
end
end
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
t =t - m ;
q = eval ( q )
// I n t e g r a t e q w . r . t m
r = integrate ( q *B , m )
m =0
// Upper l i m i t i s t
g = eval ( r ) // P u t i n g u p p e r l i m i t i n q
m = t // Lower l i m i t i s 0
h = eval ( r )
// P u t t i n g l o w e r l i m i t i n q
y =( h - g ) ;
disp (y , y= )
printf ( x ( t )=p h i ( t ) x ( 0 )+ i n t e g r a t e ( p h i ( tmB) w . r . t
m from 0 t o t ) )
26 y1 =( q * x ) + y ;
27 disp ( y1 , x ( t )= )
78
5 d = det ( P )
6 if d ==0
7
printf ( m a t r i x
i s s i n g u l a r , so system i s
u n c o n t r o l l a b l e );
8 else
9
printf ( s y s t e m
10 end ;
i s c o n t r o l l a b l e );
A =[0 1; -1 -2];
B =[1; -1];
P = cont_mat (A , B ) ;
disp (P , C o n t r o l l a b i l i t y M a t r i x= )
d = determ ( P )
if d ==0
printf ( m a t r i x i s s i n g u l a r , s o s y s t e m i s
u n c o n t r o l l a b l e );
8 else
9
printf ( s y s t e m i s c o n t r o l l a b l e ) ;
10 end ;
9 else
10
printf ( s y s t e m
11 end ;
i s o b s e r v a b l e );
syms g1 g2 g3
poly (0 , l ) ;
A =[1 2 0;3 -1 1;0 2 0];
C =[0;0;1];
G =[ g1 ; g2 ; g3 ];
p =A - G * C ;
[ r c ]= size ( A ) ;
I = eye (r , c ) ;
q = lI - p ; // l I (AGC) where I i s i d e n t i t y m a t r i x
r = det ( q ) // d e t r m i n a n t o f l I (AGC)
// on e q u a t i n g r =0 we g e t
// c h a r a c t e r i s t i c e q u a t i o n
l ^3+ g3 *( l ) ^2+(2* g2 -9) l +2+6* g1 -2* g2 -7* g3 =0;
printf ( d e s i r e d c h a r a c t e r i s t i c e q u a t i o n g i v e n i s \n )
l ^3+10*( l ) ^2+34* l +40=0;
// on c o m p a r i n g t h e c o e f f i c i e n t s og t h e two
equations
// we g e t g1 =25.2 g2 =21.5 g3 =10
g1 =25.2;
g2 =21.5;
g3 =10;
disp ( G )
80