Вы находитесь на странице: 1из 63

Scilab Textbook Companion for

Process Systems Analysis And Control


by S. E. LeBlanc And D. R. Coughanowr1
Created by
K. Dheemanth
B.Tech. (pursuing)
Chemical Engineering
UCT (A), Osmania University
College Teacher
Dr. V. Ramesh Kumar, UCT (A), Osmania University
Cross-Checked by
Prashant Dave, IIT Bombay
August 12, 2013

1 Funded

by a grant from the National Mission on Education through ICT,


http://spoken-tutorial.org/NMEICT-Intro. This Textbook Companion and Scilab
codes written in it can be downloaded from the Textbook Companion Project
section at the website http://scilab.in

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

2 The Laplace Transform

3 Inversion by Partial Fractions

4 Further Properties of Transforms

13

5 Response of First Order Systems

15

6 Physical Examples of First Order Systems

18

7 Response of First Order Systems in Series

20

10 Controllers and Final Control Elements

21

12 Closed Loop Transfer functions

23

14 Stability

25

15 Root Locus

29

16 Introduction To Frequency Response

32

17 Control System Design By Frequeny Response

37

18 Advanced Control Strategies

43

19 Controller Tuning And Process Identification

46

20 Control Valves

51

22 Sampling And Z Transforms

54

24 Stability

55

26 Sampled Data Control Of A First Order Process With Transport Lag


56
29 Transfer Function Matrix

58

30 Multivariable Control

60

List of Scilab Codes


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

2.1
2.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

First order systems . . . . . . . . . . . . . . . . . . . . . . .

17

15.1 Root locus . . . . . . . . . . . . . . . . . . . . . . . . . . . .


15.2 Root locus . . . . . . . . . . . . . . . . . . . . . . . . . . . .

30
31

16.1 Bode diagram . . . . . . . . . . . . . . . . . . . . . . . . . .


16.2 Bode diagram . . . . . . . . . . . . . . . . . . . . . . . . . .

34
36

17.1 Frequency Response . . . . . . . . . . . . . . . . . . . . . .


17.2 Tuning Rules . . . . . . . . . . . . . . . . . . . . . . . . . .
17.3 Tuning Rules . . . . . . . . . . . . . . . . . . . . . . . . . .

38
41
42

19.1 Tuning Rules . . . . . . . . . . . . . . . . . . . . . . . . . .


19.2 Tuning Rules . . . . . . . . . . . . . . . . . . . . . . . . . .

48
50

Chapter 2
The Laplace Transform

Scilab code Exa 2.1 Laplace transform


1 // Example 2 . 1
2 syms t s ;
3 fs = laplace ( 1 ,t , s ) ;
4 disp ( fs , f ( s )= )

Scilab code Exa 2.3 Laplace transform


1
2
3
4
5
6
7
8

// 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

Scilab code Exa 3.1 Inverse laplace transform


1
2
3
4
5
6
7
8
9
10
11

// 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 )= )

Scilab code Exa 3.2 Inverse laplace transform


1 // Example 3 . 2
2 clc
3 s = %s ;
4 syms 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 )= )

Scilab code Exa 3.3 Inverse laplace transform


1
2
3
4
5
6
7
8
9
10
11

// 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 )= )

Scilab code Exa 3.4 Inverse laplace transform


1 // Example 3 . 4
2 clc
3 s = %s ;
4 syms t ;

10

5
6
7
8
9
10
11

xs =2/(( s ^2+4) *( s +1) ) ;


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 )= )

Scilab code Exa 3.5 Inverse laplace transform


1
2
3
4
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 )= )

Scilab code Exa 3.6 Inverse laplace transform


1
2
3
4
5
6
7
8
9

// 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

Scilab code Exa 4.1 Final value theorem


1
2
3
4
5
6
7
8
9
10

// 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 )= )

Scilab code Exa 4.2 Final value theorem


1 // Example 4 . 2
2 clc
3 s = %s ;

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

Scilab code Exa 4.4 Laplace transform


1 // Example 4 . 4
2 clc
3 syms t s a k ;
4 xt = laplace ( %e( a t ) c o s ( k t ) ,t , s ) ;
5 disp ( xt , x ( t )= )
6 x

14

Chapter 5
Response of First Order
Systems

Scilab code Exa 5.1 First order systems


// Example 5 . 1
tau =0.1; // min
xs =90; // d e g r e e s
A =10; // d e g r e e s
Y_inf =10; // d e g r e e s
Y_t =8; // d e g r e e s
// S u b s t i t u t i n g i n t o Eq . ( 5 . 1 2 ) t h e a p p r o p r i a t e v a l u e s
o f Y t , A, and t a u g i v e s
8 t = -0.1* logm (1 -( Y_t / A ) ) ; // min
9 disp ( min ,t , t i m e= )
1
2
3
4
5
6
7

Scilab code Exa 5.2 First order systems


1 // Example 5 . 2
2 clear all
3 clc

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

tau =0.1; // min


xs =100; // F a h r e n h e i t
ys =100; // F a h r e n h e i t
A =2; // F a h r e n h e i t
f =10/ %pi ; // c y c l e s / min
w =2* %pi * f ; // r a d / min
// From Eq . ( 5 . 2 5 ) , t h e a m p l i t u d e o f t h e r e s p o n s e and
the phase angle are c a l c u l a t e d ; thus
disp ( F a h r e n h e i t ,A / sqrt (( tau * w ) ^2+1) , A/ s q r t ( ( t a u w
) 2+1)= )
phi = atan ( - w * tau ) ; // r a d i a n s
phi = phi *180/ %pi ; // d e g r e e s
disp ( d e g r e e s ,phi , p h a s e l a g= )
t =0:0.01:1;
// From Eq . ( 5 . 1 9 ) , t h e i n p u t o f t h e t h e r m o m e t e r i s
therefore
disp ( X( t ) =2 s i n ( 2 0 t ) ) ;
// o r
xt = xs +2* sin (20* t ) ;
// The r e s p o n s e o f t h e t h e r m o m e t e r i s t h e r e f o r e
disp ( Y( t ) = 0 . 8 9 4 4 s i n ( 2 0 t 6 3 . 4 3 4 9 ) )
// o r
yt = ys +0.8944* sin (20* t -63.4349) ;
Lag = phi /(360* f ) ; // min
Lag = abs ( Lag ) ; // min
disp ( min ,Lag , Lag= )
clf ;
plot (t , yt )
plot (t , xt )
xlabel ( t i m e )
ylabel ( x ( t ) , y ( t ) )
title ( x ( t ) , y ( t ) Vs t i m e )
xgrid

16

Figure 5.1: First order systems

17

Chapter 6
Physical Examples of First
Order Systems

Scilab code Exa 6.1 First order systems


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

// 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

18 Ht = ilaplace ( 1 0 ( 1 / ( s ( s +1) ) ) ,s , t ) ; // t <0.1


19 disp ( Ht , H( t )= )
20 disp ( H( t ) =10(1 yexp (( t 0 . 1 ) ) ) ) // t >0.1
21 Ht =10*((1 - exp ( - t ) ) -(1 - exp ( -( -t -0.1) ) ) ) ;
22 disp ( Ht , H( t )= )
23 // from Eq . ( 5 . 1 6 )
24 Ht = R * A * exp ( -( t / tau ) ) ; // i m p u l s e
25 disp ( Ht , H( t )= )

19

Chapter 7
Response of First Order
Systems in Series

Scilab code Exa 7.1 First order systems


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

// 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

Scilab code Exa 10.1 Control system


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

// 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

Scilab code Exa 12.1 Transfer functions


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

// 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= )

Scilab code Exa 12.2 Transfer functions


1 // Example 1 2 . 2
2 clc

23

3
4
5
6
7
8

syms Gc1 Gc2 G1 G2 G3 H1 H2 ;


Ga = Gc2 * G1 /. H2
Gb = G2 * G3
g = Gc1 * Ga * Gb /. H1 ;
g = simple ( g ) ;
disp (g , C/R= )

24

Chapter 14
Stability

Scilab code Exa 14.1 Stability


// Example 1 4 . 1
clear
clc
s = %s ;
G1 =10*((0.5* s +1) / s ) ;
G2 =1/(2* s +1) ;
H =1;
G = G1 * G2 * H
// 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 2+3 s +5=0 ) ;
h = poly ([5 ,3 ,1] , s , c o e f f ) ;
r = roots ( h )
disp (r , r o o t s= )
// S i n c e t h e r e a l p a r t o f r o o t s a r e n e g a t i v e , t h e
system i s s t a b l e
18 n = length ( r ) ;
19 c =0;
20 for i =1: n
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

25

21
22
23
24
25
26
27
28

if ( real ( r (i ,1) ) <0)


c = c +1;
end
end
if (c >=1)
printf ( s y s t e m i s s t a b l e \n )
else ( s y s t e m i s u n s t a b l e )
end

Scilab code Exa 14.2 Stability


1 // Example 1 4 . 2
2 clear ;
3 clc
4 h = poly ([2 ,4 ,5 ,3 ,1] , s , c o e f f ) ;
5 r = routh_t ( h )
6 // S i n c e t h e r e i s no c h a n g e i n s i g n

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

Scilab code Exa 14.3 Stability


26

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 )

Scilab code Exa 14.4 Stability

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

Scilab code Exa 15.1 Root locus


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

// 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

Scilab code Exa 15.2 Root locus


1 // Example 1 5 . 2
2 clc

29

Figure 15.1: Root locus

30

Figure 15.2: Root locus


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

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

Scilab code Exa 16.1 Frequency Response


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

// 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= )

Scilab code Exa 16.2 Frequency Response

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= )

Scilab code Exa 16.4 Bode diagram


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

// 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

Figure 16.1: Bode diagram

34

Scilab code Exa 16.5 Bode diagram


1 // Example 1 6 . 5
2 clc
3 s = poly (0 , s ) ;
4 disp ( G= 1 0 ( 0 . 5 s +1) exp ( s / 1 0 ) / ( ( ( s +1) 2 ) ( 0 . 1 s +1)

) )
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

Figure 16.2: Bode diagram

36

Chapter 17
Control System Design By
Frequeny Response

Scilab code Exa 17.1 Frequency Response


// Example 1 7 . 1
clc
s = %s ;
syms Kc
tau =1;
taum =1;
wC =1;
g1 = Kc ;
g2 =1/( s +1) ;
g3 =1/( s +1) ;
G1 = g2 * g3 ;
G1 = syslin ( c , G1 )
G = g1 * g2 /. g3 ;
disp (G , C( s ) /R( s )= )
// T h i s e q u a t i o n can be w r i t t e n i n t h e form o f Kc ( s
+1) /((1+ Kc ) ( t a u 2 2 s 2+2 t a u 2 z e t a 2 s +1)
16 tau2 = sqrt (1/(1+ Kc ) )
17 zeta2 = sqrt (1/(1+ Kc ) )
18 clf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

37

Figure 17.1: Frequency Response


19 bode ( G1 )
20 show_margins ( G1 )
21 //To make t h e open l o o p g a i n 1 a t w=4
22 phaseangle = -152 // d e g r e e s
23 phasemargin =180+ phaseangle // d e g r e e s
24 // At t h i s p h a s e margin , t h e g a i n m a r g i n i s
25 A =0.062 // g a i n m a r g i n
26 Kc =1/ A
27 zeta2 = dbl ( zeta2 )

Scilab code Exa 17.3 Tuning Rules


38

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= )

Scilab code Exa 17.4 Tuning Rules


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

// 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

Figure 17.2: Tuning Rules

41

Figure 17.3: Tuning Rules

42

Chapter 18
Advanced Control Strategies

Scilab code Exa 18.3 Tuning Rules


1
2
3
4
5
6
7
8
9
10

// 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 )= )

Scilab code Exa 18.5 Internal Model Control


1 // Example 1 8 . 5
2 clc
3 syms K tau s l ;
4 Gm = K /( tau * s +1) ;
5 // For t h i s c a s e

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 )

Scilab code Exa 18.6 Internal Model Control


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

// 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

Scilab code Exa 19.1 Tuning Rules


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

// 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 )

Scilab code Exa 19.2 Tuning Rules


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

// 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

Figure 19.1: Tuning Rules

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

Figure 19.2: Tuning Rules

50

Chapter 20
Control Valves

Scilab code Exa 20.1 Control Valves


1
2
3
4
5
6
7

// Example 2 0 . 1
clc
Cv =4;
G =1.26;
P =100; // p s i
q = Cv * sqrt ( P / G ) ;
disp ( gpm ,q , q= )

Scilab code Exa 20.2 Control Valves


1
2
3
4
5
6
7
8

// 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

Scilab code Exa 20.3 Control Valves


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

// 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

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
Cv = q / sqrt ( P / G )
// For q=20
q =20; //gpm
q1 = q /(60*7.48) ; // f t 3/ s e c
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

53

Chapter 22
Sampling And Z Transforms

Scilab code Exa 22.1 Z transforms


1 // Example 2 2 . 1
2 clc
3 disp ( f ( t )=u ( t ) =1 )
4 disp ( f ( nT ) =1 ) // f o r n>=0
5 syms z n
6 // From Eq . ( 2 2 . 8 )
7 Z = symsum ( z ^( - n ) ,n ,0 , %inf )

Scilab code Exa 22.2 Z transforms


1 // Example 2 2 . 2
2 clc
3 syms T tau z n
4 disp ( f ( t )=exp ( t / t a u ) )
5 ft = exp ( - n * T / tau ) * z ^( - n ) ;
6 Z = symsum ( ft ,n ,0 , %inf )

54

Chapter 24
Stability

Scilab code Exa 24.1 Stability


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

// 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

Scilab code Exa 26.1.a Sampled data system


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

// 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

Scilab code Exa 26.1.b Sampled data system


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

// 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

Scilab code Exa 29.1 Transfer function matrix


// Example 2 9 . 1
clc
syms t tau
A =[ -1 1;0 -2]
B =[0;1]
x0 =[ -1;0]
printf ( x1=Ax+Bu ( t ) )
//On s o l v i n g g i v e n e q u a t i o n
// l e t X=exp (A t )
X =[ exp ( - t ) exp ( - t ) - exp ( -2* t ) ;0 exp ( -2* t ) ]
//Y=exp (A ( tt a u ) )
Y =[ exp ( -(t - tau ) ) exp ( -(t - tau ) ) - exp ( -2*( t - tau ) ) ;0
exp ( -2*( t - tau ) ) ]
13 // From Eq . ( 2 9 . 4 )
14 xt = X * x0 + integ ( Y *B , tau ,0 , t )

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

Scilab code Exa 29.2 Transfer function matrix

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

Scilab code Exa 30.1 Multivariable control


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

// 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 )

Scilab code Exa 30.2 Multivariable control


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

// 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

Scilab code Exa 30.3 Multivariable control


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 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

Вам также может понравиться