0% found this document useful (0 votes)
84 views

Control and Instrumentation - Prof - A. George Ansfer

The document is a Scilab manual for control and instrumentation containing solutions to experiments involving digital simulation of controllers and linear systems. It includes 5 solutions for experiments on digital simulation of P, PI, PD and PID controllers with figures; a solution for the digital simulation of a linear system's step response under different damping conditions with a figure; and solutions for experiments on the effects of stability and frequency domain methods for controller design with accompanying figures.

Uploaded by

123_JE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Control and Instrumentation - Prof - A. George Ansfer

The document is a Scilab manual for control and instrumentation containing solutions to experiments involving digital simulation of controllers and linear systems. It includes 5 solutions for experiments on digital simulation of P, PI, PD and PID controllers with figures; a solution for the digital simulation of a linear system's step response under different damping conditions with a figure; and solutions for experiments on the effects of stability and frequency domain methods for controller design with accompanying figures.

Uploaded by

123_JE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Scilab Manual for

Control and Instrumentation


by Prof A. George Ansfer
Electrical Engineering
St. Xaviers Catholic College of Engineering1

Solutions provided by
Prof A.George Ansfer
Electrical Engineering
St.Xaviers Catholic College of Engineering

January 18, 2017

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


http://spoken-tutorial.org/NMEICT-Intro. This Scilab Manual and Scilab codes
written in it can be downloaded from the Migrated Labs section at the website
http://scilab.in
1
Contents

List of Scilab Solutions 3

1 Digital Simulation of P, PI, PD & PID Controller 5

2 Digital Simulation of Linear System 8

3 Simulation of Control Systems 10

2
List of Experiments

Solution 1.1Exp1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Solution 2.2exp2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Solution 3.3exp3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Solution 3.4exp4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3
List of Figures

1.1 Exp1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.1 exp2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3.1 exp3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 exp4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4
Experiment: 1

Digital Simulation of P, PI, PD


& PID Controller

Scilab code Solution 1.1 Exp1

1 // D i g i t a l S i m u l a t i o n o f P , PI , PD, and PID


controllers
2 // 1 Open Loop Program
3 num = poly ([10] , s , c o e f f ) ; // Numerator i n p u t
4 den = poly ([20 10 1] , s , c o e f f ) ; // Den omin ator i n p u t
5 q = syslin ( c , num / den ) // R a t i o o f t h e n u m e r a t o r t o t h e
denominator
6 t =0:0.05:2.5; // t i m e i n t e r v a l
7 p = csim ( s t e p ,t , q ) ;
8 subplot (321)
9 plot2d (t , p ) ;
10 xtitle ([ Open Loop ] , Time ( S e c o n d ) , A m p l i t u d e ) ;
11
12 // 2 P C o n t r o l Program
13 kp =300;
14 num = poly ([ kp ] , s , c o e f f ) ;
15 den = poly ([20+ kp 10 1] , s , c o e f f ) ;
16 q = syslin ( c , num / den )
17 t =0:0.01:2;

5
18 p = csim ( s t e p ,t , q ) ;
19 subplot (322)
20 plot2d (t , p ) ;
21 xtitle ([ P C o n t r o l ] , Time ( S e c o n d ) , A m p l i t u d e ) ;
22
23 // 3 PI C o n t r o l Program
24 kp =30;
25 ki =70;
26 num = poly ([ ki kp ] , s , c o e f f ) ;
27 den = poly ([ ki 20+ kp 10 1] , s , c o e f f ) ;
28 q = syslin ( c , num / den )
29 t =0:0.01:2;
30 p = csim ( s t e p ,t , q ) ;
31 subplot (323)
32 plot2d (t , p ) ;
33 xtitle ([ PI C o n t r o l ] , Time ( S e c o n d ) , A m p l i t u d e )
;
34
35 // 4 PD C o n t r o l Program
36 kp =300;
37 kd =10;
38 num = poly ([ kp kd ] , s , c o e f f ) ;
39 den = poly ([20+ kp 10+ kd 1] , s , c o e f f ) ;
40 q = syslin ( c , num / den )
41 t =0:0.01:2;
42 p = csim ( s t e p ,t , q ) ;
43 subplot (324)
44 plot2d (t , p ) ;
45 xtitle ([ PD C o n t r o l ] , Time ( S e c o n d ) , A m p l i t u d e )
;
46
47 // 5 PID C o n t r o l Program
48 kp =350;
49 kd =50;
50 ki =300;
51 num = poly ([ ki kp kd ] , s , c o e f f ) ;
52 den = poly ([ ki 20+ kp 10+ kd 1] , s , c o e f f ) ;
53 q = syslin ( c , num / den )

6
Figure 1.1: Exp1

54 t =0:0.01:2;
55 p = csim ( s t e p ,t , q ) ;
56 subplot (325)
57 plot2d (t , p ) ;
58 xtitle ([ PID C o n t r o l ] , Time ( S e c o n d ) , A m p l i t u d e
);

7
Experiment: 2

Digital Simulation of Linear


System

Scilab code Solution 2.2 exp2

1 // S e c o n d o r d e r s y s t e m s t e p r e s p o n s e f o r damping
conditions
2 t =0:0.0000001:0.0002;
3 d =[0.5 1 1.5]; // E n t e r i n g t h e damping c o n d i t i o n s
values
4 cv =[1 2 3];
5 s = %s ;
6 for n =1:3
7 num = 10^10;
8 den = s ^2 + 2* d ( n ) *100000* s +10^10;
9 P = syslin ( c ,num , den ) ;
10 Ps = csim ( s t e p ,t , P ) ;
11 plot2d (t , Ps , style = cv ( n ) ) ;
12 end ;
13 xgrid (6) ;
14 xtitle ([ S e c o n d o r d e r s t e p r e s p o n s e ] , Time ( S e c o n d )
, Amplitude );
15 legends ([ d = 0 . 5 ( underdamped ) ; d=1( c r i t i c a l l y damped
) ; d = 1 . 5 ( overdamped ) ] ,[1 ,2 ,3] , opt =4) ;

8
Figure 2.1: exp2

9
Experiment: 3

Simulation of Control Systems

Scilab code Solution 3.3 exp3

1 // E f f e c t s on S t a b i l i t y .
2 // G( s ) = a 2 / s ( s +2b a ) , H( s ) = C , T( s ) = C a 2
/ ( s ( s +2b a ) + C a 2 )
3 s = %s ;
4 t =0:0.01:10;
5 a =1; b =1;
6 C =[1 ,2 ,5 ,10]
7 for n =1:4
8 T = syslin ( c , C ( n ) * a ^2 , s *( s + 2* b * a ) + C ( n ) * a
^2 ) ;
9 Ts = csim ( s t e p ,t , T ) ;
10 xset ( l i n e s t y l e ,n ) ;
11 plot2d (t , Ts ) ;
12 xgrid (5) ;
13 end
14 xtitle ( E f f e c t s on S t a b i l i t y . , Time ( s e c ) , C( t ) ) ;
15 legends ([ C=1 ; C=2 ; C=5 ; C=10
;] ,[[1;1] ,[1;2] ,[1;3] ,[1;4]] , opt =4) ;

10
Figure 3.1: exp3

Scilab code Solution 3.4 exp4

1 // F r e q u e n c y Domain Methods f o r c o n t r o l l e r d e s i g n
2
3 // 1 N o r m a l i z e d bandwidth v s Damping f a c t o r ( s e c o n d
order system )
4 deff ( [ a ]= f 1 ( b ) , a=s q r t (1 2 b2+ s q r t (2 4 b2+4b 4 )
) )
5 b =[0:0.01:0.9];
6 subplot (311)
7 fplot2d (b , f1 ,[1])
8 xgrid (2)
9 xtitle ([ N o r m a l i z e d bandwidth v s Damping F a c t o r ] ,
Damping r a t i o , N o r m a l i z e d bandwidth ) ;
10
11 // 2 Peak o v e r s h o o t v s R e s o n a n c e Peak ( s e c o n d
order system )
12 deff ( [ C]= f 2 ( b ) ,C=exp (( %pi b ) / s q r t (1b 2 ) ) )
13 deff ( [ D]= f 3 ( b ) ,D=1/(2 b s q r t (1b 2 ) ) )

11
14 b =[0.05:0.01:0.9];
15 subplot (312)
16 xset ( l i n e s t y l e ,4) ;
17 fplot2d (b , f2 ,[1])
18 xset ( l i n e s t y l e ,1) ;
19 fplot2d (b , f3 ,[1])
20 xgrid (3)
21 xtitle ([ Peak o v e r s h o o t
v s R e s o n a n c e Peak ] ,
Damping r a t i o , Peak Gain , R e s o n a n c e Gain ) ;
22 legends ([ Peak Gain ; R e s o n a n c e Gain
] ,[[1;4] ,[1;1]] , opt =1) ;
23
24 // 3 R e s o n a n t F r e q u e n c y v s Damping F r e q u e n c y (
Second o r d e r system )
25 deff ( [ e ]= f 4 ( b ) , e=s q r t (1 2 b 2 ) / s q r t (1b 2 ) )
26 b =[0:0.01:0.9]; // don t end w i t h 1 bec , d i v i s i o n by
0 error
27 subplot (313)
28 fplot2d (b , f4 ,[1])
29 xgrid (4)
30 xtitle ([ R e s o n a n t F r e q u e n c y v s Damping F r e q u e n c y ] ,
Damping r a t i o , R e s o n a n t F r e q u e n c y ) ;

12
Figure 3.2: exp4

13

You might also like