Scilab Code for Control Systems Theory and Applications by Smarajit Ghosh 1 Created by Anuradha Singhania 4th Year Student B. Tech. (Elec. & Commun. ) Sri Mata Vaishno Devi University, Jammu College Teacher Prof. Amit Kumar Garg Sri Mata Vaishno Devi University, Jammu Reviewer Prof. Madhu Belur, IIT Bombay 29 June 2010 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 www.scilab.in
124
Embed
Scilab Code for Control Systems Theory and Applications by Smarajit Ghosh · 2015-09-15 · Scilab Code for Control Systems Theory and Applications by Smarajit Ghosh1 Created by Anuradha
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Scilab Code forControl Systems
Theory and Applicationsby Smarajit Ghosh1
Created byAnuradha Singhania
4th Year StudentB. Tech. (Elec. & Commun. )
Sri Mata Vaishno Devi University, Jammu
College TeacherProf. Amit Kumar Garg
Sri Mata Vaishno Devi University, JammuReviewer
Prof. Madhu Belur, IIT Bombay
29 June 2010
1Funded by a grant from the National Mission on Education through ICT,http://spoken-tutorial.org/NMEICT-Intro. This Textbook companion and scilabcodes written in it can be downloaded from www.scilab.in
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox.
2.1 Scilab Code
Example 2.01-01 2.01.01.sci
1 syms t s ;2 y=l ap l a c e ( ’ 13 ’ , t , s ) ;3 disp (y , ”ans=” )
Example 2.01-02 2.01.02sci
1 syms t s ;2 y=l ap l a c e ( ’ 4+5∗%eˆ(−3∗ t ) ’ , t , s ) ;3 disp (y , ”ans=” )
Example 2.01-03 2.01.03.sci
1 syms t s ;2 y=l ap l a c e ( ’ 2∗ t−3∗%eˆ(− t ) ’ , t , s ) ;3 disp (y , ”ans=” )
11
Example 2.03 2.03.sci
1 p=poly ( [ 9 1 ] , ’ s ’ , ’ c o e f f ’ )2 q=poly ( [ 3 7 1 ] , ’ s ’ , ’ c o e f f ’ )3 f=p/q ;4 disp ( f , ”F( s )=” )5 x=s∗ f ;6 y=l im i t (x , s , 0 ) ; / / f i n a l v a l u e t h e o r e m
7 disp (y , ” f ( i n f )=” )8 z=l im i t (x , s , %inf ) ; / / i n i t i a l v a l u e t h e o r e m
9 disp ( z , ” f (0 )=” )
Example 2.04 2.04.sci
1 s=%s2 syms t ;3 disp ( ( s+3) /( ( s+1)∗( s+2)∗( s+4) ) , ”F( s )=” )4 [A]=pfss ( ( s+3) /( ( s+1)∗( s+2)∗( s+4) ) ) / / p a r t i a l f r a c t i o n
o f F ( s )
5 F1= i l a p l a c e (A(1) , s , t )6 F2= i l a p l a c e (A(2) , s , t )7 F3= i l a p l a c e (A(3) , s , t )8 F=F1+F2+F3 ;9 disp (F , ” f ( t )=” )
Example 2.05-01 2.05.01.sci
1 syms t s ;2 y= l ap l a c e ( ’%eˆ(− t )+5∗t+6∗%eˆ(−3∗ t ) ’ , t , s ) ;3 disp (y , ”ans=” )
Example 2.05-02 2.05.02.sci
1 syms t s ;2 y=l ap l a c e ( ’ 5+6∗ t ˆ2+3∗%eˆ(−2∗ t ) ’ , t , s ) ;3 disp (y , ”ans=” )
12
Example 2.06 2.06.sci
1 syms t s ;2 y=l ap l a c e ( ’3− %eˆ(−3∗ t ) ’ , t , s ) ;3 disp (y , ”ans=” )
Example 2.11 2.11.sci
1 p=poly ( [ 0 . 3 8 ] , ’ s ’ , ’ c o e f f ’ ) ;2 q=poly ( [ 0 0 .543 2 .48 1 ] , ’ s ’ , ’ c o e f f ’ ) ;3 F=p/q ;4
5 syms s ;6 x=s∗F;7 y=l im i t (x , s , 0 ) ; / / f i n a l v a l u e t h e o r e m
8 y=dbl ( y ) ;9 disp (y , ” f ( i n f )=” )
10 z=l im i t (x , s , %inf ) / / / / i n i t i a l v a l u e t h e o r e m
11 z=dbl ( z ) ;12 disp ( z , ” f (0 )=” )
Example 2.13 2.13.sci
1 s=%s ;2 p=poly ( [ 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;3 q=poly ( [ 0 −1 −1 −2] , ’ s ’ , ’ r o o t s ’ ) ;4 f=p/q ;5 syms t s ;6 y=i l a p l a c e ( f , s , t ) ;7 disp (y , ” f ( t )=” )
13
Chapter 3
Transfer Function
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox.
3.1 Scilab Code
Example 3.02 3.02.sci
1 syms t s ;2 f=%eˆ(−3∗ t ) ;3 y=l ap l a c e ( ’%eˆ(−3∗ t ) ’ , t , s ) ;4 disp (y , ”G( s )=” )
Example 3.03 3.03.sci
1 syms t s ;2 disp (%eˆ(−3∗ t ) , ”g ( t )=” ) ;3 y1=l ap l a c e ( ’%eˆ(−3∗ t ) ’ , t , s ) ;4 disp ( y1 , ”G( s )=” )5 disp (%eˆ(−4∗ t ) , ” r ( t )=” ) ;6 y2=l ap l a c e ( ’%eˆ(−4∗ t ) ’ , t , s ) ;7 disp ( y2 , ”R( s )=” )8 disp ( y1∗y2 , ”G( s )R( s )=” )
1 syms t s2 y=l ap l a c e (%eˆ(−3∗ t )∗ sin (2∗ t ) , t , s ) ;3 disp (y , ”ans=” )
Example 3.16 3.16.sci
1 syms t s ;2 x=6−4∗%eˆ(−5∗ t )/5+%eˆ(−3∗ t ) / / G i v e n s t e p R e s p o n s e o f
t h e s y s t e m
3 printf ( ” Der iva t i ve o f s tep response g i v e s impulsere sponse \n” )
4 y=d i f f (x , t ) ; / / D e r i v a t i v e o f s t e p r e s p o n s e
5 printf ( ”Laplace Transform o f Impulse Response g i v e s theTrans fe r Function \n ” )
6 p=l ap l a c e (y , t , s ) ;7 disp (p , ” Trans fe r Function=” )
Example 3.17 3.17.sci
1 printf ( ”Given : Poles are s=−1,(−2+ i ) ,(−2− i ) ; z e r o s s=−3+i ,−3− i , Gain f a c t o r ( k )=5 \n” )
2 num=poly([−3+%i,−3−%i ] , ’ s ’ , ’ r o o t s ’ ) ;3 den=poly([−1,−2+%i,−2−%i ] , ’ s ’ , ’ r o o t s ’ ) ;4 G=(5∗num)/den ;5 disp (G, ”G( s )=” )
Example 3.18 3.18.sci
1 s=%s ;2 G=sysl in ( ’ c ’ , ( 5∗ ( s+2) ) / ( ( s+3)∗( s+4) ) ) ;3 disp (G, ”G( s )=” )
15
4 x=denom(G) ;5 disp (x , ” Cha r a c t e r i s t i c s Polynomial=” )6 y=roots ( x ) ;7 disp (y , ” Poles o f a system=” )
Example 3.19 3.19.sci
1 printf ( ”Given : Poles are s=−3, Zeros are s=−2, GainFactor ( k )=5 \n ” )
2 num=poly ( [ −2 ] , ’ s ’ , ’ r o o t s ’ ) ;3 den=poly ( [ −3 ] , ’ s ’ , ’ r o o t s ’ ) ;4 G=5∗num/den ;5 disp (G, ”G( s )=” )6 disp ( ” Input i s Step Function ” )7 syms t s ;8 R=lap l a c e (1 , t , s ) ;9 disp (R, ”R( s )=” )
10 printf ( ”C( s )=R( s )G( s ) \n” )11 C=R∗G;12 disp (C, ”C( s )=” )13 c=i l a p l a c e (C, s , t ) ;14 disp ( c , ”c ( t )=” )
Example 3.23 3.23.sci
1 / / p o l e z e r o p l o t f o r g ( s ) = ( s ˆ 2 + 3 s + 2 ) / ( s ˆ 2 + 7 s + 1 2 )
2 s=%s ;3 p=poly ( [ 2 3 1 ] , ’ s ’ , ” c o e f f ” )4 q=poly ( [ 1 2 7 1 ] , ’ s ’ , ” c o e f f ” )5 V=sysl in ( ’ c ’ ,p , q )6 plzr (V)7 syms s t ;8 v =i l a p l a c e ( ’ (2+(3∗ s )+s ˆ2) /( s ˆ2+(7∗ s )+12) ’ , s , t )9 disp (v , ”V( t ) = ’)
16
Chapter 4
Control system Components
4.1 Scilab Code
Example 4.01 4.01.sci
1 printf ( ”Given a ) Exc i ta t i on vo l tage ( Ein )=2V \n b)Se t t i ng Ratio ( a )= 0 .4 \n” )
2 Ein=2;3 disp ( Ein , ”Ein=” )4 a=0.4 ;5 disp ( a , ”a=” )6 Rt=10ˆ3;7 disp (Rt , ”Rt=” )8 Rl=5∗10ˆ3;9 disp (Rl , ”Rl=” )
10 printf ( ”Eo = ( a∗Ein ) /(1+(a∗(1−a )∗Rt) /Rl ) \n” )11 Eo = (a∗Ein ) /(1+(a∗(1−a )∗Rt) /Rl ) ;12 disp (Eo , ” output vo l tage (E0)=” )13 printf ( ”e=((a ˆ2)∗(1−a ) ) / ( ( a∗(1−a ) )+(Rl/Rt) ) \n” )14 e=((a ˆ2)∗(1−a ) ) / ( ( a∗(1−a ) )+(Rl/Rt) ) ;15 disp ( e , ” l oad ing e r r o r=” )16 printf ( ”E=Ein∗e \n” )17 E=Ein∗e ; / / V o l t a g e e r r o r = E x c i t a t i o n v o l t a g e ( E i n ) ∗
L o a d i n g e r r o r ( e )
18 disp (E, ”Voltage e r r o r=” )
17
Example 4.02 4.02.sci
1 printf ( ”n=5 , He l i c a l turn \n” )2 n=5; / / H e l i c a l t u r n
3 disp (n , ”n=” )4 printf ( ”N=9000 ,Winding Turn \n” )5 N=9000; / / W i n d i n g T u r n
6 disp (N, ”N=” )7 printf ( ”R=10000 , Potent iometer Res i s tance \n” )8 R=10000; / / P o t e n t i o m e t e r R e s i s t a n c e
9 disp (R, ”R=” )10 printf ( ”Ein=90 , Input vo l tage \n” )11 Ein=90; / / I n p u t v o l t a g e
12 disp ( Ein , ”Ein=” )13 printf ( ” r=5050 , Res i s tance at mid po int \n” )14 r =5050; / / R e s i s t a n c e a t m i d p o i n t
15 disp ( r , ” r=” )16 printf ( ”D=r−5000 , Deviat ion from nominal at mid−point \
n” )17 D=r−5000; / / D e v i a t i o n f r o m n o m i n a l a t m i d − p o i n t
18 disp (D, ”D=” )19 printf ( ”L=D/R∗100 , L in ea r i t y \n” )20 L=D/R∗100 ; / / L i n e a r i t y
21 disp (L , ”L=” )22 printf ( ”R=Ein/N , Reso lut ion \n” )23 R=Ein/N; / / R e s o l u t i o n
24 disp (R, ”R=” )25 printf ( ”Kp=Ein /(2∗ pi ∗n) , Potent iometer Constant \n” )26 Kp=Ein /(2∗%pi∗n) ; / / P o t e n t i o m e t e r C o n s t a n t
27 disp (Kp, ”Kp=” )
Example 4.03 4.03.sci
1 printf ( ” s i n c e S2 i s the r e f e r an c e s t a t o r winding , Es2=KVcos0 \n where Es2 & Er are rms vo l t ag e s \n ’ )
2 k=13 Theta=60;4 di sp (Theta , ”Theta=” )
18
5 V=28;6 di sp (V, ”V( app l i ed )=” )7 p r i n t f ( ”Es2=V∗cos ( Theta ) \n” )8 Es2=k∗V∗ cos ( Theta ∗(%pi/180) ) ;9 di sp (Es2 , ”Es2=” )
10 p r i n t f ( ”Es1=k∗V∗cos (Theta−120)\n” )11 Es1=k∗V∗ cos ( ( Theta−120)∗(%pi/180) ) ; // Given Theta=60
in degree s12 di sp (Es1 , ”Es1=’ )13 p r i n t f (”Es3=k∗V∗ cos ( Theta+120) \n”)14 Es3=k∗V∗ cos ( ( Theta+120) ∗(%pi/180) ) ;15 di sp (Es3 , ” Es3=’ )16 printf ( ”Es31=sq r t (3 ) ∗k∗Er∗ s i n ( Theta ) ” )17 Es31=sqrt (3 ) ∗k∗V∗ sin ( Theta ∗(%pi/180) ) ;18 disp (Es31 , ”Es31= ’)19 p r i n t f ( ”Es12=sqrt (3 ) ∗k∗Er∗ sin ( ( Theta−120)” )20 Es12=sq r t (3 ) ∗k∗V∗ s i n ( ( Theta−120)∗(%pi/180) ) ;21 di sp (Es12 , ”Es12=’ )22 p r i n t f (” Es23=sq r t (3 ) ∗k∗Er∗ s i n ( ( Theta+120) ”)23 Es23=sq r t (3 ) ∗k∗V∗ s i n ( ( Theta+120) ∗(%pi/180) ) ;24 di sp (Es23 , ” Es23=’ )
Example 4.04 4.04.sci
1 printf ( ” S e n s i t i v i t y=5v/1000rpm \n” )2 Vg=5;3 disp (Vg , ”Vg=” )4 printf ( ”w( in rad ians / sec ) =(1000/60) ∗2∗ pi \n” )5 w=(1000/60) ∗2∗%pi ;6 disp (w, ”w=” )7 printf ( ”Kt=Vg/w \n ’ )8 Kt=Vg/w;9 di sp (Kt , ”Gain constant (Kt)=” )
Example 4.05 4.05.sci
1 printf ( ”Torque=KmVm=2 \n” )2 t=2;
19
3 disp ( t , ”Torque ( t )=” )4 Fm=0.2;5 disp (Fm, ” Co e f f i c i e n t o f Viscous f r i c t i o n (Fm)=” )6 N=47 I =0.28 F1=0.059 printf ( ”Wnl=t /Fm” )
10 Wnl=t /Fm;11 disp (Wnl , ”No Load Speed (Wnl)=” )12 printf ( ”Fwt=I+(Nˆ2∗F1) \n” )13 Fwt=I+(Nˆ2∗F1) ;14 disp (Fwt , ”Total Viscous F r i c t i on (Fwt)=” )15 printf ( ”Te=t−(Fwt∗w) \n” )16 Te=0.8 / / l o a d
17 w=(t−Te) /Fwt ;18 disp (w, ”Speed o f Motor (w)=” )
20
Chapter 6
Control system Components
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox.
To Run the following codes use the same destination for the function aswell as the main code.
6.1 Scilab Code
Example F1 parallel.sce
1 function [ y]= p a r a l l e l ( sys1 , sys2 )2 y=sys1+sys23 endfunction
Example F2 serial.sce
1 function [ y]= s e r i e s ( sys1 , sys2 )2 y=sys1 ∗ sys23
4 endfunction
Example 6.01 6.01.sci
1 exec s e r i e s . s c e ;2 s=%s ;
21
3 sys1=sysl in ( ’ c ’ , ( s+3)/( s+1) )4 sys2=sysl in ( ’ c ’ , 0 . 2 / ( s+2) )5 sys3=sysl in ( ’ c ’ ,50/( s+4) )6 sys4=sysl in ( ’ c ’ ,10/( s ) )7 a=s e r i e s ( sys1 , sys2 ) ;8 b=s e r i e s ( a , sys3 ) ;9 y=s e r i e s (b , sys4 ) ;
10 y=simp( y ) ;11 disp (y , ”C( s ) /R( s )=” )
This code requires S F1.
Example 6.02 6.02.sci
1 exec p a r a l l e l . s c e ;2 s=%s ;3 sys1=sysl in ( ’ c ’ ,1/ s )4 sys2=sysl in ( ’ c ’ , 2/( s+1) )5 sys3=sysl in ( ’ c ’ , 3/( s+3) )6 a=p a r a l l e l ( sys1 , sys2 ) ;7 y=p a r a l l e l ( a , sys3 ) ;8 y=simp( y ) ;9 disp (y , ”C( s ) /R( s )=” )
This code requires S F2.
Example 6.03 6.03.sci
1 exec s e r i e s . s c e ;2 s=%s ;3 sys1=sysl in ( ’ c ’ , 3/( s ∗( s+1) ) )4 sys2=sysl in ( ’ c ’ , s ˆ2/(3∗( s+1) ) )5 sys3=sysl in ( ’ c ’ , 6/( s ) )6 a=(−1)∗ sys3 ;7 b=s e r i e s ( sys1 , sys2 ) ;8 y=b/ . a / / f e e d b a c k o p e r a t i o n
9 y=simp( y )10 disp (y , ”C( s ) /R( s )=” )
22
Example 6.04 6.04.sci
1 exec p a r a l l e l . s c e ;2 syms G1 G2 G3 H;3 a=s e r i e s (G1,G2) ;4 b=p a r a l l e l ( a ,G3) ;5 y=b/ .H / / n e g a t i v e f e e d b a c k o p e r a t i o n
6 y=simple ( y )7 disp (y , ”C( s ) /R( s )=” )
Example 6.05 6.05.sci
1 exec s e r i e s . s c e ;2 syms G1 G2 H1 H2 s ;3 a=G1/ .H1 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
4 b=a / .H2 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
5 y=s e r i e s (b ,G2) ;6 y=simple ( y ) ;7 disp (y , ”C( s ) /R( s )=” )
Example 6.06 6.06.sci
1 exec p a r a l l e l . s c e ;2 exec s e r i e s . s c e ;3 syms G1 G2 G3 G4 G5 G6 H1 H2 ;4 a=p a r a l l e l (G3,G5) ;5 b=p a r a l l e l ( a,−G4) ;6 c=s e r i e s (G1,G2) ;7 d=c / .H1 ;8 e=s e r i e s (b , d) ;9 f=e / .H2 ;
10 y=s e r i e s ( f ,G6) ;11 y=simple ( y ) ;12 disp (y , ”C( s ) /R( s )=” )
Example 6.07 6.07.sci
23
1 exec s e r i e s . s c e ;2 syms G1 G2 G3 H1 H2 R X;3 / / p u t t i n g x = 0 , t h e n s o l v i n g t h e b l o c k
4 a=G3/ .H1 ;5 b=s e r i e s (G1,G2) ;6 c=s e r i e s ( a , b ) ;7 x1=c / .H2 ;8 C1=R∗x1 ;9 disp ( x1 , ”C1( s ) /R( s )=” )
10 / / p u t t i n g r =0 , t h e n s o l v i n g t h e b l o c k
11 d=s e r i e s (G1,G2) ;12 e=s e r i e s (d ,H2) ;13 f=G3/ .H1 ;14 x2=f / . e ;15 C2=X∗x2 ;16 disp ( x2 , ”C2( s ) /X( s )=” )17 / / r e s u l t a n t o u t p u t C= C1 + C2
1 exec p a r a l l e l . s c e ;2 exec s e r i e s . s c e ;3 syms G1 G2 G3 H1 H2 ;4 / / s h i f t t h e t a k e − o f f p o i n t a f t e r t h e b l o c k G2
5 a=G3/G2 ;6 b=p a r a l l e l ( a , 1 ) ;7 c=s e r i e s (G1,G2) ;8 d=c / .H1 / / n e g a t i v e f e e d b a c k o p e r a t i o n
9 e=s e r i e s (d , b) ;10 y=e / .H2 ;11 y=simple ( y ) ;12 disp (y , ”C( s ) /R( s )=” )
Example 6.09 6.09.sci
24
1 exec s e r i e s . s c e2 syms G1 G2 G3 H1 H2 H3 ;3 / / R e m o v e t h e f e e d b a c k l o o p h a v i n g f e e d b a c k p a t h
t r a n s f e r f u n c t i o n H2
4 a=G3/ .H2 ;5 / / I n t e r c h a n g e t h e s u m m e r . a s w e l l a s r e p l a c e t h e
c a s c a d e b l o c k b y i t s e q u i v a l e n t b l o c k
6 b=s e r i e s (G1,G2) ;7 c=b/ .H1 ; / / N e g a t i v e F e e d b a c k O p e r a t i o n
8 d=s e r i e s ( c , a ) ;9 y=d/ .H3 ; / / N e g a t i v e F e e d b a c k O p e r a t i o n
10 y=simple ( y ) ;11 disp (y , ”C( s ) /R( s )=” )
Example 6.10 6.10.sci
1 exec p a r a l l e l . s c e ;2 exec s e r i e s . s c e ;3 syms G1 G2 G3 G4 G5 H1 H2 ;4 a=G2/ .H1 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
5 b=s e r i e s (G1, a ) ;6 c=s e r i e s (b ,G3) ;7 d=p a r a l l e l ( c ,G4) ;8 e=s e r i e s (d ,G5) ;9 y=e / .H2 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
10 y=simple ( y ) ;11 disp (y , ”C( s ) /R( s )=” )
Example 6.11 6.11.sci
1 exec p a r a l l e l . s c e ;2 exec s e r i e s . s c e ;3 syms G1 G2 G3 G4 G5 G6 G7 H1 H2 H3 ;4 a=p a r a l l e l (G1,G2) ;5 b=p a r a l l e l ( a ,G3) ;6 / / s h i f t t h e t a k e o f f p o i n t t o t h e r i g h t o f t h e b l o c k G4
7 c=G4/ .H1 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
8 d=G5/G4 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
25
9 e=p a r a l l e l (d , 1 ) ;10 f=G6/ .H2 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
11 g=s e r i e s (b , c ) ;12 h=s e r i e s ( g , e ) ;13 i=s e r i e s (h , f ) ;14 j=s e r i e s ( i ,G7) ;15 y=j / .H3 ;16 y=simple ( y ) ;17 disp (y , ”C( s ) /R( s )=” )
Example 6.12 6.12.sci
1 exec s e r i e s . s c e ;2 exec p a r a l l e l . s c e ;3 syms G1 G2 G3 G4 H1 H2 H3 ;4 / / s h i f t t h e t a k e − o f f p o i n t a f t e r t h e b l o c k G1
5 a=G3/G1 ;6 b=p a r a l l e l ( a ,G2) ;7 c=G1/ .H1 ; / / N e g a t i v e F e e d b a c k O p e r a t i o n
8 d=1/b ; / / N e g a t i v e F e e d b a c k O p e r a t i o n
9 e=p a r a l l e l (d ,H3) ;10 f=s e r i e s ( e ,H2) ;11 g=s e r i e s ( c , b ) ;12 h=g / . f ; / / N e g a t i v e F e e d b a c k O p e r a t i o n
13 y=s e r i e s (h ,G4) ;14 y=simple ( y ) ;15 disp (y , ”C( s ) /R( s )=” )
Example 6.13 6.13.sci
1 exec s e r i e s . s c e ;2 exec p a r a l l e l . s c e ;3 syms G1 G2 G3 G4 H1 H2 ;4 / / r e d u c e t h e i n t e r n a l f e e d b a c k l o o p
5 a=G2/ .H2 ;6 / / p l a c e t h e s u m m e r l e f t t o t h e b l o c k G1
7 b=G3/G1 ;8 / / e x c h a n g e t h e s u m m e r
26
9 c=p a r a l l e l (b , 1 ) ;10 d=s e r i e s ( a ,G1) ;11 e=s e r i e s (d ,G4) ;12 f=e / .H1 ;13 y=s e r i e s ( c , f ) ;14 y=simple ( y ) ;15 disp (y , ”C( s ) /R( s )=” )
Example 6.14 6.14.sci
1 exec s e r i e s . s c e ;2 exec p a r a l l e l . s c e ;3 syms G1 G2 G3 G4 H1 H2 ;4 / / s h i f t t h e t a k e − o f f p o i n t t o t h e r i g h t o f t h e b l o c k G3
5 a=H1/G3 ;6 b=s e r i e s (G2,G3) ;7 c=p a r a l l e l (H2 , a ) ;8 d=b/ . c ;9 e=s e r i e s (d ,G1) ;
10 f=e / . a ;11 y=s e r i e s ( f ,G4) ;12 y=simple ( y ) ;13 disp (y , ”C( s ) /R( s )=” )
Example 6.15 6.15.sci
1 exec s e r i e s . s c e ;2 exec p a r a l l e l . s c e ;3 syms G1 G2 G3 G4 H1 H2 H3 ;4 / / s h i f t t h e t a k e − o f f p o i n t t o t h e r i g h t o f t h e b l o c k H1
5 / / s h i f t t h e o t h e r t a k e − o f f p o i n t t o t h e r i g h t o f t h e
b l o c k H1 &H2
6 a=s e r i e s (H1 ,H2) ;7 b=1/a ;8 c=1/H1 ;9 d=G3/ . a ;
10 / / m o v e t h e s u m m e r t o t h e l e f t o f t h e b l o c k G2
11 e=G4/G2 ;
27
12 f=s e r i e s (d ,G2) ;13 / / e x c h a n g e t h e s u m m e r
14 g=f / .H1 ;15 h=p a r a l l e l (G1, e ) ;16 i=s e r i e s (h , g ) ;17 j=s e r i e s ( a ,H3) ;18 y=i / . j ;19 y=simple ( y ) ;20 disp (y , ”C( s ) /R( s )=” )
28
Chapter 8
Time Domain Analysis ofControl Systems
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox
8.1 Scilab Code
Example 8.02 8.02.sci
1 s=%s ;2 p=poly ( [ 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;3 q=poly ( [ 0 1 0 .95 0 . 2 1 ] , ’ s ’ , ’ c o e f f ’ ) ;4 G=p/q ;5 disp (G, ”G( s )=” )6 H=1;7 y=G∗H; / / T y p e 1 S y s t e m
8 disp (y , ”G( s )H( s )=” )9 / / R e f e r i n g t h e t a b l e 8 . 2 g i v e n i n t h e b o o k , F o r t y p e 1
s y s t e m Kp= % i n f & Ka =0
10 printf ( ”For type1 Kp=i n f & Ka=0 \n” )11 syms s ;12 Kv=l im i t ( s∗y , s , 0 ) ; / / Kv= v e l o c i t y e r r o r c o e f f i c i e n t
13 disp (Kv, ” Ve loc i ty Error C o e f f i c i e n t (Kv)=” )
29
Example 8.03-01 8.03.01.sci
1 s=%s ;2 p=poly ( [ 1 0 ] , ’ s ’ , ’ c o e f f ’ ) ;3 q=poly ( [ 0 0 1 ] , ’ s ’ , ’ c o e f f ’ ) ;4 G=p/q ;5 H=0.7;6 y=G∗H; / / t y p e 2
7 disp (y , ”G( s )H( s )=” )8 / / r e f e r i n g t h e t a b l e 8 . 2 g i v e n i n t h e b o o k , f o r t y p e 1
Kp= % i n f & Kv= % i n f
9 printf ( ”For type1 Kp=i n f & Kv=i n f \n” )10 syms s ;11 Ka=l im i t ( s ˆ2∗y , s , 0 ) ; / / Ka= a c c e l a r a t i o n e r r o r
c o e f f i c i e n t
12 disp (Ka, ”Ka=” )
Example 8.03-02 8.03.02.sci
1 p=poly ( [ 5 ] , ’ s ’ , ’ c o e f f ’ ) ;2 q=poly ( [ 5 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;3 G=p/q4 H=0.65 y=G∗H / / t y p e 0
6 / / r e f e r i n g t h e t a b l e 8 . 2 g i v e n i n t h e b o o k , f o r t y p e 1
Ka =0 & Kv =0
7 syms s8 Kp=l im i t ( s∗y/s , s , 0 ) / / Kp= p o s i t i o n a l e r r o r c o e f f i c i e n t
Example 8.03-03 8.03.03.sci
1
2 p=poly ( [ 1 0 .13 0 . 4 ] , ’ s ’ , ’ c o e f f ’ ) ;3 q=poly ( [ 0 0 5 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;4 G=10∗p/q / / g a i n FACTOR = 1 0
5 H=0.86 y=G∗H / / t y p e 2
30
7 / / r e f e r i n g t h e t a b l e 8 . 2 g i v e n i n t h e b o o k , f o r t y p e 2
Kp= % i n f & Kv= % i n f
8 syms s9 Ka=l im i t ( s ˆ2∗y , s , 0 ) / / Ka= a c c e l a r a t i o n e r r o r c o e f f i c i e n t
Example 8.04 8.04.sci
1
2 p=poly ( [ 4 1 ] , ’ s ’ , ’ c o e f f ’ ) ;3 q=poly ( [ 0 0 6 5 1 ] , ’ s ’ , ’ c o e f f ’ ) ;4 syms K real ;5 y=K∗p/q / / g a i n FACTOR=K
6 disp (y , ”G( s )H( s )=” )7 / / G ( s ) H ( s ) = y , a n d i t i s o f t y p e 2
8 / / r e f e r i n g t h e t a b l e 8 . 2 g i v e n i n t h e b o o k , f o r t y p e 2
Kp= % i n f & Kv= % i n f
9 printf ( ”For type1 Kp=i n f & Kv=i n f \n” )10 syms A s t ;11 Ka=l im i t ( s ˆ2∗y , s , 0 ) ; / / Ka= a c c e l a r a t i o n e r r o r
c o e f f i c i e n t
12 disp (Ka, ”Ka=” )13 / / g i v e n i n p u t i s r ( t ) =A ( t ˆ 2 ) / 2 & R ( s ) = l a p l a c e ( r ( t ) )
14 printf ( ”Given r ( t )=A( t ˆ2) /2 \n” )15 R=lap l a c e ( ’A∗ t ˆ2/2 ’ , t , s ) ;16 disp (R, ”R( s )=” )17 / / s t e a d y s t a t e e r r o r = L t s −>0 s R ( S ) / 1 + G ( s ) H ( S )
18 e=l im i t ( s∗R/(1+y) , s , 0 )19 disp ( e , ”Ess=” )
Example 8.05 8.05.sci
1 p=poly ( [ 6 0 ] , ’ s ’ , ’ c o e f f ’ ) ;2 q=poly ( [ 1 2 7 1 ] , ’ s ’ , ’ c o e f f ’ ) ;3 G=p/q ;4 disp (G, ”G( s )=” )5 H=1;6 y=G∗H7 F=1/(1+y) ;
31
8 disp (F , ”1/(1+G( s )H( s ) )=” )9 syms t s ;
10 Ko=l im i t ( s∗F/s , s , 0 ) / / Ko= L t s −>0 ( 1 / ( 1 + G ( s ) H ( S ) )
11 d=d i f f ( s∗F/s , s ) ;12 K1=l im i t ( d i f f ( s∗F/s , s ) , s , 0 ) / / K1= L t s −>0 ( dF ( s ) / d s )
13 K2=l im i t ( d i f f (d , s ) , s , 0 ) / / K2= L t s −>0 ( d 2 F ( s ) / d s )
14 / / g i v e n i n p u t i s r ( t ) = 4 + 3 ∗ t + 8 ( t ˆ 2 ) / 2 & R ( s ) = l a p l a c e ( r ( t
) )
15 a=(4+3∗ t+8∗( t ˆ2) /2)16 b=d i f f (4+3∗ t+8∗( t ˆ2) /2 , t )17 c=d i f f (b , t )18 e=Ko∗a+K1∗b+K2∗c / / e r r o r b y d y n a m i c c o e f f i c i e n t m e t h o d
19 disp ( e , ” e r r o r ” )
Example 8.06 8.06.sci
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=sysl in ( ’ c ’ , [ 2 5 / ( ( s+1)∗ s ) ] ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 CL=F/ .B / / C a l c u l a t e s 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
5 / / c o m p a r e CL w i t h Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗Wn+Wn ˆ 2 )
6 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r o f CL
7 z=coeff ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s o f t h e
d e n o m i n a t o r p o l y n o m i a l
8 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
9 Wn=sqrt ( z (1 , 1 ) ) / / Wn= n a t u r a l f r e q u e n c y
10 / / 2 ∗ z e t a ∗Wn= z ( 1 , 2 )
11 zeta=z (1 , 2 ) /(2∗Wn) / / z e t a = d a m p i n g f a c t o r
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
32
2 F=sysl in ( ’ c ’ , [ 2 0 / ( s ˆ2+5∗ s+5) ] ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 CL=F/ .B / / C a l c u l a t e s 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
5 / / c o m p a r e CL w i t h Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗Wn+Wn ˆ 2 )
6 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r o f CL
7 z=coeff ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s o f t h e
d e n o m i n a t o r p o l y n o m i a l
8 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
9 Wn=sqrt ( z (1 , 1 ) ) / / Wn= n a t u r a l f r e q u e n c y
10 / / 2 ∗ z e t a ∗Wn= z ( 1 , 2 )
11 zeta=z (1 , 2 ) /(2∗Wn) / / z e t a = d a m p i n g f a c t o r
12 Wd=Wn∗sqrt(1− zeta ˆ2)13 Tp=%pi/Wd / / Tp= p e a k t i m e
14 Mp=100∗exp((−%pi∗ zeta ) /sqrt(1− zeta ˆ2) ) / / p e a k
o v e r s h o o t
15 Td=(1+0.7∗ zeta ) /Wn / / Td= d e l a y t i m e
16 a=atan ( sqrt(1− zeta ˆ2) / zeta )17 Tr=(%pi−a ) /Wd / / T r = r i s e t i m e
18 Ts=4/( zeta ∗Wn) / / T s = s e t t l i n g t i m e
Example 8.08 8.08.sci
1 p=poly ( [ 1 4 0 , 3 5 ] , ’ s ’ , ’ c o e f f ’ ) ;2 q=poly ( [ 0 ,10 ,7 , 1 ] , ’ s ’ , ’ c o e f f ’ ) ;3 G=p/q4 H=15 y=G∗H / / t y p e 1
6 / / r e f e r i n g t h e t a b l e 8 . 2 g i v e n i n t h e b o o k , f o r t y p e 1
Kp= % i n f & Ka =0
7 syms s8 Kv=l im i t ( s∗y , s , 0 ) / / Kv= v e l o c i t y e r r o r c o e f f i c i e n t
9 / / g i v e n i n p u t i s r ( t ) = 5 ∗ t & R ( s ) = l a p l a c e ( r ( t ) )
10 R=lap l a c e ( ’ 5∗ t ’ , t , s )11 / / s t e a d y s t a t e e r r o r = L t s −>0 s R ( S ) / 1 + G ( s ) H ( S )
12 e=l im i t ( s∗R/(1+y) , s , 0 ) / / e = e r r o r f o r r a m p i n p u t
13 disp ( e , ” steady s t a t e e r r o r ” )
33
Example 8.09 8.09.sci
1 p=poly ( [ 4 0 , 2 0 ] , ’ s ’ , ’ c o e f f ’ ) ;2 q=poly ( [ 0 , 0 , 5 , 6 , 1 ] , ’ s ’ , ’ c o e f f ’ ) ;3 G=p/q ;4 H=1;5 y=G∗H; / / t y p e 2
6 disp (y , ”G( s )H( s=” )7 / / r e f e r i n g t h e t a b l e 8 . 2 g i v e n i n t h e b o o k , f o r t y p e 2
Kp= % i n f & Kv= % i n f
8 syms s t ;9 Ka=l im i t ( s ˆ2∗y , s , 0 ) / / Ka= a c c e l a r a t i o n e r r o r
c o e f f i c i e n t
10 / / g i v e n i n p u t i s r ( t ) =1+3 t + t ˆ 2 / 2 & R ( s ) = l a p l a c e ( r ( t ) )
11 R=lap l a c e ( ’ (1+3∗ t+(t ˆ2/2) ) ’ , t , s )12 / / s t e a d y s t a t e e r r o r = L t s −>0 s R ( S ) / 1 + G ( s ) H ( S )
13 e=l im i t ( s∗R/(1+y) , s , 0 ) / / e = e r r o r f o r r a m p i n p u t
14 disp ( e , ” steady s t a t e e r r o r ” )
Example 8.10 8.10.sci
1 s = poly ( 0 , ’ s ’ )2 sys = sysl in ( ’ c ’ , ( 20 ) /( s ˆ2+7∗ s+10) )3 a=sys / . ( 2∗ ( s+1) ) / / s i m p l i f y i n g t h e i n t e r n a l f e e d b a c k
l o o p
4 b=20∗2∗a ;5 disp (b , ”G( s ) ” )6 c=1;7 disp ( c , ”H( s ) ” )8 OL=b∗c ;9 disp (OL, ”G( s )H( s ) ” )
10 , ”G( s )∗H( s ) ” )11 syms t s ;12 Kp=l im i t ( s∗OL/s , s , 0 ) / / Kp= p o s i t i o n e r r o r c o e f f i c i e n t
13 Kv=l im i t ( s∗OL, s , 0 ) / / Kv= v e l o c i t y e r r o r c o e f f i c i e n t
14 Ka=l im i t ( s ˆ2∗OL, s , 0 ) / / Ka= a c c e l a r a t i o n e r r o r
c o e f f i c i e n t
34
15 / / g i v e n i n p u t r ( t ) =6
16 R=lap l a c e ( ’ 6 ’ , t , s )17 / / s t e a d y s t a t e e r r o r = L t s −>0 s R ( S ) / 1 + G ( s ) H ( S )
18 e1=l im i t ( s∗R/(1+OL) , s , 0 ) ; / / e = e r r o r f o r g i v e n i n p u t
19 disp ( e1 , ” e r r o r ” )20 / / g i v e n i n p u t r ( t ) =8 t
21 M=lap l a c e ( ’ 8∗ t ’ , t , s )22 / / s t e a d y s t a t e e r r o r = L t s −>0 s R ( S ) / 1 + G ( s ) H ( S )
23 e2=l im i t ( s∗M/(1+OL) , s , 0 ) ; / / e = e r r o r f o r g i v e n i n p u t
24 disp ( e2 , ” e r r o r ” )25 / / g i v e n i n p u t r ( t ) = 1 0 + 4 t +3 t ˆ 2 / 2
26 N=lap l a c e ( ’ 10+4∗ t+(3∗ t ˆ2) /2 ’ , t , s )27 / / s t e a d y s t a t e e r r o r = L t s −>0 s R ( S ) / 1 + G ( s ) H ( S )
28 e3=l im i t ( s∗N/(1+OL) , s , 0 ) ; / / e = e r r o r f o r g i v e n i n p u t
29 disp ( e3 , ” e r r o r ” )
Example 8.11 8.11.sci
1 s = poly ( 0 , ’ s ’ )2 sys1 = sysl in ( ’ c ’ , ( s ) /( s+6) ) ;3 sys2 = sysl in ( ’ c ’ , ( s+2)/( s+3) ) ;4 sys3 = sysl in ( ’ c ’ , ( 5 ) / ( ( s+3)∗ s ˆ3) ) ;5 a=sys2+sys3 ;6 disp ( a , ”H( s ) ” )7 b=sys1 ;8 disp (b , ”G(S) ” )9 y=a∗b ;
10 disp (y , ”G(S)H(S) ” )11 syms s12 Kp=l im i t ( s∗y/s , s , 0 ) / / Kp= p o s i t i o n e r r o r c o e f f i c i e n t
13 Kv=l im i t ( s∗y , s , 0 ) / / Kv= v e l o c i t y e r r o r c o e f f i c i e n t
14 Ka=l im i t ( s ˆ2∗y , s , 0 ) / / Ka= a c c e l a r a t i o n e r r o r
c o e f f i c i e n t
Example 8.12 8.12.sci
1 s=%s ;2 syms k t ;
35
3 y=k /( ( s+1)∗ s ˆ2∗( s+4) ) ;4 disp (y , ”G( s )H( s )=” )5 r=1+(8∗ t )+(18∗ t ˆ2/2) ;6 disp ( r , ” r ( t )=” )7 R=lap l a c e ( r , t , s ) ;8 disp (R, ”R( s )=” )9 e=l im i t ( ( s∗R)/(1+y) , s , 0 )
10 disp ( e , ”Ess=” )11 printf ( ’ Given Ess = 0 .8 \n”)12 e =0.8 ;13 k=72/e ;14 di sp (k , ” k=”)
Example 8.13 8.13.sci
1 syms s t k ;2 s = poly ( 0 , ’ s ’ ) ;3 y=k/( s ∗( s+2) ) ; / / G ( s ) H ( s )
4 disp (y , ”G( s )H( s ) ” )5 / / R= l a p l a c e ( ’ 0 . 2 ∗ t ’ , t , s )
6 R=lap l a c e ( ’ 0 .2∗ t ’ , t , s )7 e=l im i t ( s∗R/(1+y) , s , 0 )8 / / g i v e n e < = 0 . 0 2
9 a = [ 0 . 0 2 ] ;10 b=[−0.4 ] ;11 m=l insolve ( a , b ) ; / / S o l v e s T h e L i n e a r E q u a t i o n
12 disp (m, ”k” )
Example 8.14 8.14.sci
1 syms s , t , k ;2 s=%s ;3 y=k/( s ∗( s+2)∗(1+0.5∗ s ) ) / / G ( s ) H ( s )
4 disp (y , ”G( s )H( s ) ” )5 / / R= l a p l a c e ( ’ 3 ∗ t ’ , t , s )
6 R=lap l a c e ( ’ 3∗ t ’ , t , s )7 e=l im i t ( s∗R/(1+y) , s , 0 ) ;8 disp ( e , ” steady s t a t e e r r o r ” )
36
9 k=4; / / g i v e n
10 y=e ;11 disp (y , ” s t a t e s t a t e e r r o r when k=4” )
Example 8.15 8.15.sci
1 s = poly ( 0 , ’ s ’ ) ;2 sys = sysl in ( ’ c ’ ,180/( s ∗( s+6) ) ) / / G ( s ) H ( s )
3 disp ( sys , ”G( s )H( s ) ” )4 syms t s ;5 / / R= l a p l a c e ( ’ 4 ∗ t ’ , t , s )
6 R=lap l a c e ( ’ 4∗ t ’ , t , s ) ;7 e=l im i t ( s∗R/(1+ sys ) , s , 0 ) ;8 y=dbl ( e ) ;9 disp (y , ” steady s t a t e e r r o r ” )
10 syms k real ;11 / / v a l u e o f k i f e r r o r r e d u c e d b y 6% ;
12 e1=l im i t ( s∗R/(1+k/( s ∗( s+6) ) ) , s , 0 ) / / −−−−−−−1
13 e1=0.94∗ e / / −−−−−−−−2
14 / / n o w s o l v i n g t h e s e t w o e q u a t i o n s
15 a = [47 ] ;16 b=[−9000];17 m=l insolve ( a , b ) ;18 disp (m, ”k” )
Example 8.16 8.16.sci
1 s=%s ;2 F=sysl in ( ’ c ’ , ( 81 ) /( s ˆ2+6∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 CL=F/ .B / / C a l c u l a t e s 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
5 / / c o m p a r e CL w i t h Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗Wn+Wn ˆ 2 )
6 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r o f CL
7 z=coeff ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s o f t h e
d e n o m i n a t o r p o l y n o m i a l
8 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
37
9 Wn=sqrt ( z (1 , 1 ) ) / / Wn= n a t u r a l f r e q u e n c y
10 / / 2 ∗ z e t a ∗Wn= z ( 1 , 2 )
11 zeta=z (1 , 2 ) /(2∗Wn) / / z e t a = d a m p i n g f a c t o r
12 Wd=Wn∗sqrt(1− zeta ˆ2)13 Tp=%pi/Wd / / Tp= p e a k t i m e
14 Mp=100∗exp((−%pi∗ zeta ) /sqrt(1− zeta ˆ2) ) / / p e a k
o v e r s h o o t
Example 8.17 8.17.sci
1 s=%s ;2 F=sysl in ( ’ c ’ , ( 25 ) /( s ˆ2+7∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 k=20/25; / / k = g a i n f a c t o r
5 CL=k∗(F/ .B) / / C a l c u l a t e s 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
6 / / c o m p a r e CL w i t h Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗Wn+Wn ˆ 2 )
7 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r o f CL
8 z=coeff ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s o f t h e
d e n o m i n a t o r p o l y n o m i a l
9 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
10 Wn=sqrt ( z (1 , 1 ) ) / / Wn= n a t u r a l f r e q u e n c y
11 / / 2 ∗ z e t a ∗Wn= z ( 1 , 2 )
12 zeta=z (1 , 2 ) /(2∗Wn) / / z e t a = d a m p i n g f a c t o r
13 Wd=Wn∗sqrt(1− zeta ˆ2)14 Tp=%pi/Wd / / Tp= p e a k t i m e
15 Mp=100∗exp((−%pi∗ zeta ) /sqrt(1− zeta ˆ2) ) / / p e a k
o v e r s h o o t
16 Td=(1+0.7∗ zeta ) /Wn / / Td= d e l a y t i m e
17 a=atan ( sqrt(1− zeta ˆ2) / zeta )18 Tr=(%pi−a ) /Wd / / T r = r i s e t i m e
19 Ts=4/( zeta ∗Wn) / / T s = s e t t l i n g t i m e
20 / / y ( t ) = e x p r e s s i o n f o r o u t p u t
21 y=(20/25)∗(1−(exp(−1∗ zeta ∗Wn∗ t ) /sqrt(1− zeta ˆ2) )∗ sin (Wd∗t+atan ( ze ta /sqrt(1− zeta ˆ2) ) ) ) ;
22 disp (y , ”Y( t ) ” )
38
Example 8.19 8.19.sci
1 s=%s ;2 F=sysl in ( ’ c ’ , ( 144) /( s ˆ2+12∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 k=20/25; / / k = g a i n f a c t o r
5 CL=k∗(F/ .B) / / C a l c u l a t e s 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
6 / / c o m p a r e CL w i t h Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗Wn+Wn ˆ 2 )
7 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r o f CL
8 z=coeff ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s o f t h e
d e n o m i n a t o r p o l y n o m i a l
9 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
10 Wn=sqrt ( z (1 , 1 ) ) / / Wn= n a t u r a l f r e q u e n c y
11 / / 2 ∗ z e t a ∗Wn= z ( 1 , 2 )
12 zeta=z (1 , 2 ) /(2∗Wn) / / z e t a = d a m p i n g f a c t o r
13 Wd=Wn∗sqrt(1− zeta ˆ2)14 Tp=%pi/Wd / / Tp= p e a k t i m e
15 Mp=100∗exp((−%pi∗ zeta ) /sqrt(1− zeta ˆ2) ) / / p e a k
o v e r s h o o t
16 Td=(1+0.7∗ zeta ) /Wn / / Td= d e l a y t i m e
17 a=atan ( sqrt(1− zeta ˆ2) / zeta )18 Tr=(%pi−a ) /Wd / / T r = r i s e t i m e
19 Ts=4/( zeta ∗Wn) / / T s = s e t t l i n g t i m e
10 disp (CL, ”C( s ) /R( s )=” ) / / C a l c u l a t e s 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
11 / / c o m p a r e CL w i t h Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗Wn+Wn ˆ 2 )
12 [ num, den]=numden(CL) / / e x t r a c t s num & d e n o f s y m b o l i c
f u n c t i o n ( CL )
13 den=den/T;14 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 ) / / c o e f f o f d e n o f s y m b o l i c
f u n c t i o n ( CL )
15 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )16 / / Wn ˆ 2 = c o f a 0 , c o m p a r i n g t h e c o e f f i c i e n t s
17 Wn=sqrt ( c o f a 0 )18 disp (Wn, ” natura l f requency Wn” ) / / Wn= n a t u r a l
f r e q u e n c y
19 / / c o f a 1 = 2 ∗ z e t a ∗Wn
20 zeta=co f a 1 /(2∗Wn)
Example 8.23-01 8.23.01.sci
1 s= poly ( 0 , ’ s ’ ) ;2 sys = sysl in ( ’ c ’ ,10/( s+2) ) ; / / G ( s ) H ( s )
3 disp ( sys , ”G( s )H( s ) ” )4 F=1/(1+sys )5 syms t s ;6 Co=l im i t ( s∗F/s , s , 0 ) / / Ko= L t s −>0 ( 1 / ( 1 + G ( s ) H ( S ) )
7 a=(3) ;8 e=Co∗a ;9 disp ( e , ” steady s t a t e e r r o r ” )
Example 8.23-02 8.23.02.sci
1 s= poly ( 0 , ’ s ’ ) ;2 sys = sysl in ( ’ c ’ ,10/( s+2) ) ; / / G ( s ) H ( s )
3 disp ( sys , ”G( s )H( s ) ” )4 F=1/(1+sys )5 syms t s ;6 Co=l im i t ( s∗F/s , s , 0 ) / / Ko= L t s −>0 ( 1 / ( 1 + G ( s ) H ( S ) )
7 d=d i f f ( s∗F/s , s )8 C1=l im i t ( d i f f ( s∗F/s , s ) , s , 0 ) / / K1= L t s −>0 ( dF ( s ) / d s )
40
9 a=(2∗ t ) ;10 b=d i f f ( (2∗ t ) , t ) ;11 e=Co∗a+C1∗b ;12 disp ( e , ” s t eadt s t a t e e r r o r ” )
Example 8.23-03 8.23.03.sci
1 s= poly ( 0 , ’ s ’ ) ;2 sys = sysl in ( ’ c ’ ,10/( s+2) ) ; / / G ( s ) H ( s )
3 disp ( sys , ”G( s )H( s ) ” )4 F=1/(1+sys )5 syms t s ;6 Co=l im i t ( s∗F/s , s , 0 ) / / Ko= L t s −>0 ( 1 / ( 1 + G ( s ) H ( S ) )
7 d=d i f f ( s∗F/s , s )8 C1=l im i t ( d i f f ( s∗F/s , s ) , s , 0 ) / / K1= L t s −>0 ( dF ( s ) / d s )
9 C2=l im i t ( d i f f (d , s ) , s , 0 ) / / K2= L t s −>0 ( d 2 F ( s ) / d s )
10 a=(( t ˆ2) /2) ;11 b=d i f f ( ( t ˆ2) /2 , t ) ;12 c=d i f f (b , t ) ;13 e=Co∗a+C1∗b+C2∗c ;14 disp ( e , ” steady s t a t e e r r o r ” )
Example 8.23-04 8.23.04.sci
1 s= poly ( 0 , ’ s ’ ) ;2 sys = sysl in ( ’ c ’ ,10/( s+2) ) ; / / G ( s ) H ( s )
3 disp ( sys , ”G( s )H( s ) ” )4 F=1/(1+sys )5 syms t s ;6 Co=l im i t ( s∗F/s , s , 0 ) / / Ko= L t s −>0 ( 1 / ( 1 + G ( s ) H ( S ) )
7 d=d i f f ( s∗F/s , s )8 C1=l im i t ( d i f f ( s∗F/s , s ) , s , 0 ) / / K1= L t s −>0 ( dF ( s ) / d s )
9 C2=l im i t ( d i f f (d , s ) , s , 0 ) / / K2= L t s −>0 ( d 2 F ( s ) / d s )
10 / / g i v e n i n p u t i s r ( t ) = 1 + 2 ∗ t + ( t ˆ 2 ) / 2 & R ( s ) = l a p l a c e ( r ( t )
)
11 a=(1+2∗ t+(t ˆ2) /2) ;12 b=d i f f ( a , t ) ;13 c=d i f f (b , t ) ;
41
14 e=Co∗a+C1∗b+C2∗c / / e r r o r b y d y n a m i c c o e f f i c i e n t m e t h o d
Example 8.24 8.24.sci
1 s= poly ( 0 , ’ s ’ ) ;2 sys1 = sysl in ( ’ c ’ , ( s+3)/( s+5) ) ;3 sys2= sysl in ( ’ c ’ , ( 100) /( s+2) ) ;4 sys3= sysl in ( ’ c ’ , ( 0 . 1 5 ) /( s+3) ) ;5 G=sys1 ∗ sys2 ∗ sys3 ∗2∗56 H=1;7 y=G∗H; / / G ( s ) H ( s )
8 disp (y , ”G( s )H( s ) ” )9 F=1/(1+y)
10 syms t s ;11 Co=l im i t ( s∗F/s , s , 0 ) / / Ko= L t s −>0 ( 1 / ( 1 + G ( s ) H ( S ) )
12 d=d i f f ( s∗F/s , s )13 C1=l im i t ( d i f f ( s∗F/s , s ) , s , 0 ) / / K1= L t s −>0 ( dF ( s ) / d s )
14 C2=l im i t ( d i f f (d , s ) , s , 0 ) / / K2= L t s −>0 ( d 2 F ( s ) / d s )
15 a=(1+(2∗ t ) +(5∗( t ˆ2/2) ) ) ;16 b=d i f f ( a , t ) ;17 c=d i f f (b , t ) ;18 e=Co∗a+C1∗b+C2∗c ;19 disp ( e , ” s t eadt s t a t e e r r o r ” )
Example 8.32 8.32.sci
1 s=%s ;2 sys=sysl in ( ’ c ’ ,(9∗(1+2∗ s ) ) /( s ˆ2+0.6∗ s+9) ) ;3 disp ( sys , ”C( s ) /R( s )=” )4 / / g i v e n r ( t ) =u ( t )
5 syms t s ;6 R=lap l a c e ( ’ 1 ’ , t , s ) ;7 disp (R, ”R( s )=” )8 C=R∗ sys ;9 disp (C, ”C( s )=” )
10 c=i l a p l a c e (C, s , t )11 disp ( c , ”c ( t )=” )12 G=9/( s ˆ3+0.6∗ s ˆ2) ;
42
13 disp (G, ”G( s )=” )14 H=1;15 y=1+G∗H;16 syms t s ;17 Kp=l im i t ( s∗G/s , s , 0 )18 Kv=l im i t ( s∗G, s , 0 )19 Ka=l im i t ( s ˆ2∗G, s , 0 )20 R=lap l a c e ( ’ (1+t+(t ˆ2/2) ) ’ , t , s )21 / / s t e a d y s t a t e e r r o r = L t s −>0 s R ( S ) / 1 + G ( s ) H ( S )
22 e=l im i t ( s∗R/(1+y) , s , 0 ) ; / / e = e r r o r f o r r a m p i n p u t
23 disp ( e , ” steady s t a t e e r r o r ( Ess ) ” )
43
Chapter 9
Feedback Characteristics ofcontrol Systems
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox
9.1 Scilab Code
Example 9.01 9.01.sci
1 s=%s ;2 G=sysl in ( ’ c ’ ,20/( s ∗( s+4) ) )3 H=0.35;4 y=G∗H;5
6 S=1/(1+y) ;7 disp (S , ”1/(1+G( s )∗H( s ) ) ” )8
9 / / g i v e n w = 1 . 2
10 w=1.211 s=%i∗w12 S=horner (S , s ) / / c a l c u l a t e s v a l u e o f S a t s
13 a=abs (S)14 disp ( a , ” s e n s i t i v i t y o f open loop ” )15
44
16 F=−y/(1+y)17 disp (F , ”(−G( s )∗H( s ) ) /(1+G( s )∗H( s ) ) ” )18 S=horner (F , s ) / / c a l c u l a t e s v a l u e o f F a t s
19 b=abs (S)20 disp (b , ” s e n s i t i v i t y o f c l o s ed loop ” )
Example 9.02 9.02.sci
1 s=%s ;2 sys1=sysl in ( ’ c ’ , 9/( s ∗( s +1.8) ) ) ;3 syms Td ;4 sys2=1+(s∗Td) ;5 sys3=sys1 ∗ sys2 ;6 H=1;7 CL=sys3 / .H; / / C a l c u l a t e s 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
8 disp (CL, ”C( s ) /R( s ) ” )9 / / c o m p a r e CL w i t h Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗Wn+Wn ˆ 2 )
10 [ num, den]=numden(CL) / / e x t r a c t s num & d e n o f s y m b o l i c
f u n c t i o n CL
11 den=den /5 ;12 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 ) / / c o e f f o f d e n o f s y m b o l i c
f u n c t i o n CL
13 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )14 / / Wn ˆ 2 = c o f a 0 , c o m p a r i n g t h e c o e f f i c i e n t s
15 Wn=sqrt ( c o f a 0 )16 disp (Wn, ” natura l f requency Wn” ) / / Wn= n a t u r a l
f r e q u e n c y
17 / / c o f a 1 = 2 ∗ z e t a ∗Wn
18 zeta=co f a 1 /(2∗Wn)19 zeta =1;disp ( zeta , ” f o r c r i t i c a l y damped func t i on zeta ” )20 Td=((2∗Wn) −1.8) /921 Ts=4/( zeta ∗Wn) ;22 Ts=dbl (Ts ) ;23 disp (Ts , ” s e t t l i n g time Ts” )
Example 9.03 9.03.sci
1 s=%s ;
45
2 G=sysl in ( ’ c ’ ,40/( s ∗( s+4) ) )3 H=0.50;4 y=G∗H;5 S=1/(1+y) ;6 disp (S , ”1/(1+G( s )∗H( s ) ) ” )7 / / g i v e n w = 1 . 3
8 w=1.39 s=%i∗w
10 S=horner (S , s )11 a=abs (S)12 disp ( a , ” s e n s i t i v i t y o f open loop ” )13 F=−y/(1+y)14 disp (F , ”(−G( s )∗H( s ) ) /(1+G( s )∗H( s ) ) ” )15 S=horner (F , s )16 b=abs (S)17 disp (b , ” s e n s i t i v i t y o f c l o s ed loop ” )
Example 9.04 9.04.sci
1 s=%s ;2 syms s ;3 syms Wn zeta A H real ;4 T=6.28;5 Wn=(8∗%pi ) /T;6 zeta =0.37 n=Wnˆ2 ;8 d=sˆ2+2∗ zeta ∗Wn∗ s+Wnˆ2 ;9 G1=n/d ;
10 disp (G1, ”G1( s ) ” )11 G=A∗G1;12 disp (G, ”G( s ) ” )13 S1=(d i f f (G,A) ) ∗(A/G) ;14 a=simple ( S1 ) ;15 disp ( a , ”open loop s e n s i t i v i t y f o r changes in A” )16 M=G/ .H;17 p=simple (M)18 S2=(d i f f (p ,A) ) ∗(A/p) ;19 b=simple ( S2 ) ;
46
20 disp (b , ” c l o s ed loop s e n s i t i v i t y f o r changes in A” )21 S3=(d i f f (p ,H) ) ∗(H/p) ;22 c=s imple ( S3 ) ;23 disp ( c , ” c l o s ed loop s e n s i t i v i t y f o r changes in H” )
Example 9.05 9.05.sci
1 s=%s ;2 sys1=sysl in ( ’ c ’ , ( s+3)/ s ) ;3 syms u rp k H RL;4 num2=u∗RL∗ s ∗( s+2) ;5 den2=(rp+RL) ∗( s+3) ;6 sys2=num2/den2 ;7 num3=k ;8 den3=s+2;9 sys3=num3/den3 ;
10 sys=sys1 ∗ sys2 ∗ sys3 ;11 disp ( sys , ”G( s )=” ) ;12 RL=10∗10ˆ3;13 rp =4∗10ˆ3;14 sys=eval ( sys )15 sys=f l o a t ( sys )16 disp ( sys , ” sys=” ) ;17 disp (H, ”H( s ) ” ) ;18 M=sys / .H / / G ( s ) / 1 + G ( s ) H ( S )
19 M=simple (M)20 S=(d i f f (M, u) ) ∗(u/M) ;21 S=simple (S) ;22 disp (S , ” system s e n s i t i v i t y due to va r i a t i o n o f u=” ) ;23 H=0.3;24 u=12;25 S=eval (S) / / −−−−−−−−− e q 1
26 S=0.04;27 k=((7/S)−7)/18 ; / / f r o m e q 1
28 disp (k , ”K=” )
Example 9.06 9.06.sci
47
1 G=210;2 H=0.12;3 syms Eo Er4 printf ( ” f o r c l o s ed loop system” )5 sys=G/ .H; / / Eo / E r =G / ( 1 + GH )
6 disp ( sys , ”Eo/Er=” )7 Eo=240 / / g i v e n
8 Er=Eo/8 . 0152 ;9 disp (Er , ”Er=” )
10 printf ( ” f o r open loop system” )11 disp (G, ”Eo/Er=” )12 Er=Eo/G;13 G=210;14 disp (Er , ”Er=” )15 / / p r i n t f ( ” s i n c e G i s r e d u c e d b y 1 2 % , t h e n e w v a l u e o f
g a i n i s 7 8 4 . 8 V ” ) ;
16 S=1/(1+G∗H)17 disp (S , ” (%change in M) /(%change in G)=” )18 disp (12 , ”%CHANGE IN G=” )19 y=12∗0.03869;20 disp (y , ”%CHANGE IN M=” )21 printf ( ” f o r open loop system” )22 disp (28 .8∗100/240 , ”%change in Eo” )
Example 9.07 9.07.sci
1 s=%s ;2 sys1=sysl in ( ’ c ’ ,20/( s ∗( s+2) ) ) ;3 syms Kt ;4 sys2=Kt∗ s ;5 sys3=sys1 / . sys2 ;6 p=simple ( sys3 ) ;7 disp (p , ”G( s )=” )8 H=1;9 sys=sys3 / .H;
1 s=%s ;2 printf ( ” 1) ze ta & Wn without Kd” )3 G=60∗ sysl in ( ’ c ’ , 1/( s ∗( s+4) ) ) ;4 disp (G, ”G(S)=” )5 CL=G/ .H;6 disp (CL, ”C( s ) /R( s )=” )7 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r o f CL
8 z=coeff ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s o f t h e
d e n o m i n a t o r p o l y n o m i a l
9 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
10 Wn=sqrt ( z (1 , 1 ) ) / / Wn= n a t u r a l f r e q u e n c y
11 / / 2 ∗ z e t a ∗Wn= z ( 1 , 2 )
12 zeta=z (1 , 2 ) /(2∗Wn)13 sys1=sysl in ( ’ c ’ , 1/( s ∗( s+4) ) ) ;
49
14 syms Kd;15 printf ( ” 2)Kd f o r ze ta =0.60 with c o n t r o l l e r ” )16 sys2=s∗Kd;17 sys3=sys1 / . sys2 ;18 G=sys3 ∗60 ;19 disp (G, ”G( s )=” )20 H=1;21 sys=G/ .H;22 disp ( sys , ”C( s ) /R( s )=” )23 [ num, den]=numden( sys )24 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 )25 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )26 / / Wn ˆ 2 = c o f a 0 , c o m p a r i n g t h e c o e f f i c i e n t s
27 Wn=sqrt ( c o f a 0 )28 Wn=dbl (Wn) ;29 disp (Wn, ” natura l f requency Wn=” )30 / / c o f a 1 = 2 ∗ z e t a ∗Wn
31 zeta =0.6032 Kd=(2∗ zeta ∗Wn)−4
Example 9.09 9.09.sci
1 s=%s ;2 printf ( ” 1) without c o n t r o l l e r ” )3 G=sysl in ( ’ c ’ ,120/( s ∗( s +12.63) ) ) ;4 disp (G, ”G( s )=” )5 H=1;6 CL=G/ .H;7 disp (CL, ”C( s ) /R( s )=” )8 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r o f CL
9 z=coeff ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s o f t h e
d e n o m i n a t o r p o l y n o m i a l
10 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
11 Wn=sqrt ( z (1 , 1 ) ) ;12 disp (Wn, ”Wn=” ) / / Wn= n a t u r a l f r e q u e n c y
16 printf ( ” 2) with c on t r o l l e r ’ )17 G=s y s l i n ( ’ c ’ , (120∗(30+ s ) ) /( s ∗( s +12.63) ∗30) ) ;18 di sp (G, ”G( s )=” )19 CL=G/ .H;20 di sp (CL, ”C( s ) /R( s )=” )21 den=denom(CL)22 den=den/30 // ex t r a c t i n g the denominator o f CL23 z=c o e f f ( den ) // ex t r a c t i n g the c o e f f i c i e n t s o f the
denominator polynomial24 //Wn̂ 2=z (1 , 1 ) , comparing the c o e f f i c i e n t s25 Wn=sqr t ( z (1 , 1 ) ) ;26 di sp (Wn, ”Wn=” ) // Wn=natura l f requency27 //2∗ zeta ∗Wn=z (1 , 2 )28 zeta=z (1 , 2 ) /(2∗Wn) ;29 Mp=100∗exp((−%pi∗ zeta ) / sq r t (1− zeta ˆ2) ) ;30 di sp (Mp, ”Mp=” )31 Ts=4/( zeta ∗Wn) ;32 di sp (Ts , ”Ts=” )
Example 9.10 9.10.sci
1 s=%s ;2 printf ( ” 1) without c o n t r o l l e r ” )3 G=64∗ sysl in ( ’ c ’ , 1/( s ∗( s+4) ) ) ;4 disp (G, ”G( s )=” )5 H=1;6 CL=G/ .H;7 disp (CL, ”C( s ) /R( s )=” )8 / / E x t r a c t i n g t h e d e n o m i n a t o r o f CL
9 y=denom(CL)10 / / E x t r a c t i n g t h e c o e f f i c i e n t s o f t h e d e n o m i n a t o r
p o l y n o m i a l
11 z=coeff ( y )12 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
13 Wn=sqrt ( z (1 , 1 ) ) ;14 / / Wn= n a t u r a l f r e q u e n c y
15 disp (Wn, ”Wn=” )16 printf ( ” 2) with c on t r o l l e r ’ )
51
17 syms K;18 sys1=s y s l i n ( ’ c ’ , 1 / ( s ∗( s+4) ) ) ;19 sys2=sys1 / . ( s∗K) ;20 G=64∗ sys221 di sp (G, ”G( s )=” )22
23 sys=G/ .H;24 sys=simple ( sys ) ;25 di sp ( sys , ”C( s ) /R( s )=” )26 [ num, den]=numden( sys )27 // Coef f o f den o f symbol ic func t i on CL28 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 )29 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )30 //Wn̂ 2= co f a 0 , comparing the c o e f f i c i e n t s31 Wn=sqr t ( c o f a 0 )32 Wn=dbl (Wn) ;33 //Wn=natura l f requency34 di sp (Wn, ” natura l f requency Wn=” )35 // c o f a 1=2∗zeta ∗Wn36 zeta=co f a 1 /(2∗Wn)37 zeta =0.6 ;38 k=(16∗ zeta )−439 di sp (k , ”K=” )
Example 9.11 9.11.sci
1 printf ( ” 2) with c on t r o l l e r ’ )2 syms K;3 sys1=s y s l i n ( ’ c ’ , 1 / ( s ∗( s +1.2) ) ) ;4 sys2=sys1 / . ( s∗K) ;5 G=16∗ sys2 ;6 G=simple (G)7 di sp (G, ”G( s )=” )8 sys=G/ .H;9 sys=simple ( sys ) ;
10 di sp ( sys , ”C( s ) /R( s )=” )11 [ num, den]=numden( sys )12 den=den /5 ; // so that c o e f f o f sˆ2=1
52
13 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 ) // c o e f f o f den o f symbol icfunc t i on CL
14 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )15 //Wn̂ 2= co f a 0 , comparing the c o e f f i c i e n t s16 Wn=sqr t ( c o f a 0 )17 Wn=dbl (Wn) ;18 di sp (Wn, ” natura l f requency Wn=” ) // Wn=
natura l f requency19 // c o f a 1=2∗zeta ∗Wn20 // zeta=co f a 1 /(2∗Wn)21 zeta =0.56;22 k=(8∗ zeta )−1.223 di sp (k , ”K=” )24 Wd=Wn∗ s q r t (1− zeta ˆ2) ;25 di sp (Wd, ”Wd=” )26 Tp=%pi/Wd;27 di sp (Tp, ”Tp=” )28 Mp=100∗exp((−%pi∗ zeta ) / sq r t (1− zeta ˆ2) ) ;29 di sp (Mp, ”Mp=” )30 Ts=4/( zeta ∗Wn) ;31 di sp (Ts , ”Ts=” )
53
Chapter 10
Stability
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox.
You can also refer the inbuilt function(routh-t) for generating Routh Ta-ble.
10.1 Scilab Code
Example 10.02-01 10.02.01.sci
1 s = poly (0 , ” s ” ) ;2 p=poly ( [ 1 2 ] , ’ s ’ , ’ c o e f f ’ ) ;3 q=poly ( [ 0 2 4 1 ] , ’ s ’ , ’ c o e f f ’ ) ;4 G=p/q ;5 H=poly ( [ 0 . 5 ] , ’ s ’ , ’ c o e f f ’ ) ;6 / / c h a r a c t e r i s t i c e q u a t i o n i s 1+G ( s ) H ( s ) =0
7 y=1+G∗H8 r=numer( y )9 disp ( ’=0 ’ , r , ” c h a r a c t e r i s t i c s equat ion i s ” )
Example 10.02-02 10.02.02.sci
1 s = poly (0 , ” s ” ) ;2 p=poly ( [ 7 ] , ’ s ’ , ’ c o e f f ’ ) ;3 q=poly ( [ 2 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
54
4 G=p/q ;5 H=poly ( [ 0 1 ] , ’ s ’ , ’ c o e f f ’ ) ;6 / / c h a r a c t e r i s t i c e q u a t i o n i s 1+G ( s ) H ( s ) =0
7 y=1+G∗H8 r=numer( y )9 disp ( ’=0 ’ , r , ” c h a r a c t e r i s t i c s equat ion i s ” )
Example 10.02-03 10.02.03.sci
1 s = poly (0 , ” s ” ) ;2 G=sysl in ( ’ c ’ , 2/( s ˆ2+2∗ s ) )3 H=sysl in ( ’ c ’ ,1/ s ) ;4 / / c h a r a c t e r i s t i c e q u a t i o n i s 1+G ( s ) H ( s ) =0
5 y=1+G∗H6 r=numer( y )7 disp ( ’=0 ’ , r , ” c h a r a c t e r i s t i c s equat ion i s ” )
Example 10.03 10.03.sci
1 s=%s ;2 m=sˆ3+5∗ s ˆ2+10∗ s+3;3 r=coeff (m)4 n=length ( r ) ;5 routh=[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;6 routh=[ routh ;−det ( routh ) / routh (2 , 1 ) , 0 ] ;7 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e s u b b l o c k o f
r o u t h m a t r i x
8 routh=[ routh ;−det ( t ) / t ( 2 , 1 ) , 0 ]9 c=0;
10 for i =1:n11 i f ( routh ( i , 1 )< 0)12 c=c+1;13 end14 end15 i f ( c>=1)16 printf ( ” system i s unstab le ” )17 else ( ” system i s s t ab l e ” )18 end
55
Example 10.04 10.04.sci
1 s=%s ;2 m=sˆ3+2∗ s ˆ2+3∗ s +10;3 r=coeff (m)4 n=length ( r ) ;5 routh=[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;6 routh=[ routh ;−det ( routh ) / routh (2 , 1 ) , 0 ] ;7 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e s u b b l o c k o f
r o u t h m a t r i x
8 routh=[ routh ;−det ( t ) / t ( 2 , 1 ) , 0 ]9 c=0;
10 for i =1:n11 i f ( routh ( i , 1 ) <0)12 c=c+1;13 end14 end15 i f ( c>=1)16 printf ( ” system i s unstab le ” )17 else ( ” system i s s t ab l e ” )18 end
11 c=0;12 for i =1:n13 i f ( routh ( i , 1 ) <0)14 c=c+1;15 end16 end17 i f ( c>=1)18 printf ( ” system i s unstab le ” )19 else ( ” system i s s t ab l e ” )20 end
10 c=0;11 for i =1:n12 i f ( routh ( i , 1 ) <0)13 c=c+1;14 end15 end16 i f ( c>=1)17 printf ( ” system i s unstab le ” )18 else ( ” system i s s t ab l e ” )19 end
Example 10.06 10.06.sci
57
1 ieee (2 )2 s=%s ;3 m=sˆ5+2∗ s ˆ4+4∗ s ˆ3+8∗ s ˆ2+3∗ s+14 r=coeff (m) ; / / E x t r a c t s t h e c o e f f i c i e n t o f t h e
( 3 : 4 , 2 : 3 ) ) / routh (4 , 2 ) , 0 ] ;11 routh=[ routh ;−det ( routh ( 4 : 5 , 1 : 2 ) ) / routh (5 , 1 ) , 0 , 0 ] ;12 disp ( routh , ” routh=” )13 / / To c h e c k t h e s t a b i l i t y
14 routh (4 , 1 )=8− l im i t (5/ eps , eps , 0 ) ; / / P u t t i n g t h e v a l u e o f
e p s =0 i n r o u t h ( 4 , 1 )
15 disp ( routh (4 , 1 ) , ” routh (4 , 1 )=” )16 routh (5 , 1 )= l im i t ( routh (5 , 1 ) , eps , 0 ) ; / / P u t t i n g t h e
v a l u e o f e p s =0 i n r o u t h ( 5 , 1 )
17 disp ( routh (5 , 1 ) , ” routh (5 , 1 ) = ’)18 routh19 p r i n t f ( ”There are two sign changes o f f i r s t column ,
hence the system i s uns tab l e \n” )
Example 10.07 10.07.sci
1 s=%s ;2 m=sˆ5+2∗ s ˆ4+2∗ s ˆ3+4∗ s ˆ2+4∗ s+83 routh=routh t (m) / / T h i s F u n c t i o n g e n e r a t e s t h e R o u t h
t a b l e
4 c=0;5 for i =1:n6 i f ( routh ( i , 1 ) <0)7 c=c+1;8 end9 end
58
10 i f ( c>=1)11 printf ( ” system i s unstab le ” )12 else ( ” system i s s t ab l e ” )13 end
10 for i =1:n11 i f ( routh ( i , 1 ) <0)12 c=c+1;13 end14 end15 i f ( c>=1)16 printf ( ” system i s unstab le ” )17 else ( ” system i s s t ab l e ” )18 end
Example 10.09 10.09.sci
1 ieee (2 ) ;2 s=%s ;3 m=sˆ5+sˆ4+3∗ s ˆ3+3∗ s ˆ2+4∗ s+84 r=coeff (m) ; / / E x t r a c t s t h e c o e f f i c i e n t o f t h e
( 3 : 4 , 2 : 3 ) ) / routh (4 , 2 ) , 0 ] ;11 routh=[ routh ;−det ( routh ( 4 : 5 , 1 : 2 ) ) / routh (5 , 1 ) , 0 , 0 ] ;12 disp ( routh , ” routh=” )13 / / To c h e c k t h e s t a b i l i t y
14 routh (4 , 1 )=l im i t ( routh (4 , 1 ) , eps , 0 ) ; / / P u t t i n g t h e v a l u e
o f e p s =0 i n r o u t h ( 4 , 1 )
15 disp ( routh (4 , 1 ) , ” routh (4 , 1 )=” )16 routh (5 , 1 )= l im i t ( routh (5 , 1 ) , eps , 0 ) ; / / P u t t i n g t h e
v a l u e o f e p s =0 i n r o u t h ( 5 , 1 )
17 disp ( routh (5 , 1 ) , ” routh (5 , 1 ) = ’)18 routh19 p r i n t f ( ”There are two sign changes o f f i r s t column ,
hence the system i s uns tab l e \n” )
Example 10.10 10.10.sci
1 ieee (2 ) ;2 syms s k ;3 m=sˆ4+4∗ s ˆ3+7∗ s ˆ2+6∗ s+k ;4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;7 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;8 c o f a 4 = c o e f f s (m, ’ s ’ , 4 ) ;9
10 r=[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 c o f a 4 ]11
1 ieee (2 ) ;2 syms s k ;3 m=(24/100)∗ sˆ3+sˆ2+s+k ;4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;7 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;8 r=[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ]9 n=length ( r ) ;
10 routh=[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ]11 routh=[ routh ;−det ( routh ) / routh (2 , 1 ) , 0 ]12 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e s u b b l o c k o f
r o u t h m a t r i x
13 routh=[ routh ;−det ( t ) / routh (3 , 1 ) , 0 ]14 disp ( routh , ” routh=” ) ;15 routh (3 , 1 )=0 / / F o r m a r g i n a l y s t a b l e s y s t e m
16 k=1/0.24;17 disp (k , ”K( marginal )=” )18 disp ( ’=0 ’ , ( s ˆ2)+k , ” a ux i l l a r y equat ion ” )19 s=sqrt(−k ) ;20 disp ( s , ”Frequency o f o s c i l l a t i o n ( in rad/ sec )=” )
Example 10.12 10.12.sci
1 ieee (2 ) ;2 syms p K s ;3 m=sˆ3+(p∗ s ˆ2)+(K+3)∗ s +(2∗(K+1) )4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;7 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;8 r=[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ]9 n=length ( r ) ;
10 routh=[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;
61
11 routh=[ routh ;−det ( routh ) / routh (2 , 1 ) , 0 ] ;12 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e s u b b l o c k o f
1 ieee (2 ) ;2 s=%s ;3 m=2∗s ˆ4+(4∗ s ˆ2)+14 routh=routh t (m) / / G e n e r a t e s t h e R o u t h T a b l e
5 roots (m) / / 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 )
6 disp (0 , ” the number o f r oo t s l y i n g in the l e f t h a l fp lane o f s−plane=” )
7 disp (0 , ” the number o f r oo t s l y i n g in the r i g h t h a l fp lane o f s−plane=” )
8 disp (4 , ” the number o f r oo t s l y i n g on the imaginary ax i s=” )
Example 10.14 10.14.sci
1 ieee (2 ) ;2 syms s k ;3 m=sˆ4+6∗ s ˆ3+10∗ s ˆ2+8∗ s+k ;4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;7 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;8 c o f a 4 = c o e f f s (m, ’ s ’ , 4 ) ;9 r=[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 c o f a 4 ]
1 ieee (2 ) ;2 syms s T;3 m=sˆ2+(2−T)∗ s+14 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;7 r=[ c o f a 0 c o f a 1 c o f a 2 ]8 n=length ( r ) ;9 routh=[ r ( [ 3 , 1 ] ) ; r (2 ) , 0 ] ;
1 ieee (2 )2 s=%s ;3 m=sˆ6+2∗ s ˆ5+7∗ s ˆ4+10∗ s ˆ3+14∗ s ˆ2+8∗ s+84 routh=routh t (m) ;5 disp ( routh , ” routh=” )6 c=0;7 for i =1:n8 i f ( routh ( i , 1 ) <0)9 c=c+1;
10 end11 end12 i f ( c>=1)13 printf ( ” system i s unstab le ” )14 else ( ” system i s s t ab l e ” )15 end
63
Chapter 11
Root Locus Method
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox
When we will execute the programm we will get the following Graphs
11.1 Scilab Code
Example 11.01 11.01.sci
1 s=%s ;2 sys1=sysl in ( ’ c ’ , 1/( s+1) ) ;3 evans ( sys1 , 200 )4 printf ( ” I f k i s var i ed from 0 to any value , root l o cu s
v a r i e s from −k to 0 \n ” )
Example 11.02 11.02.sci
1 s=%s ;2 sys1=sysl in ( ’ c ’ , ( s+1)/( s+4) ) ;3 evans ( sys1 , 100 )4 printf ( ” r o o t l o cu s beg ins at s=−4 & ends at s=−1” )
Example 11.03 11.03.sci
64
Figure 11.1: Output Graph of S 11.01
1 s=%s ;2 sys1=sysl in ( ’ c ’ , ( s+3−%i) ∗( s+3+%i) / ( ( s+2−%i) ∗( s+2+%i) ) ) ;3 evans ( sys1 , 100 )4 printf ( ”Root locus s t a r t s from s=−2+i & −2− i ends at s
=−3+i &−3− i \n” )
Example 11.04 11.04.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , ( s+1)/( s+2) ) ;3 evans (H, 100 )
65
Figure 11.2: Output Graph of S 11.02
4 printf ( ” C l ea r l y from the graph i t observed that g ivenpo int −1+i & −3+i does not l i e on the root l o cu s \n
” )5 / / t h e r e i s a n o t h e r p r o c e s s t o c h e c k w h e t h e r t h e p o i n t s
l i e o n t h e l o c u s o f t h e s y s t e m
6 P=−1+%i ; / / P= s e l e c t e d p o i n t
7 k1=−1/real (horner (H,P) )8 Ns=H( ’num ’ ) ; Ds=H( ’ den ’ ) ;9 roots (Ds+k1∗Ns) / / d o e s n o t c o n t a i n s P a s p a r t i c u l a r
r o o t
10 P=−3+%i ; / / P= s e l e c t e d p o i n t
11 k2=−1/real (horner (H,P) ) ;
66
Figure 11.3: Output Graph of S 11.03
12 Ns=H( ’num ’ ) ; Ds=H( ’ den ’ )13 roots (Ds+k2∗Ns) / / d o e s n o t c o n t a i n s P a s p a r t i c u l a r
r o o t
Example 11.05 11.05.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , 1/( s ∗( s+1)∗( s+3) ) ) ;3 evans (H, 100 )4 printf ( ” C l ea r l y from the graph i t observed that g iven
po int −0.85 l i e s on the root l o cu s \n” )
67
Figure 11.4: Output of S 11.04
5 / / t h e r e i s a n o t h e r p r o c e s s t o c h e c k w h e t h e r t h e p o i n t s
10 r oo t s (Ds+k∗Ns) // conta in s P as p a r t i c u l a r root
68
Figure 11.5: Output of S 11.05
Example 11.06 11.06.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , 1/ ( ( s+1)∗( s+5) ) ) ;3 evans (H, 100 )4 printf ( ” C l ea r l y from the graph i t observed that g iven
po int −0.85 l i e s on the root l o cu s \n” )5 / / t h e r e i s a n o t h e r p r o c e s s t o c h e c k w h e t h e r t h e p o i n t s
l i e o n t h e l o c u s o f t h e s y s t e m
6 P=−3+5∗%i ; / / P= s e l e c t e d p o i n t
7 k=−1/real (horner (H,P) ) ;8 disp (k , ”k= ’)
69
Figure 11.6: Output of S 11.06
9 Ns=H( ’num’ ) ; Ds=H( ’ den ’ ) ;10 r oo t s (Ds+k∗Ns) // conta in s P as p a r t i c u l a r root
Example 11.08 11.08.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , ( s+2) / ( ( s+1)∗ s ∗( s+4) ) ) ;3 evans (H, 100 )4 printf ( ”From the graph we observed that , \n a )The no o f
l o c i ending at i n f i s 2 \n b) Three l o c i w i l l s t a r tfrom s= 0,−1 & −4,\n c )One l o c i w i l l end at −2 &
70
Figure 11.7: Output of S 11.08
remaining two w i l l end at i n f ” )
Example 11.09 11.09.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , ( s+2) / ( ( s+1)∗ s ∗( s+4) ) ) ;3 evans (H, 100 )
Example 11.10 11.10.sci
1 n=3;
71
Figure 11.8: Output of S 11.09
2 disp (n , ”no o f po l e s=” )3 m=1;4 disp (m, ”no o f po l e s=” )5 q=0;6 O=((2∗q )+1)/(n−m) ∗180 ;7 disp (O, ”q=” )8 q=1;9 O=((2∗q )+1)/(n−m) ∗180 ;
10 disp (O, ”q=” )11
12 printf ( ”Centroid =((sum of a l l r e a l part o f po l e s o f G( s)H( s ) )−(sum of a l l r e a l part o f z e r o s o f G( s )H( s ) ) /(
72
n−m) \n” )13 C=((0−1−4)−(−2)) /2 ;14 disp (C, ” c en t r o id=” )
Example 11.11 11.11.sci
1 n=3;2 disp (n , ”no o f po l e s=” )3 m=0;4 disp (m, ”no o f po l e s=” )5 q=0;6 O=((2∗q )+1)/(n−m) ∗180 ;7 disp (O, ”q=” )8 q=1;9 O=((2∗q )+1)/(n−m) ∗180 ;
15 printf ( ”Centroid =((sum of a l l r e a l part o f po l e s o f G( s)H( s ) )−(sum of a l l r e a l part o f z e r o s o f G( s )H( s ) ) /(n−m) \n” )
16 C=((0−1−1)−(−0)) /3 ;17 disp (C, ” c en t r o id=” )
Example 11.12 11.12.sci
1 n=4;2 disp (n , ”no o f po l e s=” )3 m=1;4 disp (m, ”no o f po l e s=” )5 q=0;6 O=((2∗q )+1)/(n−m) ∗180 ;7 disp (O, ”q=” )8 q=1;9 O=((2∗q )+1)/(n−m) ∗180 ;
15 printf ( ”Centroid =((sum of a l l r e a l part o f po l e s o f G( s)H( s ) )−(sum of a l l r e a l part o f z e r o s o f G( s )H( s ) ) /(n−m) \n” )
16 C=((0−2−4−5)−(−3)) /3 ;17 disp (C, ” c en t r o id=” )
Example 11.13 11.13.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , ( s+2) / ( ( s+1)∗ s ∗( s+3) ) ) ;3 plzr (H)4 printf ( ”There are two adjacent p laced po l e s at s=0 &s
=−1 \n” )5 printf ( ”One breakaway po int e x i s t s between s=0 & s=−1 \
n” )
Example 11.14 11.14.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , ( ( s+2)∗( s+4) ) / ( ( s ˆ2) ∗( s+5) ) ) ;3 plzr (H)4 printf ( ”There are two adjacent p laced z e ro s at s=−2 &s
=−4 \n” )5 printf ( ”One break in po int e x i s t s between s=−2 & s=−4 \n
” )
Example 11.15 11.15.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , ( s+6) / ( ( s+1)∗( s+3) ) ) ;3 plzr (H)4 printf ( ”There are two adjacent p laced po l e s at s=−3 &s
=−1 \n” )
74
Figure 11.9: Output of S 11.13
5 printf ( ”One breakaway po int e x i s t s between s=−3 & s=−1\n” )
6 printf ( ”One break in po int e x i s t s to the l e f t o f z e r o sat s=−6 \n” )
Example 11.16 11.16.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , 1/ ( ( s+1)∗ s ∗( s+3) ) ) ;3 plzr (H)4 printf ( ”There are two adjacent p laced po l e s at s=0 &s
75
Figure 11.10: Output of S 11.14
=−1 \n” )5 printf ( ”One breakaway po int e x i s t s between s=0 & s=−1 \
n” )
Example 11.17 11.17.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , 1/ ( ( s+1)∗ s ∗( s+3) ) ) ;3 evans (H, 100 )4 syms k ;5 m=sˆ3+6∗ s ˆ2+8∗ s+k ;
76
Figure 11.11: Output of S 11.15
6 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;7 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;8 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;9 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;
10 r=[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ]11
12 n=length ( r ) ;13 routh=[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;14 routh=[ routh ;−det ( routh ) / routh (2 , 1 ) , 0 ] ;15 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e s u b b l o c k o f
r o u t h m a t r i x
16 routh=[ routh ;−det ( t ) / t ( 2 , 1 ) , 0 ]
77
Figure 11.12: Output of S 11.16
17 disp (48 , ”K( marginal )=” )18 disp ( ’=0 ’ , (6∗ s ˆ2)+k , ” a ux i l l a r y equat ion ” )19 k=48;20 s=sqrt(−k/6) ;21 disp ( s , ” s=” )
Example 11.19 11.19.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , 1/ ( ( s+1+%i )∗ s ∗( s+1−%i) ) ) ;3 evans (H, 100 )
78
Figure 11.13: Output of S 11.17
Example 11.20 11.20.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , 1/ ( ( s+3)∗ s ∗( s+5) ) ) ;3 evans (H, 100 )
1 s=%s ;2 num=real (poly ( [ 1 ] , ’ s ’ , ” c o e f f ” ) )3 den=real (poly([−1,−2+%i,−2−%i ] , ’ s ’ ) )4 H=num/den5 evans (H, 100 )6 k=1.5 ;7 disp (k , ”K( des ign )=” )8 / / K p u r e c a l c u l a t e s t h e v a l u e o f k a t i m a g i n a r y
c r o s s o v e r
9 [K,Y]=kpure (H)
80
Figure 11.15: Output of S 11.20
10 GM=K/k ;11 disp (GM, ” value o f k at imaginary c r o s s ov e r /k ( des ign )=” )12 disp (GM, ” gain margin=” )
Example 11.23 11.23.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , 1/( s ∗ ( ( s+3)ˆ2) ) ) ;3 evans (H, 100 )4 K=25;5 y=K∗H; / / −−−−− e q 1 )
81
Figure 11.16: Output of S 11.21
6 disp (K∗H, ”G( s )H( s )=” ) ;7 disp ( ’=1 ’ ,K∗H, ”mod(G( s )H( s ) ) ” ) ;8 / / o n s o l v i n g e q 1 f o r s = % i ∗ w t h i s w e g e t a n e q u a t i o n m
1 s=%s ;2 syms k Wn;3 H=sysl in ( ’ c ’ , 1/ ( ( s+3)ˆ2∗ s ) ) ;4 evans (H, 100 ) / / r o o t l o c u s
5 printf ( ”To determine the value o f Wn \n” )6 disp ( k∗H, ”G( s )H( s )=” )7 y=1+(k∗H) ;8 disp ( ’=0 ’ , y , ”1+G( s )H( s ) ” )9 evans (H, 100 )
84
Figure 11.19: Output of S 11.25
10 [ num, den]=numden(y )11
12 c o f a 0 = c o e f f s (num, ’ s ’ , 0 ) ;13 c o f a 1 = c o e f f s (num, ’ s ’ , 1 ) ;14 c o f a 2 = c o e f f s (num, ’ s ’ , 2 ) ;15 c o f a 3 = c o e f f s (num, ’ s ’ , 3 ) ;16 r=[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ]17
18 n=length ( r ) ;19 routh=[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;20 routh=[ routh ;−det ( routh ) / routh (2 , 1 ) , 0 ] ;21 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e s u b b l o c k o f
85
Figure 11.20: Output of S 11.26
r o u t h m a t r i x
22 routh=[ routh ;−det ( t ) / t ( 2 , 1 ) , 0 ]23 / / t o o b t a i n Wn
24 disp ( ’=0 ’ , ( ( 6∗ s ˆ2)+54) , ” a u x i l l a r y eq” )25 p=(6∗( s ˆ2) )+k ;26 s=%i∗Wn27 k=54;28 p=eval (p)29 Wn=sqrt ( k/6)30 printf ( ”With gvn va lue s o f ze ta adding a g r id on root
l o cu s \n” )31
86
32 zeta =0.5 ; / / g i v e n
33 sgrid ( zeta ,Wn, 7 ) / / a d d a g r i d o v e r a n e x i s t i n g
c o n t i n u o u s s − p l a n e r o o t w i t h g i v e n v a l u e s f o r z e t a
a n d wn .
34 printf ( ”NOTE:− c l i c k on the po int where l o cu s i n t e r s e c t sz=0.5 f o r d e s i r ed value o f k \n” )
35 k=−1/real (horner (H, [ 1 , %i ]∗ locate (1 ) ) ) / / To o b t a i n t h e
g a i n a t a g i v e n p o i n t o f t h e l o c u s
36
37
38 p=locate (1 ) / / d e s i r e d p o i n t o n t h e r o o t l o c u s
Example 11.28 11.28.sci
1 s=%s ;2 H=sysl in ( ’ c ’ , 1/ ( ( s+4)∗ s ∗( s+6) ) ) ;3 evans (H, 100 )
87
Figure 11.21: Output of S 11.27
88
Figure 11.22: Output of S 11.28
89
Chapter 12
Frequency Domain Analysis
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox.
12.1 Scilab Code
Example 12.01 12.01.sci
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=sysl in ( ’ c ’ , [ 2 2 5 / ( ( s+6)∗ s ) ] ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 CL=F/ .B / / C a l c u l a t e s 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
5 / / c o m p a r e CL w i t h Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗Wn+Wn ˆ 2 )
6 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r o f CL
7 z=coeff ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s o f t h e
d e n o m i n a t o r p o l y n o m i a l
8 / / Wn ˆ 2 = z ( 1 , 1 ) , c o m p a r i n g t h e c o e f f i c i e n t s
9 Wn=sqrt ( z (1 , 1 ) ) / / Wn= n a t u r a l f r e q u e n c y
10 / / 2 ∗ z e t a ∗Wn= z ( 1 , 2 )
11 zeta=z (1 , 2 ) /(2∗Wn) / / z e t a = d a m p i n g f a c t o r
38 zeta=dbl ( eval ( ze ta ) ) ;39 disp ( zeta , ” zeta = ’)40 Ts=4/( zeta ∗Wn) ;41 di sp (Ts , ” S e t t l i n g Time (Ts )=” )42 Wc=Wn((1−(2∗ zeta ˆ2) )+sq r t (4∗ zeta ˆ4−4∗ zeta ˆ2+2) )43 di sp (Wc, ”BW=” )
94
Chapter 13
Bode Plot
When we will execute the programm we will get the following Graphs.
13.1 Scilab Code
Example 13.01 13.01.sci
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=sysl in ( ’ c ’ , [ 2 0 / ( s+2) ] ) / / C r e a t e s t r a n s f e r f u n c t i o n i n
f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 OL=F∗B / / C a l c u l a t e s o p e n − l o o p t r a n s f e r f u n c t i o n
5 fmin =0.1 ; / / M i n f r e q i n Hz
6 fmax=100; / / Max f r e q i n Hz
7 s c f (1 ) ; c l f ;8 bode(OL, fmin , fmax ) ; / / P l o t s f r e q u e n c y r e s p o n s e o f o p e n −
l o o p s y s t e m i n B o d e d i a g r a m
9 show margins (OL) / / d i s p l a y g a i n a n d p h a s e m a r g i n a n d
a s s o c i a t e d c r o s s o v e r f r e q u e n c i e s
Example 13.02 13.02.sci
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
95
Figure 13.1: Output of S 13.01
2 F=sysl in ( ’ c ’ , [20/((2+ s )∗ s ) ] ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 OL=F∗B; / / C a l c u l a t e s o p e n − l o o p t r a n s f e r f u n c t i o n
5 fmin =0.01; / / M i n f r e q i n Hz
6 fmax=20; / / Max f r e q i n Hz
7 s c f (1 ) ; c l f ;
96
Figure 13.2: Output of S 13.02
8 bode(OL, fmin , fmax ) ; / / P l o t s f r e q u e n c y r e s p o n s e o f o p e n −
l o o p s y s t e m i n B o d e d i a g r a m
9 show margins (OL) / / d i s p l a y g a i n a n d p h a s e m a r g i n a n d
a s s o c i a t e d c r o s s o v e r f r e q u e n c i e s
Example 13.03 13.03.sci
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=sysl in ( ’ c ’ , [40/((2+ s )∗ s ∗( s+5) ) ] ) / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
97
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 OL=F∗B; / / C a l c u l a t e s o p e n − l o o p t r a n s f e r f u n c t i o n
5 fmin =0.1 ; / / M i n f r e q i n Hz
6 fmax=20; / / Max f r e q i n Hz
7 s c f (1 ) ; c l f ;8 bode(OL, fmin , fmax ) ; / / P l o t s f r e q u e n c y r e s p o n s e o f o p e n −
l o o p s y s t e m i n B o d e d i a g r a m
9 [ GainMargin , freqGM]=g margin (OL) / / C a l c u l a t e s g a i n
m a r g i n [ dB ] a n d c o r r e s p o n d i n g f r e q u e n c y [ H z ]
10 [ Phase , freqPM]=p margin (OL) / / C a l c u l a t e s p h a s e [ d e g ]
a n d c o r r e s p o n d i n g f r e q [ H z ] o f p h a s e m a r g i n
11 PhaseMargin=180+Phase / / C a l c u l a t e s a c t u a l p h a s e m a r g i n
[ d e g ]
12 show margins (OL) / / d i s p l a y g a i n a n d p h a s e m a r g i n a n d
a s s o c i a t e d c r o s s o v e r f r e q u e n c i e s
Example 13.04 13.04.sci
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=sysl in ( ’ c ’ , [ 4 0 / ( ( s+5)∗(2+s )∗ s ˆ2) ] ) / / C r e a t e s t r a n s f e r
f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 OL=F∗B; / / C a l c u l a t e s o p e n − l o o p t r a n s f e r f u n c t i o n
5 fmin =0.1 ; / / M i n f r e q i n Hz
6 fmax=20; / / Max f r e q i n Hz
7 s c f (1 ) ; c l f ;8 bode(OL, fmin , fmax ) ; / / P l o t s f r e q u e n c y r e s p o n s e o f o p e n −
l o o p s y s t e m i n B o d e d i a g r a m
9 show margins (OL) / / d i s p l a y g a i n a n d p h a s e m a r g i n a n d
a s s o c i a t e d c r o s s o v e r f r e q u e n c i e s
Example 13.05 13.05.sci
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
98
Figure 13.3: Output of S 13.03
2 F=sysl in ( ’ c ’ , [ ( 4 0 0∗ ( s+2) ) / ( ( s+5)∗(10+ s )∗ s ˆ2) ] ) / /
C r e a t e s t r a n s f e r f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 OL=F∗B / / C a l c u l a t e s o p e n − l o o p t r a n s f e r f u n c t i o n
5 fmin =0.1 ; / / M i n f r e q i n Hz
6 fmax=20; / / Max f r e q i n Hz
7 s c f (1 ) ; c l f ;8 bode(OL, fmin , fmax ) ; / / P l o t s f r e q u e n c y r e s p o n s e o f o p e n −
l o o p s y s t e m i n B o d e d i a g r a m
9 show margins (OL) / / d i s p l a y g a i n a n d p h a s e m a r g i n a n d
a s s o c i a t e d c r o s s o v e r f r e q u e n c i e s
99
Figure 13.4: Output of S 13.04
Example 13.06 13.06.sci
1 s=poly (0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=sysl in ( ’ c ’ , [ ( 2 8 8∗ ( s+4) ) / ( ( s+2)∗(144+4.8∗ s+s ˆ2)∗ s ) ] )/ / C r e a t e s t r a n s f e r f u n c t i o n i n f o r w a r d p a t h
3 B=sysl in ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) / / C r e a t e s t r a n s f e r
f u n c t i o n i n b a c k w a r d p a t h
4 OL=F∗B / / C a l c u l a t e s o p e n − l o o p t r a n s f e r f u n c t i o n
5 fmin =0.1 ; / / M i n f r e q i n Hz
6 fmax=100; / / Max f r e q i n Hz
100
Figure 13.5: Output of S 13.05
7 s c f (1 ) ; c l f ;8 bode(OL, fmin , fmax ) ; / / P l o t s f r e q u e n c y r e s p o n s e o f o p e n −
l o o p s y s t e m i n B o d e d i a g r a m
9 show margins (OL) / / d i s p l a y g a i n a n d p h a s e m a r g i n a n d
a s s o c i a t e d c r o s s o v e r f r e q u e n c i e s
101
Figure 13.6: Output of S 13.06
102
Chapter 15
Nyquist Plot
When we will execute the programm we will get the following Graphs
15.1 Scilab Code
Example 15.01 15.01.sci
1 s=%s ;2 sys=sysl in ( ’ c ’ , 1/( s+2) )3 nyquist ( sys )4 show margins ( sys , ’ nyqu i s t ’ )5 printf ( ” S ince P=0(no o f po l e s in RHP)=Poles o f G( s )H( s )
\n here the number o f z e r o s o f 1+G( s )H( s ) in theRHP i s zero \n hence the system i s s t ab l e ” )
Example 15.02 15.02.sci
1 s=%s ;2 sys=sysl in ( ’ c ’ , 1/( s ∗( s+2) ) )3 nyquist ( sys )4 show margins ( sys , ’ nyqu i s t ’ )5 printf ( ” S ince P=0(no o f po l e s in RHP)=Poles o f G( s )H( s )
\n here the number o f z e r o s o f 1+G( s )H( s ) in theRHP i s zero \n hence the system i s s t ab l e ” )
103
Figure 15.1: Output of S 15.01
Example 15.03 15.03.sci
1 s=%s ;2 sys=sysl in ( ’ c ’ , 1/( s ˆ2∗( s+2) ) )3 nyquist ( sys )4 show margins ( sys , ’ nyqu i s t ’ )5 printf ( ” S ince P=0(no o f po l e s in RHP)=Poles o f G( s )H( s )
\n here the number o f z e r o s o f 1+G( s )H( s ) in the
104
Figure 15.2: Output of S 15.02
RHP i s not equal to zero \n hence the system i sunstab le ” )
Example 15.04 15.04.sci
1 s=%s ;2 sys=sysl in ( ’ c ’ , 1/( s ˆ3∗( s+2) ) )3 nyquist ( sys )4 show margins ( sys , ’ nyqu i s t ’ )5 printf ( ” S ince P=0(no o f po l e s in RHP)=Poles o f G( s )H( s )
\n here the number o f z e r o s o f 1+G( s )H( s ) in the
105
Figure 15.3: Output of S 15.03
RHP i s N>0 \n hence the system i s unstab le ” )
Example 15.05 15.05.sci
1 s=%s ;2 sys=sysl in ( ’ c ’ , 1/( s ˆ2∗( s+2) ) )3 nyquist ( sys )4 show margins ( sys , ’ nyqu i s t ’ )5 printf ( ” S ince P=0(no o f po l e s in RHP)=Poles o f G( s )H( s )
\n here the number o f z e r o s o f 1+G( s )H( s ) in theRHP i s N>0 \n hence the system i s unstab le ” )
106
Figure 15.4: Output of S 15.04
Example 15.06 15.06.sci
1 s=%s ;2 P1=1;3 P2=2;4 sys=sysl in ( ’ c ’ , 1/ ( ( s+1)∗( s+2) ) )5 nyquist ( sys )6 show margins ( sys , ’ nyqu i s t ’ )7 printf ( ” S ince P=0(no o f po l e s in RHP)=Poles o f G( s )H( s )
\n\n Here the number o f z e r o s o f 1+G( s )H( s ) in theRHP i s zero \n\n Hence the system i s s t ab l e ” )
107
Figure 15.5: Output of S 15.05
Example 15.07 15.07.sci
1 s=%s ;2 sys=sysl in ( ’ c ’ ,12/( s ∗( s+1)∗( s+2) ) )3 nyquist ( sys )4 show margins ( sys , ’ nyqu i s t ’ )5 gm=g margin ( sys )6 i f (gm<=0)7 printf ( ” system i s unstab le ” )8 else9 printf ( ” system i s s t ab l e ” ) ; end ;
108
Figure 15.6: Output of S 15.06
Example 15.08 15.08.sci
1 s=%s ;2 sys=sysl in ( ’ c ’ , ( 30 ) / ( ( s ˆ2+2∗ s+2)∗( s+3) ) )3 nyquist ( sys )4 gm=g margin ( sys )5 show margins ( sys , ’ nyqu i s t ’ )6 printf ( ” S ince P=0(no o f po l e s in RHP)=Poles o f G( s )H( s )
\n Here the number o f z e r o s o f 1+G( s )H( s ) in theRHP i s zero \n Hence the system i s s t ab l e ” )
7 i f (gm<=0)8 printf ( ” system i s unstab le ” )
109
Figure 15.7: Output of S 15.07
9 else10 printf ( ” system i s s t ab l e ” )11 end
110
Figure 15.8: Output of S 15.08
111
Chapter 17
State Variable Approach
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-tutorial.org) for the installation of Symbolic Toolbox.
17.1 Scilab Code
Example 17.03 17.03.sci
1 s=%s ;2 / / C r e a t i n g c o n t − t i m e t r a n s f e r f u n c t i o n
3 TFcont=sysl in ( ’ c ’ , 3/( s ˆ4+(2∗ s ˆ3)+(3∗ s )+2) )4 SScont=t f2ss (TFcont )5 / / CCF f o r m
6 [ Ac , Bc ,U, ind ]=canon ( SScont (2 ) , SScon (3 ) )
Example 17.04 17.04.sci
1 s=%s ;2 TFcont=sysl in ( ’ c ’ , [ ( 7 + 2∗ s + 3∗( s ˆ2) ) /(5 + 12∗ s + 5∗( s
ˆ2) + s ˆ3 ) ] )3 SScont=t f2ss (TFcont )4 [ Ac , Bc ,U, ind ]=canon ( SScont (2 ) , SScont (3 ) )
Example 17.06 17.06.sci
112
1 s=%s ;2 / / C r e a t i n g c o n t − t i m e t r a n s f e r f u n c t i o n
3 TFcont=sysl in ( ’ c ’ , [ ( 5 ∗ ( s+1)∗( s+2) ) / ( ( s+4)∗( s+5) ) ] )4 SScont=t f2ss (TFcont )5 / / CCF f o r m
6 [ Ac , Bc ,U, ind ]=canon ( SScont (2 ) , SScont (3 ) )
Example 17.07 17.07.sci
1 s=%s ;2 / / C r e a t i n g c o n t − t i m e t r a n s f e r f u n c t i o n
3 TFcont=sysl in ( ’ c ’ , ( s+1) / ( ( s+2)∗( s+5)∗( s+3) ) )4 SScont=t f2ss (TFcont )5 / / CCF f o r m
6 [ Ac , Bc ,U, ind ]=canon ( SScont (2 ) , SScont (3 ) )
Example 17.08 17.08.sci
1 s=%s ;2 / / C r e a t i n g c o n t − t i m e t r a n s f e r f u n c t i o n
3 TFcont=sysl in ( ’ c ’ , ( 6 ) / ( ( s+2)ˆ2∗( s+1) ) )4 SScont=t f2ss (TFcont )5 / / CCF f o r m
6 [ Ac , Bc ,U, ind ]=canon ( SScont (2 ) , SScont (3 ) )
Example 17.09 17.09.sci
1 A=[0 1;−6 −5]2 [Row Col ]= s ize (A) / / S i z e o f a m a t r i x
3 l=poly (0 , ’ l ’ ) ;4 m=l ∗eye (Row, Col )−A / / l I −A
5 n=det (m) / / To F i n d T h e D e t e r m i n a n t o f l i −A
6 roots (n) / / To F i n d T h e V a l u e O f l
Example 17.10 17.10.sci
1 A=[−2 1 ;0 −3]
113
2 B=[0 ; 1 ]3 C=[1 1 ]4 s=poly (0 , ’ s ’ ) ;5 [Row Col ]= s ize (A) / / S i z e o f a m a t r i x
6 m=s∗eye (Row, Col )−A / / s I −A
7 n=det (m) / / To F i n d T h e D e t e r m i n a n t o f s i −A
8 p=inv (m) / / To F i n d T h e I n v e r s e O f s I −A
9 y=C∗p∗B ; / / To F i n d C ∗ ( s I −A ) ˆ − 1 ∗ B
10 disp (y , ” Trans fe r Function=” )
Example 17.11 17.11.sci
1 A=[0 1;−6 −5]2 x = [ 1 ; 0 ] ;3 disp (x , ”x ( t ) = ’)4 s=poly (0 , ’ s ’ ) ;5 [Row Col ]= s i z e (A) // S i z e o f a matrix6 m=s∗ eye (Row, Col )−A // sI−A7 n=det (m) //To Find The Determinant o f s i−A8 p=inv (m) ; // To Find The Inve r s e Of sI−A9 syms t s ;
10 di sp (p , ” phi ( s )=” ) // Resolvent Matrix11 f o r i =1:Row12 f o r j =1:Col13 //Taking Inve r s e Laplace o f each element o f Matrix phi (
s )14 q ( i , j )=i l a p l a c e (p( i , j ) , s , t ) ;15 end ;16 end ;17 di sp (q , ” phi ( t )=” ) // State Trans i t i on Matrix18 r=inv (q ) ;19 r=s imple ( r ) ; //To Find phi(−t )20 di sp ( r , ” phi(−t )=” )21 y=q∗x ; //x ( t )=phi ( t )∗x (0 )22 di sp (y , ” So lu t i on To The given eq .=” )
Example 17.12 17.12.sci
114
1 A=[0 1;−6 −5]2 B=[0 ; 1 ]3 x = [1 ; 0 ]4 disp (x , ”x ( t ) = ’)5 s=poly (0 , ’ s ’ ) ;6 [Row Col ]= s i z e (A) // S i z e o f a matrix A7 m=s∗ eye (Row, Col )−A // sI−A8 n=det (m) //To Find The Determinant o f s i−A9 p=inv (m) ; // To Find The Inve r s e Of sI−A
10 syms t s m;11 di sp (p , ” phi ( s )=” ) // Resolvent Matrix12 f o r i =1:Row13 f o r j =1:Col14 // Inve r s e Laplace o f each element o f Matrix ( phi ( s ) )15 q ( i , j )=i l a p l a c e (p( i , j ) , s , t ) ;16 end ;17 end ;18 di sp (q , ” phi ( t )=” ) // State Trans i t i on Matrix19 t=(t−m) ;20 q=eva l ( q ) //At t=t−m , eva lua t ing q i . e phi ( t−m)21 // In t e g r a t e q w. r . t m( I n d e f i n i t e I n t e g r a t i on )22 r=in t eg (q∗B,m)23 m=0 //Upper l im i t i s t24 g=eva l ( r ) // Putting the value o f upper l im i t in q25 m=t //Lower Limit i s 026 h=eva l ( r ) // Putt ing the value o f lower l im i t in q27 y=(h−g ) ;28 di sp (y , ”y=” )29 p r i n t f ( ”x ( t )= phi ( t )∗x (0 ) + in t eg ( phi ( t−m)∗B) w. r . t m
from 0 t0 t \n” )30 //x ( t )=phi ( t )∗x (0 )+in t eg ( phi ( t−m)∗B) w. r . t m from 0 t0
t31 y1=(q∗x )+y ;32 di sp ( y1 , ”x ( t )=” )
Example 17.13 17.13.sci
1 A=[3 0 ;2 4 ]
115
2 B=[0 ; 1 ]3 Cc=cont mat (A,B) ;4 disp (Cc , ” Con t r o l a b i l i t y Matrix=” )5 / / To C h e c k W h e t h e r t h e m a t r i x ( C c ) i s s i n g u l a r i . e
d e t e r m i n t o f C c =0
6 i f determ(Cc)==0;7 printf ( ” S ince the matrix i s S ingular , the system i s
not c o n t r o l l a b l e \n” ) ;8 else ;9 printf ( ”The system i s c o n t r o l l a b l e \n” )
10 end ;
Example 17.14 17.14.sci
1 A=[−2 1 ;0 −3]2 B=[4 ; 1 ]3 C=[1 0 ]4 [O]=obsv mat (A,C) ;5 disp (O, ” Obse rvab i l i t y Matrix=” )6 / / To C h e c k W h e t h e r t h e m a t r i x ( C c ) i s s i n g u l a r i . e
d e t e r m i n t o f C c =0
7 i f determ(O)==0;8 printf ( ” S ince the matrix i s S ingular , the system i s not
Observable \n” ) ;9 else ;
10 printf ( ”The system i s Observable \n” )11 end ;
Example 17.16 17.16.sci
1 s=%s ;2 / / C r e a t i n g c o n t − t i m e t r a n s f e r f u n c t i o n
3 TFcont=sysl in ( ’ c ’ , ( ( 5∗ s ˆ2)+(2∗ s )+6)/( s ˆ3+(7∗ s ˆ2)+(11∗ s )+8) )
4 SScont=t f2ss (TFcont )5 / / CCF f o r m
6 [ Ac , Bc ,U, ind ]=canon ( SScont (2 ) , SScont (3 ) )
116
Example 17.17 17.17.sci
1 s=%s ;2 / / C r e a t i n g c o n t − t i m e t r a n s f e r f u n c t i o n
3 TFcont=sysl in ( ’ c ’ , ( 8 ) /( s ∗( s+2)∗( s+3) ) )4 SScont=t f2ss (TFcont )5 / / CCF f o r m
6 [ Ac , Bc ,U, ind ]=canon ( SScont (2 ) , SScont (3 ) )
Example 17.18 17.18.sci
1 A=[0 1;−3 −4]2 x = [ 1 ; 0 ] ;3 disp (x , ”x ( t ) = ’)4 s=poly (0 , ’ s ’ ) ;5 [Row Col ]= s i z e (A) // S i z e o f a matrix6 m=s∗ eye (Row, Col )−A // sI−A7 n=det (m) //To Find The Determinant o f s i−A8 p=inv (m) ;// To Find The Inve r s e Of sI−A9 syms t s ;
10 di sp (p , ” phi ( s )=” ) // Resolvent Matrix11 f o r i =1:Row12 f o r j =1:Col13 //Taking Inve r s e Laplace o f each element o f Matrix phi (
s )14 q ( i , j )=i l a p l a c e (p( i , j ) , s , t ) ;15 end ;16 end ;17 di sp (q , ” phi ( t )=” ) // State Trans i t i on Matrix18 r=inv (q ) ;19 r=s imple ( r ) ; //To Find phi(−t )20 di sp ( r , ” phi(−t )=” )
Example 17.19 17.19.sci
1 A=[0 1;−3 −4]2 B=[0 ; 1 ]3 C=[1 0 ]
117
4 x = [0 ; 0 ]5 disp (x , ”x ( t ) = ’)6 s=poly (0 , ’ s ’ ) ;7 [Row Col ]= s i z e (A) // S i z e o f a matrix A8 m=s∗ eye (Row, Col )−A // sI−A9 n=det (m) //To Find The Determinant o f s i−A
10 p=inv (m) ; // To Find The Inve r s e Of sI−A11 syms t s m;12 di sp (p , ” phi ( s )=” ) // Resolvent Matrix13 f o r i =1:Row14 f o r j =1:Col15 //Taking Inve r s e Laplace o f each element o f Matrix ( phi (
s ) )16 q ( i , j )=i l a p l a c e (p( i , j ) , s , t ) ;17 end ;18 end ;19 di sp (q , ” phi ( t )=” ) // State Trans i t i on Matrix20 t=(t−m)21 q=eva l ( q ) //At t=t−m , eva lua t ing q i . e phi ( t−m)22 r=in t eg (q∗B,m) // In t e g r a t e q w. r . t m ( I n d e f i n i t e
I n t e g r a t i on )23 m=0 //Upper l im i t i s t24 g=eva l ( r ) // Putting the value o f upper l im i t in q25 m=t //Lower Limit i s 026 h=eva l ( r ) // Putt ing the value o f lower l im i t in q27 y=(h−g ) ;28 p r i n t f ( ”x ( t )= phi ( t )∗x (0 ) + in t eg ( phi ( t−m)∗B) w. r . t m
from 0 t0 t \n” )29 //x ( t )=phi ( t )∗x (0 ) + in t eg ( phi ( t−m)∗B) w. r . t m from 0
t0 t30 y1=(q∗x )+y ;31 di sp ( y1 , ”x ( t )=” )32 y2=C∗y1 ;33 di sp ( y2 , ”Output Response=” )
Example 17.20 17.20.sci
1 A=[0 1;−2 0 ]
118
2 B=[0 ; 3 ]3 Cc=cont mat (A,B) ;4 disp (Cc , ” Con t r o l a b i l i t y Matrix=” )5 / / To C h e c k W h e t h e r t h e m a t r i x ( C c ) i s s i n g u l a r i . e
d e t e r m i n t o f C c =0
6 i f determ(Cc)==0;7 printf ( ” S ince the matrix i s S ingular , the system i s not
c o n t r o l l a b l e \n” ) ;8 else ;9 printf ( ”The system i s c o n t r o l l a b l e \n” )
10 end ;
Example 17.21 17.21.sci
1 A=[−3 0 ;0 −2]2 B=[4 ; 1 ]3 C=[2 0 ]4 [O]=obsv mat (A,C) ;5 disp (O, ” Obse rvab i l i t y Matrix=” )6 / / To C h e c k W h e t h e r t h e m a t r i x ( C c ) i s s i n g u l a r i . e
d e t e r m i n t o f C c =0
7 i f determ(O)==0;8 printf ( ” S ince the matrix i s S ingular , the system i s not
Observable \n” ) ;9 else ;
10 printf ( ”The system i s Observable \n” )11 end ;
Example 17.22 17.22.sci
1 ieee (2 )2 A=[−3 0 0 ;0 −1 1 ; 0 0 −1]3 B= [ 0 ; 1 ; 0 ]4 s=poly (0 , ’ s ’ ) ;5 [Row Col ]= s ize (A) / / S i z e o f a m a t r i x
6 m=s∗eye (Row, Col )−A / / s I −A
7 n=det (m) / / To F i n d T h e D e t e r m i n a n t o f s i −A
8 p=inv (m) ; / / To F i n d T h e I n v e r s e O f s I −A
119
9 syms t s ;10 disp (p , ” phi ( s )=” ) / / R e s o l v e n t M a t r i x
Example 17.23 17.23.sci
1 A=[−2 0 ;1 −1]2 B=[0 ; 1 ]3 x = [0 ; 0 ]4 disp (x , ”x ( t ) = ’)5 s=poly (0 , ’ s ’ ) ;6 [Row Col ]= s i z e (A) // S i z e o f a matrix A7 m=s∗ eye (Row, Col )−A // sI−A8 n=det (m) //To Find The Determinant o f s i−A9 p=inv (m) ; // To Find The Inve r s e Of sI−A
10 syms t s m;11 di sp (p , ” phi ( s )=” ) // Resolvent Matrix12 t=(t−m)13 q=eva l ( q ) //At t=t−m , eva lua t ing q i . e phi ( t−m)14 // In t e g r a t e q w. r . t m ( I n d e f i n i t e I n t e g r a t i on )15 r=in t eg (q∗B,m)16 m=0 //Upper l im i t i s t17 g=eva l ( r ) // Putting the value o f upper l im i t in q18 m=t //Lower Limit i s 019 h=eva l ( r ) // Putt ing the value o f lower l im i t in q20 y=(h−g ) ;21 di sp (y , ”y=” )22 p r i n t f ( ”x ( t )= phi ( t )∗x (0 ) + in t eg ( phi ( t−m)∗B) w. r . t m
from 0 t0 t \n” )23 //x ( t )=phi ( t )∗x (0 )+in t eg ( phi ( t−m)∗B)w. r . t m from 0 t0 t24 y1=(q∗x )+y ;25 di sp ( y1 , ”x ( t )=” )26 // CONTROLABILITY OF THE SYSTEM27 Cc=cont mat (A,B) ;28 di sp (Cc , ” Con t r o l a b i l i t y Matrix=” )29 //To Check Whether the matrix (Cc) i s s i n gu l a r i . e
determint o f Cc=030 i f determ (Cc)==0;
120
31 p r i n t f ( ” S ince the matrix i s S ingular , the system i s notc o n t r o l l a b l e \n” ) ;
32 e l s e ;33 p r i n t f ( ”The system i s c o n t r o l l a b l e \n” )34 end ;
121
Chapter 18
Digital Control Systems
For the execution of the programm keep the main programm and the Func-tion in the same folder.
18.1 Scilab Code
Example F3 ztransfer.sce
1 function [ Z t r an s f e r ]= z t r a n s f e r ( sequence )2 z = poly (0 , ’ z ’ , ’ r ’ )3 Zt r an s f e r=sequence ∗(1/ z ) ˆ [ 0 : ( length ( sequence )−1) ] ’4 endfunction