Professional Documents
Culture Documents
1 Funded
Book Description
Title: Process Systems Analysis And Control
Author: S. E. LeBlanc And D. R. Coughanowr
Publisher: McGraw - Hill International
Edition: 2
Year: 1991
ISBN: 0-07-100807-1
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
13
15
18
20
21
23
14 Stability
25
15 Root Locus
29
32
37
43
46
20 Control Valves
51
54
24 Stability
55
58
30 Multivariable Control
60
2.1
2.3
3.1
3.2
3.3
3.4
3.5
3.6
4.1
4.2
4.4
5.1
5.2
6.1
7.1
10.1
12.1
12.2
14.1
14.2
14.3
14.4
15.1
15.2
16.1
16.2
16.4
16.5
Laplace transform . . . .
Laplace transform . . . .
Inverse laplace transform
Inverse laplace transform
Inverse laplace transform
Inverse laplace transform
Inverse laplace transform
Inverse laplace transform
Final value theorem . . .
Final value theorem . . .
Laplace transform . . . .
First order systems . . . .
First order systems . . . .
First order systems . . . .
First order systems . . . .
Control system . . . . . .
Transfer functions . . . .
Transfer functions . . . .
Stability . . . . . . . . . .
Stability . . . . . . . . . .
Stability . . . . . . . . . .
Stability . . . . . . . . . .
Root locus . . . . . . . .
Root locus . . . . . . . .
Frequency Response . . .
Frequency Response . . .
Bode diagram . . . . . .
Bode diagram . . . . . .
5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
8
8
9
9
10
10
11
11
13
13
14
15
15
18
20
21
23
23
25
26
26
27
29
29
32
32
33
35
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
17.1
17.3
17.4
18.3
18.5
18.6
19.1
19.2
20.1
20.2
20.3
22.1
22.2
24.1
26.1.a
26.1.b
29.1
29.2
30.1
30.2
30.3
Frequency Response . .
Tuning Rules . . . . . .
Tuning Rules . . . . . .
Tuning Rules . . . . . .
Internal Model Control
Internal Model Control
Tuning Rules . . . . . .
Tuning Rules . . . . . .
Control Valves . . . . .
Control Valves . . . . .
Control Valves . . . . .
Z transforms . . . . . .
Z transforms . . . . . .
Stability . . . . . . . . .
Sampled data system .
Sampled data system .
Transfer function matrix
Transfer function matrix
Multivariable control . .
Multivariable control . .
Multivariable control . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
37
38
39
43
43
44
46
47
51
51
52
54
54
55
56
57
58
58
60
61
62
List of Figures
5.1
17
30
31
34
36
38
41
42
48
50
Chapter 2
The Laplace Transform
// Example 2 . 3
clc
s = %s ;
xs =2/( s +3) ;
disp ( xs , x ( s )= )
syms t ;
xt = ilaplace ( xs ,s , t ) ;
disp ( xt , x ( t )= )
Chapter 3
Inversion by Partial Fractions
// Example 3 . 1
clc
s = %s ;
xs =1/( s *( s +1) ) ;
disp ( xs , x ( s )= )
syms t ;
[ A ]= pfss ( xs )
F1 = ilaplace ( A (1) ,s , t ) ;
F2 = ilaplace ( A (2) ,s , t ) ;
xt = F1 + F2 ;
disp ( xt , x ( t )= )
5
6
7
8
9
10
11
12
13
14
15
16
num = poly ([ -8 9 -6 0 1] , s , c o e f f ) ;
den = s *( s -2) * poly ([ -2 -1 2 1] , s , c o e f f ) ;
xs = syslin ( c , num / den ) ;
disp ( xs , x ( s )= )
A = pfss ( xs )
F1 = ilaplace ( A (1) ,s , t ) ;
F2 = ilaplace ( A (2) ,s , t ) ;
F3 = ilaplace ( A (3) ,s , t ) ;
F4 = ilaplace ( A (4) ,s , t ) ;
F5 = ilaplace ( A (5) ,s , t ) ;
xt = F1 + F2 + F3 + F4 + F5 ;
disp ( xt , x ( t )= )
// Example 3 . 3
clc
s = %s ;
syms t ;
xs =2/( s *( s ^2+2* s +2) ) ;
disp ( xs , x ( s )= )
[ A ]= pfss ( xs )
F1 = ilaplace ( A (1) ,s , t ) ;
F2 = ilaplace ( A (2) ,s , t ) ;
xt = F1 + F2 ;
disp ( xt , x ( t )= )
10
5
6
7
8
9
10
11
// Example 3 . 5
clc
s = %s ;
syms t ;
xs =1/( s *( s ^2 -2* s +5) ) ;
disp ( xs , x ( s )= )
[ A ]= pfss ( xs )
F1 = ilaplace ( A (1) ,s , t ) ;
F2 = ilaplace ( A (2) ,s , t ) ;
xt = F1 + F2 ;
disp ( xt , x ( t )= )
// Example 3 . 6
clc
s = %s ;
syms t ;
xs =1/( s *( s ^3+3* s ^2+3* s +1) ) ;
disp ( xs , x ( s )= )
[ A ]= pfss ( xs )
F1 = ilaplace ( A (1) ,s , t ) ;
F2 = ilaplace ( A (2) ,s , t ) ;
11
10 xt = F1 + F2 ;
11 disp ( xt , x ( t )= )
12
Chapter 4
Further Properties of
Transforms
// Example 4 . 1
clc
s = %s ;
num = poly (1 , s , c o e f f ) ;
den = s * poly ([1 3 3 1] , s , c o e f f ) ;
xs = num / den ;
disp ( xs , x s= )
syms s ;
xt = limit ( s * xs ,s ,0) ; // f i n a l v a l u e t h e o r e m
disp ( xt , x ( t )= )
13
num = poly ([ -8 0 9 -6 1] , s , c o e f f ) ;
den = s *( s -2) * poly ([ -2 -1 2 1] , s , c o e f f )
xs = num / den ;
disp ( xs , x ( s )= )
disp ( s * xs , s x ( s )= )
[ A ]= pfss ( s * xs )
printf ( s i n c e x s becomes i n f i n i t e f o r s =1 and s =2 ,
the c o n d i t i o n s o f the f i n a l v a l u e theorem ar e not
s a t i s f i e d \n )
11 printf ( F i n a l v a l u e t h e o r e m i s n o t a p p l i c a b l e \n )
4
5
6
7
8
9
10
14
Chapter 5
Response of First Order
Systems
15
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
33
16
17
Chapter 6
Physical Examples of First
Order Systems
// Example 6 . 1
clc ;
syms s t ;
tau =1; // min
R =1/9; // f t / cfm
A =9;
// from E q u a t i o n 6 . 8
g = R /( tau * s +1) ;
disp (g , H( s ) /Q( s )= )
// from Example 4 . 5
disp ( Q( t ) =90[ u ( t )u ( t 0 . 1 ) )
// where u ( t ) i s a u n i t s t e p f u n c t i o n , t h e l a p l a c e
transform of i t gives
Qs =90*(1 - exp ( -0.1* s ) ) / s
disp ( Qs , Q( s )= )
Hs = Qs * g ;
disp ( Hs , H( s )= )
// t a k i n g f i r s t term f o r t < 0 . 1 , t h e s e c o n d term g o e s
equals to zero
18
19
Chapter 7
Response of First Order
Systems in Series
// Example 7 . 1
clc
s = %s ;
tau1 =0.5;
tau2 =1;
R2 =1;
// From Eq . ( 7 . 8 )
g = R2 /(( tau1 * s +1) *( tau2 * s +1) )
disp (g , H2 ( s ) /Q( s )= )
Qs =1/ s ;
H2s = g * Qs ;
disp ( H2s , H2 ( s )= )
syms t ;
H2t = ilaplace ( H2s ,s , t ) ;
disp ( H2t , H2 ( t )= )
20
Chapter 10
Controllers and Final Control
Elements
// Example 1 0 . 1
clear
clc
t1 =60; // F a h r e n h e i t
t2 =100; // F a h r e n h e i t
p1 =3; // p s i
p2 =15; // p s i
T1 =71; // F a h r e n h e i t
T2 =75; // F a h r e n h e i t
pb =(( T2 - T1 ) /( t2 - t1 ) ) *100;
disp ( % ,pb , p r o p o r t i o n a l band= )
Gain =( p2 - p1 ) /( T2 - T1 ) ;
disp ( p s i /F , Gain , Gain= )
// Assume pb i s c h a n g e d t o 75% t h e n
pb =75; //%
T =( pb *( t2 - t1 ) ) /100;
disp ( F a h r e n h e i t ,T , T= )
Gain =( p2 - p1 ) / T ;
disp ( p s i /F , Gain , Gain= )
21
22
Chapter 12
Closed Loop Transfer functions
// Example 1 2 . 1
clc
syms Gc G1 G2 G3 H1 H2 R U1 ;
G = Gc * G1 * G2 * G3 * H1 * H2 ;
g = Gc * G1 * G2 * G3 /(1+ G ) ;
disp (g , C/R= )
g1 = G2 * G3 /(1+ G ) ;
disp ( g1 , C/U1= )
g2 = G3 * H1 * H2 /(1+ G ) ;
disp ( g2 , B/U2= )
C1 = g * R ;
C2 = g1 * U1 ;
disp ( C1 + C2 , C= )
23
3
4
5
6
7
8
24
Chapter 14
Stability
25
21
22
23
24
25
26
27
28
7
8
9
10
11
12
13
14
15
16
17
18
in the f i r s t
column , t h e r e a r e no r o o t s h a v i n g p o s i t i v e r e a l
p a r t s , and t h e s y s t e m i s s t a b l e .
y = coeff ( h ) ;
n = length ( y ) ;
c =0;
for i =1: n
if ( r (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 ( s y s t e m i s s t a b l e )
end
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
32
// Example 1 4 . 3
clc
syms Kc s s3 ;
G1 =1/(( s +1) *(0.5* s +1) ) ;
H =3/( s +3) ;
G = Kc * G1 * H ;
G = simple ( G ) ;
// The c h a r a c t e r i s t i c e q u a t i o n i s t h e r e f o r e
disp ( 1+G=0 )
disp ( =0 ,1+G , 1+G= ) ;
// which i s e q u i v a l e n t t o
disp ( s 3+6 s 2+11 s +6+6Kc=0 )
routh =[1 11;6 6+6* Kc ]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) ,0]
routh =[ routh ; - det ( routh (2:3 ,1:2) ) / routh (3 ,1) ,0]
routh = simple ( routh )
disp ( >0 , routh (3 ,1) )
disp ( Kc<10 )
Kc =10;
routh = horner ( routh , Kc ) ;
routh = dbl ( routh )
C = routh (2 ,1) ;
D = routh (2 ,2) ;
p = poly ([ D 0 C ] , s , c o e f f )
disp ( 6 s 2+66=0 )
r = roots ( p )
disp ( =0 , simple (( s - r (1 ,1) ) *( s - r (2 ,1) ) *( s - s3 ) ) )
//On c o m p a r i n g w i t h t h e e q u a t i o n
poly ([6+6* Kc 11 6 1] , s , c o e f f )
// we g e t
s3 = -6;
printf ( s 1 = 3 . 3 1 6 6 2 4 8 i , s 2 = 3 . 3 1 6 6 2 4 8 i , , s 3 =6\n )
27
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
// Example 1 4 . 4
clc
s = %s ;
tau1 =1;
tau2 =1/2;
tau3 =1/3;
taui =0.25;
Kc =5;
n = Kc /( tau1 * tau2 * tau3 ) *( taui * s +1) ;
d = taui * s *( s +(1/ tau1 ) ) *( s +(1/ tau2 ) ) *( s +(1/ tau3 ) ) ;
G = syslin ( c ,n / d ) ;
// The c h a r a c t e r i s t i c e q u a t i o n i s t h e r e f o r e
disp ( 1+G=0 )
disp ( =0 ,1+G , 1+G= ) ;
// which i s e q u i v a l e n t t o
disp ( s 4+6 s 3+11 s 2+36 s +120=0 )
h = poly ([120 36 11 6 1] , s , c o e f f )
r = routh_t ( h )
y = coeff ( h ) ;
n = length ( y ) ;
c =0;
for i =1: n
if ( r (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 \n )
else ( s y s t e m i s s t a b l e )
end
28
Chapter 15
Root Locus
// Example 1 5 . 1
clc
s = %s ;
syms K ;
N =1;
D = poly ([ -1 -2 -3] , s , r o o t s ) ;
G = syslin ( c ,N / D ) ;
disp ( K *G , G= )
evans ( G )
v =[ -3.5 3.5 -6 6];
mtlb_axis ( v ) ;
xgrid
29
30
s = %s ;
syms Kc ;
N =1+(2* s /3) +1/(3* s ) ;
D =(20* s +1) *(10* s +1) *(0.5* s +1) ;
G=N/D;
G = syslin ( c ,G ) ;
disp ( Kc *G , G= )
clf
evans ( G )
v =[ -2.5 1 -5 5];
mtlb_axis ( v ) ;
xgrid
31
Chapter 16
Introduction To Frequency
Response
// Example 1 6 . 1
clc
s = %s ;
j = %i ;
f =10/ %pi ;
w =2* %pi * f ;
G =1/(0.1* s +1) ;
s=w*j;
Gs = horner (G , s ) ;
disp ( Gs , G( 2 0 j )= )
[r , theta ]= polar ( Gs )
theta = theta *180/ %pi ;
disp ( d e g r e e s , theta , t h e t a= )
32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Example 1 6 . 2
clc
syms tau s zeta w ;
j = %i ;
n =1;
d = tau ^2* s ^2+2* zeta * tau * s +1;
G=n/d
s=j*w;
G =1/(2* s * tau * zeta + s ^2* tau ^2+1)
[ num den ]= numden ( G )
d = abs ( den )
cof_a_0 = coeffs ( den , %i ,0)
cof_a_1 = coeffs ( den , %i ,1)
AR =1/ d
theta = AR * atan ( - cof_a_1 / cof_a_0 ) ;
disp ( theta , Phase a n g l e= )
// Example 1 6 . 4
clc
s = %s ;
H =1/( s +1) ;
Hs = syslin ( c ,H )
J =1/( s +5) ;
Js = syslin ( c ,J )
G = Hs * Js ;
Gs = syslin ( c ,G )
clf
bode ([ Hs ; Js ; Gs ;])
legend ([ 1 / ( s +1) ; 1 / ( s /5+1) ; 1 / ( 5 ( s +1) ( s /5+1) )
])
33
34
) )
5 printf ( exp ( 0.1 s ) =(2 0.1 s ) / ( 2 + 0 . 1 s ) \n ) )
6 G =10*(0.5* s +1) *(2 -0.1* s ) /((( s +1) ^2) *(0.1* s +1)
*(2+0.1* s ) ) ;
7 Gs = syslin ( c ,G )
8 clf
9 bode ( Gs )
35
36
Chapter 17
Control System Design By
Frequeny Response
37
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Example 1 7 . 3
clc ;
syms Kc tauI s ;
g1 = Kc *(1+1/( tauI * s ) ) ;
g2 =1/( s +1) ;
g2 = exp ( -1.02* s )
G = g1 * g2 * g3 // Openloop t r a n s f e r f u n c t i o n
//By s o l v i n g t h e e q u a t i o n 180= a t a n (w) 5 7 . 3 1 . 0 2 w ,
we g e t
wc0 =2; // r a d / min
disp ( AR=Kcu/ s q r t (1+ wc0 2 ) )
AR =1;
Kcu = AR * sqrt (1+ wc0 ^2) ;
// From Z i e g l e r N i c h o l a s r u l e s
Kc = Kcu *0.45 // u l t i m a t e g a i n
Pu =2* %pi / wc0 ; // u l t i m a t e p e r i o d
tauI = Pu /1.2;
disp ( min , tauI , t a u I= )
// Example 1 7 . 4
clc
s = %s ;
syms Kc K1 tauI tauD
K =0.09;
Kc = K1 / K ;
Gc = K1 *(1+1/( tauI * s ) + tauD * s )
g1 =1/(( s +1) *( s +2) ) ;
// g2=exp ( 0.5 s ) , we can w r i t e i t a s g2 =(2 0.5 s )
/(2+0.5 s ) . Therefore ,
g2 =(2 -0.5* s ) /(2+0.5* s ) ;
G = g1 * g2 ;
G = syslin ( c ,G )
clf
39
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
bode ( G )
show_margins ( G )
// From t h e bode d i a g r a m s we g e t
wc0 =1.56; // r a d / min
A =0.145;
Ku =1/ A
Pu =2* %pi / wc0
//By ZN r u l e s
// For P c o n t r o l l e r
K1 =0.5* Ku
Gc = K1
G1 = Gc * G / K1
// For PI c o n t r o l l e r
K1 =0.45* Ku
tauI = Pu /1.2
Gc = K1 *(1+1/( tauI * s ) )
G2 = Gc * G / K1
// For PID c o n t r o l l e r
K1 =0.6* Ku
tauI = Pu /2
tauD = Pu /8
Gc = K1 *(1+1/( tauI * s ) + tauD * s )
G3 = Gc * G / K1
clf
bode ([ G1 ; G2 ; G3 ])
legend ([ G1 ; G2 ; G3 ]) ;
40
41
42
Chapter 18
Advanced Control Strategies
// Example 1 8 . 3
clc
s = %s ;
Kf = -1;
tp =2;
// A p p l y i n g f e e d f o r w a r d c o n t r o l r u l e s
T1 =1.5* tp
T2 =0.7* tp
Gfs = Kf *( T1 * s +1) /( T2 * s +1) ;
disp ( Gfs , Gf ( s )= )
43
6
7
8
9
10
11
12
13
14
15
16
17
Gma =1;
Gmm = K /( tau * s +1) ;
Gm = Gma * Gmm ;
GI =1/ Gmm
f =1/( l * s +1) ;
// I n o r d e r t o be a b l e t o i m p l e m e n t t h i s t r a n s f e r
f u n c t i o n l e t f ( s ) =1/( l s +1)
// Thus IMC becomes
GI = f / Gmm
Gc = GI /(1 - GI * Gm )
//On s i m p l i f i c a t i o n , i t w i l l be i n t h e form o f
Gc = tau *(1+1/( tau * s ) ) /( l * s * K )
printf ( The r e s u l t i s i n t h e form o f PI c o n t r o l l e r )
// Example
clc
syms K taud s tau t
G = K * exp ( - taud * s ) /( tau * s +1)
// we can u s e an a p p r o x i m a t i o n t h a t
printf ( exp ( t a u d s ) =(2 t a u d s / 2 ) /(2+ t a u d s ) \n )
Gm = K *(2 - taud * s /2) /((2+ taud * s ) *( tau * s +1) ) ; // h e r e Gm=G
// For t h i s model
Gma =(2 - taud * s /2) /(2+ taud * s ) ;
Gmm = K /( tau * s +1) ;
Gm = Gma * Gmm ;
GI =1/ Gmm
f =1/( l * s +1) ;
// I n o r d e r t o be a b l e t o i m p l e m e n t t h i s t r a n s f e r
f u n c t i o n l e t f ( s ) =1/( l s +1)
// Thus IMC becomes
GI = f / Gmm
Gc = GI /(1 - GI * Gm )
// T h i s may be r e d u c e d a l g e b r a i c a l l y t o t h e form
44
19
20
21
22
g i v e n by Eq . ( 1 8 . 2 1 ) w i t h
printf ( Kc=(2 t a u+t a u d ) / ( 2 l +t a u d ) \n )
printf ( t a u I=t a u+t a u d /2\ n )
printf ( t a u t a u d ) / ( 2 t a u+t a u d ) \n )
printf ( t a u 1= l t a u d / 2 ( l+t a u d ) \n )
45
Chapter 19
Controller Tuning And Process
Identification
// Example 1 9 . 1
clc
s = poly (0 , s ) ;
syms tauI Kc
Gc =1+1/( tauI * s ) ;
g1 =1/( s +1) ;
// g2=exp ( s ) ;
// we can w r i t e exp ( s ) a s (2 s ) /(2+ s ) . T h e r e f o r e ,
g2 =(2 - s ) /(2+ s ) ;
G = g1 * g2 ;
G = syslin ( c ,G )
Gp = Kc * Gc * G
Gs = Gp /(1+ Gp ) // O v e r a l l t r a n s f e r f u n c t i o n
// Z i e g l e r N i c h o l a s method
scf (1) ;
clf
bode ( G )
show_margins ( G )
// From bode d i a g r a m s we g e t
46
20
21
22
23
24
25
26
27
28
29
30
31
32
wc0 =2.03
Kcu =2.26
Pu =2* %pi / wc0
// S i n c e Gc i s a PI c o n t r o l l e r , by ZN r u l e s
Kc =0.45* Kcu
tauI = Pu /1.2
// CohenCoon method
// Comaparing G w i t h Eq . ( 1 9 . 6 ) , we g e t
T =1;
Td =1;
Kp =1;
Kc = T *(0.9+ Td /(12* T ) ) /( Kp * Td )
tauI = Td *(30+3* Td / T ) /(9+20* Td / T )
// Example 1 9 . 2
clc
s = %s ;
syms t Kc tauI ;
Gc = Kc *(1+1/( tauI * s ) )
G =1/( s +1) ^4;
G = syslin ( c ,G )
Gs = Gc * G /(1+ Gc * G ) // O v e r a l l t r a n s f e r f u n c t i o n
Us =1/ s ;
Cs = G * Us ;
// CohenCoon method
Ct = ilaplace ( Cs ,s , t )
Ct1 = diff ( Ct , t )
Ct2 = diff ( Ct1 , t )
disp ( =0 , Ct2 )
//On s o l v i n g t h e e q u a t i o n we g e t
t = linsolve ( -1 ,3)
47
48
18
19
20
21
22
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
S = dbl ( Ct1 )
C3 = dbl ( Ct )
// From t h e f i g u r e 1 9 . 1 0 (B Vs t )
y2 =0.353;
y1 =0;
x2 =3;
Td =3 -( y2 - y1 ) / S
Bu =1; // u l t i m a t e v a l u e o f B
// From Eq . ( 1 9 . 4 )
T = Bu / S
Kp =1;
// From T a b l e 1 9 . 2
Kc = T *(0.9+ Td /(12* T ) ) /( Kp * Td )
tauI = Td *(30+3* Td / T ) /(9+20* Td / T )
//By ZN method
clf
bode ( G )
show_margins ( G )
// From Bode d i a g r a m s we g e t
Kcu =4;
Pu =2* %pi ;
// S i n c e Gc i s a PI c o n t r o l l e r , by ZN r u l e s
Kc =0.45* Kcu
tauI = Pu /1.2
//By f i t t i n g t h e p r o c e s s r e a c t i o n c u r v e t o a f i r s t
o r d e r w i t t r a n s p o r t l a g model by means o f a l e a s t
square f i t t i n g procedure . Applying the l e a s t
s q u a r e f i t p r o c e d u r e o u t t o t =5 p r o d u c e d t h e
following results
Td =1.5;
T =3;
//By a p p l y i n g CohenCoon r u l e s , we g e t
Kc = T *(0.9+ Td /(12* T ) ) /( Kp * Td )
tauI = Td *(30+3* Td / T ) /(9+20* Td / T )
49
50
Chapter 20
Control Valves
// Example 2 0 . 1
clc
Cv =4;
G =1.26;
P =100; // p s i
q = Cv * sqrt ( P / G ) ;
disp ( gpm ,q , q= )
// Example 2 0 . 2
clc
L =100; // f t
D =1; // f t
D1 = D /12; // i n c h e s
D2 = D1 *2.42; // c e n t i m e t r e s
rho =62.4; // l b / f t 3
mu =1.5; // cp
51
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Cv =4;
pv =100; // p s i
G =1;
q = Cv * sqrt ( pv / G ) ; //maximum f l o w
disp ( gpm ,q , q= )
printf ( L e t u s s t a r t f l o w from q=30 gpm\n )
q =30; //gpm
q1 = q /(60*7.48) ; // f t 3/ s e c
q2 = q1 *60*60; // f t 3/ h r
Re =4* q2 * rho /( %pi * mu * D2 ) // R e y n o l d s number
// For t h i s v a l u e o f R e y n o l d s number and f o r smooth
pipe fanning f r i c t i o n fa c to r i s 0.005
f =0.005; // f a n n i n g f r i c t i o n f a c t o r
gc =32.2;
p =32* f * L * rho * q1 ^2/(144* %pi ^2* gc * D1 ^5) ; // p s i
P = pv - p
qmax = Cv * sqrt ( P / G ) ;
disp ( gpm , qmax , qmax= )
x = q / qmax // l i f t
// Example 2 0 . 3
clc
L =200; // f t
D =1; // f t
D1 = D /12; // i n c h e s
D2 = D1 *2.42; // c e n t i m e t r e s
rho =62.4; // l b / f t 3
mu =1.5; // cp
pv =100; // p s i
G =1;
q =30; //maximum f l o w
disp ( gpm ,30 , q= )
q1 = q /(60*7.48) ; // f t 3/ s e c
52
14 q2 = q1 *60*60; // f t 3/ h r
15 Re =4* q2 * rho /( %pi * mu * D2 ) // R e y n o l d s number
16 // For t h i s v a l u e o f R e y n o l d s number and f o r smooth
17
18
19
20
21
22
23
24
25
26
27
28
29
53
Chapter 22
Sampling And Z Transforms
54
Chapter 24
Stability
// Example 2 4 . 1
clc
syms K b z w ;
Gz = K *(1 - b ) /( z - b )
// where b=exp (T/ t a u )
// From Eq . ( 2 4 . 4 )
z = w +1/ w -1;
Gz = eval ( Gz )
disp ( =0 ,1+ Gz , 1+G( z )= )
// which i s e q u i v a l e n t t o
disp ( (K+1) (1 b ) w+(1+b )K(1b ) =0 )
routh =[( K +1) *(1 - b ) ;(1+ b ) -K *(1 - b ) ]
// b i s a l w a y s p o s i t i v e and l e s s t h a n one and K i s
positive
// The f i r s t e l e m e n t i n t h e a r r a y i s p o s i t i v e
// For s t a b i l i t y , t h e Routh t e s t r e q u i r e s t h a t a l l
e l e m e n t s o f t h e f i r s t column be p o s i t i v e
// T h e r e f o r e ,
disp ( >0 , routh (2 ,1) )
disp ( K<(1+b ) /(1 b ) )
55
Chapter 26
Sampled Data Control Of A
First Order Process With
Transport Lag
// Example 2 6 . 1 ( a )
clc
T =1;
tau =1.25;
b = exp ( - T / tau )
// For q u a r t e r d e c a y r a t i o
alpha =0.5
K =( alpha + b ) /(1 - b )
// U l t i m a t e v a l u e o f C i s
Ci = K /( K +1) ;
disp ( Ci , C( i n f )= )
Ri =1;
Offset = Ri - Ci
Period =2* T
56
// Example 2 6 . 1 ( a )
clc
T =0.5;
tau =1.25;
b = exp ( - T / tau )
// For q u a r t e r d e c a y r a t i o
alpha =0.5
K =( alpha + b ) /(1 - b )
// U l t i m a t e v a l u e o f C i s
Ci = K /( K +1) ;
disp ( Ci , C( i n f )= )
Ri =1;
Offset = Ri - Ci
Period =2* T
57
Chapter 29
Transfer Function Matrix
1
2
3
4
5
6
7
8
9
10
11
12
58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Example 2 9 . 2
clc
A =[ -2 0;4 -3]
B =[1 0;0 2]
syms s H1s H2s U1s U2s
I = eye (2 ,2)
Gs = inv ( s *I - A ) * B
Hs =[ H1s ; H2s ]
Us =[ U1s ; U2s ]
Hs = Gs * Us
//On c o m p a r i n g
H1s = Hs (1 ,1)
H2s = Hs (2 ,1)
U2s =0;
U1s =1/ s ;
H1s = eval ( H1s )
H2s = eval ( H2s )
//On i n v e r s e l a p l a c e t r a n s f o r m a t i o n s
H1t = ilaplace ( H1s ,s , t )
H2s = ilaplace ( H2s ,s , t )
59
Chapter 30
Multivariable Control
// Example 3 0 . 1
clc
A1 =1;
A2 =1/2;
R1 =1/2;
R2 =2;
R3 =1;
A =[ -1/( R1 * A1 ) -1/( R3 * A1 ) 1/( A1 * R1 ) ;1/( R1 * A2 ) -1/( R2 *
A2 ) -1/( A2 * R1 ) ]
B =[1/ A1 0;0 1/ A2 ]
syms s M1 M2 ;
I = eye (2 ,2)
Gp = inv ( s *I - A ) * B
G11 = Gp (1 ,1)
G12 = Gp (1 ,2)
G21 = Gp (2 ,1)
G22 = Gp (2 ,2)
M =[ M1 ; M2 ]
Cs = inv ( s *I - A ) * B * M
M1 =1/ s ;
M2 =0;
60
21
22
23
24
Cs = eval ( Cs )
M1 =0;
M2 =1/ s ;
Cs = eval ( Cs )
// Example 3 0 . 2
clc
syms s K1 K2
Gc11 = K1 ;
Gc22 = K2 ;
A1 =1;
A2 =1/2;
R2 =2;
R3 =1;
// I n t h i s p r o b l e m ,Gv i s a u n i t d i a g o n a l m a t r i x i . e
.,
Gv1 =1;
Gv2 =1;
A =[ -1/( R1 * A1 ) -1/( R3 * A1 ) 1/( A1 * R1 ) ;1/( R1 * A2 ) -1/( R2 *
A2 ) -1/( A2 * R1 ) ]
B =[1/ A1 0;0 1/ A2 ]
I = eye (2 ,2)
Gp = inv ( s *I - A ) * B
G11 = Gp (1 ,1)
G12 = Gp (1 ,2)
G21 = Gp (2 ,1)
G22 = Gp (2 ,2)
Gc12 = - G12 * Gv2 * Gc22 /( G11 * Gv1 )
Gc21 = - G21 * Gv1 * Gc11 /( G22 * Gv2 )
Gv =[ Gv1 0;0 Gv2 ]
Gc =[ Gc11 Gc12 ; Gc21 Gc22 ]
Go = Gp * Gv * Gc ;
Go = simple ( Go )
61
// Example 3 0 . 3
clc
A1 =1;
A2 =1/2;
R1 =1/2;
R2 =2;
R3 =1;
Gc11 = K1 ;
Gc22 = K2 ;
Gc12 =0;
Gc21 =0;
A =[ -1/( R1 * A1 ) -1/( R3 * A1 ) 1/( A1 * R1 ) ;1/( R1 * A2 ) -1/( R2 *
A2 ) -1/( A2 * R1 ) ]
B =[1/ A1 0;0 1/ A2 ]
syms s ;
I = eye (2 ,2)
Gp = inv ( s *I - A ) * B
G11 = Gp (1 ,1)
G12 = Gp (1 ,2)
G21 = Gp (2 ,1)
G22 = Gp (2 ,2)
Gv1 =1;
Gv2 =1;
Gm = I
Gv =[ Gv1 0;0 Gv2 ]
Gc =[ Gc11 Gc12 ; Gc21 Gc22 ]
Go = Gp * Gv * Gc ;
Go = simple ( Go )
// From Eq . ( 3 0 . 3 2 )
P = det ( I + Go * Gm )
disp ( =0 , simple ( P ) )
62