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

Advanced Control System Notes

The document is a Scilab code that demonstrates plotting the phase portraits of linear systems with stable and unstable nodes, and stable and unstable foci. It contains code to define transfer functions, convert them to state space form, and simulate trajectories starting from a grid of initial conditions to obtain the phase portraits. Plots are generated of the pole-zero maps and phase portraits for each example system. Captions and labels are added to the plots.

Uploaded by

Brijesh B Naik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
213 views

Advanced Control System Notes

The document is a Scilab code that demonstrates plotting the phase portraits of linear systems with stable and unstable nodes, and stable and unstable foci. It contains code to define transfer functions, convert them to state space form, and simulate trajectories starting from a grid of initial conditions to obtain the phase portraits. Plots are generated of the pole-zero maps and phase portraits for each example system. Captions and labels are added to the plots.

Uploaded by

Brijesh B Naik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Scilab Manual for

Advanced Control Systems


by Prof Deepti Khimani
Instrumentation Engineering
VESIT1

Solutions provided by
Prof Mrs. Deepti Khimani
Instrumentation Engineering
Mumbai University/V. E. S. Institute of Technology

December 28, 2018

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 4

1 To plot the phase portrait of systems having stable and


unstable nodes. 6

2 To plot the phase portrait of systems having stable and


unstable focus. 11

3 To plot the phase portrait of systems having vortex point. 15

4 To plot the phase portrait of systems having saddle point. 19

5 To demonstrate limit cycles for vander pol’s equation. 23

6 To demonstrate the effect of the static nonlinearities. 25

7 To demonstrate the stability of the system using Describing


function. 27

8 To demonstrate the stability of the system using Lyapunov


equation. 30

9 Stabilization of double integrator system using variable struc-


ture control. 32

10 Design the exact feedback linearizing controller for the non


linear system. 34

11 To design sliding mode controller for a linear system. 36

2
12 To demonstrate model reference adaptive control system. 38

3
List of Experiments

Solution 1.01 Lab01 . . . . . . . . . . . . . . . . . . . . . . . . 6


Solution 2.1 Lab02 . . . . . . . . . . . . . . . . . . . . . . . . 11
Solution 3.01 Lab03 . . . . . . . . . . . . . . . . . . . . . . . . 15
Solution 4.01 Lab04 . . . . . . . . . . . . . . . . . . . . . . . . 19
Solution 7.01 Lab07 . . . . . . . . . . . . . . . . . . . . . . . . 27
Solution 8.01 Lab08 . . . . . . . . . . . . . . . . . . . . . . . . 30

4
List of Figures

1.1 Lab01 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2 Lab01 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.1 Lab02 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2 Lab02 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3.1 Lab03 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 Lab03 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.1 Lab04 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 Lab04 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

5.1 Lab05 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

6.1 Lab06 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.2 Lab06 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

7.1 Lab07 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

9.1 Lab09 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

10.1 Lab10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

11.1 Lab11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
11.2 Lab11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

12.1 Lab12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

5
Experiment: 1

To plot the phase portrait of


systems having stable and
unstable nodes.

Scilab code Solution 1.01 Lab01

1 // Lab . 0 1 : To p l o t t h e p h a s e p o r t r a i t o f s y s t e m s
h a v i n g s t a b l e and u n s t a b l e n o d e s .
2
3 // s c i l a b − 5 . 5 . 0
4 // O p e r a t i n g System : Windows 7 , 32− b i t
5
6 clc ;
7 clear all ;
8 clf ;
9
10 // System t r a n s f e r f u n c t i o n
11 s = poly (0 , ’ s ’ ) ;
12 g =1/( s ^2+3* s +2) ;
13
14 // Draw p o l e z e r o map o f t h e s y s t e m
15 plzr ( g ) ;
16 title ( ’ P o l e −z e r o map o f t h e s y s t e m w i t h r e a l s t a b l e

6
e i g e n v a l u e s ’ , ’ f o n t s i z e ’ ,3)
17 // C o n v e r t t h e g i v e n t r a n s f e r f u n c t i o n i n t o s t a t e
s p a c e form
18 sys = tf2ss ( g ) ;
19
20 // P l o t o f s y s t e m p h a s e t r a j e c t o r y
21 sys . c =[1 ,0;0 ,1];
22 sys . d =[0 0] ’;
23
24 t =0:0.2:10;
25 a1 = size ( t ) ;
26 u = zeros ( a1 (1) , a1 (2) ) ;
27 figure
28 for i = -2.0:0.5:2;
29 for j = -2:0.5:2;
30 y1 = csim (u ,t , sys ,[ i , j ] ’) ;
31 plot ( y1 (1 ,:) , y1 (2 ,:) ) ;
32 end
33 end
34
35 set ( gca () ,” g r i d ” ,[0.3 0.3])
36 title ( ’ Phase p o r t r a i t o f t h e s y s t e m w i t h s t a b l e node
’ , ’ f o n t s i z e ’ ,3)
37 xlabel ( ’ x1 ( t ) ’ , ’ f o n t s i z e ’ ,2)
38 ylabel ( ’ x2 ( t ) ’ , ’ f o n t s i z e ’ ,2)
39 f = get ( ” c u r r e n t f i g u r e ” ) // C u r r e n t f i g u r e h a n d l e
40 f . background =8
41 // System t r a n s f e r f u n c t i o n
42 s = poly (0 , ’ s ’ ) ;
43 g =1/( s ^2 -3* s +2) ;
44
45 // Draw p o l e z e r o map o f t h e s y s t e m
46 figure ;
47 plzr ( g ) ;
48 title ( ’ P o l e −z e r o map o f t h e s y s t e m w i t h r e a l
u n s t a b l e e i g e n v a l u e s ’ , ’ f o n t s i z e ’ ,3)
49 f = get ( ” c u r r e n t f i g u r e ” ) // C u r r e n t f i g u r e h a n d l e
50 f . background =8

7
51 // C o n v e r t t h e g i v e n t r a n s f e r f u n c t i o n i n t o s t a t e
s p a c e form
52 sys = tf2ss ( g ) ;
53
54 // P l o t o f s y s t e m p h a s e t r a j e c t o r y
55 sys . c =[1 ,0;0 ,1];
56 sys . d =[0 0] ’;
57
58 a1 = size ( t ) ;
59 u = zeros ( a1 (1) , a1 (2) ) ;
60 figure
61 for i = -2.0:0.5:2;
62 for j = -2:0.5:2;
63 y1 = csim (u ,t , sys ,[ i , j ] ’) ;
64 plot ( y1 (1 ,:) , y1 (2 ,:) ) ;
65 end
66 end
67 set ( gca () ,” g r i d ” ,[0.3 0.3])
68 f = get ( ” c u r r e n t f i g u r e ” ) // C u r r e n t f i g u r e h a n d l e
69 f . background =8
70 zoom_rect ([ -5 , -5 ,5 ,5])
71 title ( ’ Phase p o r t r a i t o f t h e s y s t e m w i t h u n s t a b l e
node ’ , ’ f o n t s i z e ’ ,3)
72 xlabel ( ’ x1 ( t ) ’ , ’ f o n t s i z e ’ ,2)
73 ylabel ( ’ x2 ( t ) ’ , ’ f o n t s i z e ’ ,2)

8
Figure 1.1: Lab01

9
Figure 1.2: Lab01

10
Experiment: 2

To plot the phase portrait of


systems having stable and
unstable focus.

Scilab code Solution 2.1 Lab02

1 // Lab . 0 2 : To p l o t t h e p h a s e p o r t r a i t o f s y s t e m s
h a v i n g s t a b l e and u n s t a b l e f o c u s p o i n t .
2
3 // s c i l a b − 5 . 5 . 0
4 // O p e r a t i n g System : Windows 7 , 32− b i t
5
6 clc ;
7 clear all ;
8 clf ;
9
10 // System t r a n s f e r f u n c t i o n
11 s = poly (0 , ’ s ’ ) ;
12 g =1/( s ^2+ s +1) ;
13
14 // Draw p o l e z e r o map o f t h e s y s t e m
15 plzr ( g ) ;
16 title ( ’ P o l e −z e r o map o f t h e s y s t e m w i t h s t a b l e

11
underdamped e i g e n v a l u e s ’ , ’ f o n t s i z e ’ ,3)
17 // C o n v e r t t h e g i v e n t r a n s f e r f u n c t i o n i n t o s t a t e
s p a c e form
18 sys = tf2ss ( g ) ;
19
20 // P l o t o f s y s t e m p h a s e t r a j e c t o r y
21 sys . c =[1 ,0;0 ,1];
22 sys . d =[0 0] ’;
23
24 t =0:0.2:10;
25 a1 = size ( t ) ;
26 u = zeros ( a1 (1) , a1 (2) ) ;
27 figure
28 for i = -2.0:0.5:2;
29 for j = -2:0.5:2;
30 y1 = csim (u ,t , sys ,[ i , j ] ’) ;
31 plot ( y1 (1 ,:) , y1 (2 ,:) ) ;
32 end
33 end
34 set ( gca () ,” g r i d ” ,[0.3 0.3])
35 f = get ( ” c u r r e n t f i g u r e ” ) // C u r r e n t f i g u r e h a n d l e
36 f . background =8
37 title ( ’ Phase p o r t r a i t o f t h e s y s t e m w i t h s t a b l e
f o c u s ’ , ’ f o n t s i z e ’ ,3)
38 xlabel ( ’ x1 ( t ) ’ , ’ f o n t s i z e ’ ,2)
39 ylabel ( ’ x2 ( t ) ’ , ’ f o n t s i z e ’ ,2)
40
41 // System t r a n s f e r f u n c t i o n
42 s = poly (0 , ’ s ’ ) ;
43 g =1/( s ^2 - s +1) ;
44
45 // C o n v e r t t h e g i v e n t r a n s f e r function into state
s p a c e form
46 sys = tf2ss ( g ) ;
47
48 // Draw p o l e z e r o map o f t h e s y s t e m
49 figure ;
50 plzr ( g ) ;

12
51 f = get ( ” c u r r e n t f i g u r e ” ) // C u r r e n t f i g u r e h a n d l e
52 f . background =8
53 title ( ’ P o l e −z e r o map o f t h e s y s t e m w i t h n e g a t i v e l y
damped e i g e n v a l u e s ’ , ’ f o n t s i z e ’ ,3)
54 // P l o t o f s y s t e m p h a s e t r a j e c t o r y
55 sys . c =[1 ,0;0 ,1];
56 sys . d =[0 0] ’;
57
58 a1 = size ( t ) ;
59 u = zeros ( a1 (1) , a1 (2) ) ;
60 figure
61 for i = -2.0:0.5:2;
62 for j = -2:0.5:2;
63 y1 = csim (u ,t , sys ,[ i , j ] ’) ;
64 plot ( y1 (1 ,:) , y1 (2 ,:) ) ;
65 end
66 end
67 set ( gca () ,” g r i d ” ,[0.3 0.3])
68 f = get ( ” c u r r e n t f i g u r e ” ) // C u r r e n t f i g u r e h a n d l e
69 f . background =8
70 zoom_rect ([ -5 , -5 ,5 ,5])
71 title ( ’ Phase p o r t r a i t o f t h e s y s t e m w i t h u n s t a b l e
f o c u s ’ , ’ f o n t s i z e ’ ,3)
72 xlabel ( ’ x1 ( t ) ’ , ’ f o n t s i z e ’ ,2)
73 ylabel ( ’ x2 ( t ) ’ , ’ f o n t s i z e ’ ,2)

13
Figure 2.1: Lab02

Figure 2.2: Lab02

14
Experiment: 3

To plot the phase portrait of


systems having vortex point.

Scilab code Solution 3.01 Lab03

1 // Lab . 0 3 : To p l o t t h e p h a s e p o r t r a i t o f s y s t e m s
having vortex point .
2
3 // s c i l a b − 5 . 5 . 0
4 // O p e r a t i n g System : Windows 7 , 32− b i t
5
6 clc ;
7 clear all ;
8 clf ;
9
10 // System t r a n s f e r f u n c t i o n
11 s = poly (0 , ’ s ’ ) ;
12 g =1/( s ^2+4) ;
13
14 // Draw p o l e z e r o map o f t h e s y s t e m
15 plzr ( g ) ;
16 title ( ’ P o l e −z e r o map o f t h e s y s t e m w i t h c r i t i c a l l y
damped e i g e n v a l u e s ’ , ’ f o n t s i z e ’ ,3)
17 // C o n v e r t t h e g i v e n t r a n s f e r f u n c t i o n i n t o s t a t e

15
s p a c e form
18 sys = tf2ss ( g ) ;
19
20 // P l o t o f s y s t e m p h a s e t r a j e c t o r y
21 sys . c =[1 ,0;0 ,1];
22 sys . d =[0 0] ’;
23
24 t =0:0.2:10;
25 a1 = size ( t ) ;
26 u = zeros ( a1 (1) , a1 (2) ) ;
27 figure
28 for i = -2.0:0.5:2;
29 for j = -2:0.5:2;
30 y1 = csim (u ,t , sys ,[ i , j ] ’) ;
31 plot ( y1 (1 ,:) , y1 (2 ,:) ) ;
32 end
33 end
34 set ( gca () ,” g r i d ” ,[0.3 0.3])
35 f = get ( ” c u r r e n t f i g u r e ” ) // C u r r e n t f i g u r e h a n d l e
36 f . background =8
37 title ( ’ Phase p o r t r a i t o f t h e s y s t e m w i t h v o r t e x
p o i n t ’ , ’ f o n t s i z e ’ ,3)
38 xlabel ( ’ x1 ( t ) ’ , ’ f o n t s i z e ’ ,2)
39 ylabel ( ’ x2 ( t ) ’ , ’ f o n t s i z e ’ ,2)

16
Figure 3.1: Lab03

17
Figure 3.2: Lab03

18
Experiment: 4

To plot the phase portrait of


systems having saddle point.

Scilab code Solution 4.01 Lab04

1 // Lab . 0 4 : To p l o t t h e Phase p o r t r a i t o f s y s t e m s
having saddle point .
2
3 // s c i l a b − 5 . 5 . 0
4 // O p e r a t i n g System : Windows 7 , 32− b i t
5
6 clc ;
7 clear all ;
8 clf ;
9
10 // System t r a n s f e r f u n c t i o n
11 s = poly (0 , ’ s ’ ) ;
12 g =1/( s ^2+1* s -2) ;
13
14 // C o n v e r t t h e g i v e n t r a n s f e r f u n c t i o n i n t o s t a t e
s p a c e form
15 sys = tf2ss ( g ) ;
16
17 // Draw p o l e z e r o map o f t h e s y s t e m

19
18 plzr ( sys ) ;
19 title ( ’ P o l e −z e r o map o f t h e s y s t e m w i t h r e a l s t a b l e
and u n s t a b l e e i g e n v a l u e s ’ , ’ f o n t s i z e ’ ,3)
20 // P l o t o f s y s t e m p h a s e t r a j e c t o r y
21 sys . c =[1 ,0;0 ,1];
22 sys . d =[0 0] ’;
23
24 t =0:0.2:5;
25 a1 = size ( t ) ;
26 u = zeros ( a1 (1) , a1 (2) ) ;
27 figure ;
28 for i = -2.0:0.5:2;
29 for j = -2:0.5:2;
30 y1 = csim (u ,t , sys ,[ i , j ] ’) ;
31 plot ( y1 (1 ,:) , y1 (2 ,:) ) ;
32 end
33 end
34 set ( gca () ,” g r i d ” ,[0.3 0.3])
35 f = get ( ” c u r r e n t f i g u r e ” ) // C u r r e n t f i g u r e h a n d l e
36 f . background =8
37 zoom_rect ([ -3 , -3 ,3 ,3])
38 title ( ’ Phase p o r t r a i t o f t h e s y s t e m w i t h s a d d l e
p o i n t ’ , ’ f o n t s i z e ’ ,3)
39 xlabel ( ’ x1 ( t ) ’ , ’ f o n t s i z e ’ ,2)
40 ylabel ( ’ x2 ( t ) ’ , ’ f o n t s i z e ’ ,2)

20
Figure 4.1: Lab04

21
Figure 4.2: Lab04

22
Experiment: 5

To demonstrate limit cycles for


vander pol’s equation.

This code can be downloaded from the website wwww.scilab.in

23
Figure 5.1: Lab05

24
Experiment: 6

To demonstrate the effect of


the static nonlinearities.

This code can be downloaded from the website wwww.scilab.in

25
Figure 6.1: Lab06

Figure 6.2: Lab06

26
Experiment: 7

To demonstrate the stability of


the system using Describing
function.

Scilab code Solution 7.01 Lab07

1 // Lab . 0 8 : To c h e c k t h e s t a b i l i t y o f t h e s y s t e m
using Describing Functions .
2
3 // s c i l a b − 5 . 5 . 0
4 // O p e r a t i n g System : Windows 7 , 32− b i t
5
6 clc ;
7 clear all ;
8
9 // F r e q u e n c y Bounds
10
11 wmin =1;
12 wmax =100;
13 fmin = wmin /2/ %pi ;
14 fmax = wmax /2/ %pi ;
15
16 // System Model

27
17
18 s = poly (0 , ’ s ’ ) ;
19 g1 = syslin ( ’ c ’ ,10/(0.5* s ^3+1.5* s ^2+ s ) )
20
21 // N y q u i s t P l o t
22
23 nyquist ( g1 , fmin , fmax )
24
25
26 // P l o t o f D e s c r i b i n g F u n c t i o n o f R e l a y w i t h
Deadzone N o n l i n e a r i t y
27 x =1:0.5:10;
28 n =(2/ %pi ) *( asin (1 ./ x ) +(1 ./ x ) .* sqrt (1 -(1 ./ x )
.^2) ) ;
29 n1 = -1 ./ n ;
30 z = size ( n1 ) ;
31 plot2d ( n1 , zeros (1 , z (2) ) ,2)
32
33 h = legend ([ ’DF Contour ’ ; ’ System Contour ’ ])

28
Figure 7.1: Lab07

29
Experiment: 8

To demonstrate the stability of


the system using Lyapunov
equation.

Scilab code Solution 8.01 Lab08

1 // Lab . 0 8 : To c h e c k t h e s t a b i l i t y o f t h e s y s t e m
u s i n g Lyapunov e q u a t i o n .
2
3 // s c i l a b − 5 . 5 . 0
4 // O p e r a t i n g System : Windows 7 , 32− b i t
5
6 clc ;
7 clear all ;
8
9 // System model
10
11 a =[0 1 0;0 0 1; -2 -3 -2];
12 q = - eye (3 ,3) ;
13 p = lyap (a ,q , ’ c ’ ) ;
14
15 // For a s t a b l e s y s t e m m a t r i x p s h o u l d be p o s i t i v e
definite for

30
16 // which a l l t h e p r i n c i p l e m i n o r s o r a l l e i g e n v a l u e s
o f t h e m a t r i x p s h o u l d be p o s i t i v e
17 eig_val = spec ( p ) ;
18 m = length ( eig_val ) ;
19 stable =0;
20 for i =1: m ;
21 if real ( eig_val ( i ) ) >0 then
22 stable = stable +1;
23 end
24 end
25 if stable == m then
26 disp ( ’ The s y s t e m i s a s y m p t o t i c a l l y s t a b l e ’ )
27 else
28 disp ( ’ The s y s t e m i s u n s t a b l e o r c r i t i c a l l y
stable ’)
29 end

31
Experiment: 9

Stabilization of double
integrator system using
variable structure control.

This code can be downloaded from the website wwww.scilab.in

32
Figure 9.1: Lab09

33
Experiment: 10

Design the exact feedback


linearizing controller for the
non linear system.

This code can be downloaded from the website wwww.scilab.in

34
Figure 10.1: Lab10

35
Experiment: 11

To design sliding mode


controller for a linear system.

This code can be downloaded from the website wwww.scilab.in

36
Figure 11.1: Lab11

Figure 11.2: Lab11

37
Experiment: 12

To demonstrate model
reference adaptive control
system.

This code can be downloaded from the website wwww.scilab.in

38
Figure 12.1: Lab12

39

You might also like