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
Book Details
Authors: Smarajit Ghosh
Title: Control Systems
Publisher: Pearson Education
Edition: 2nd
Year: 2009
Place: New Delhi
ISBN: 978-81-317-0828-6
1
Contents
List of Scilab Code 4
2 Laplace Transform and Matrix Algebra 112.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3 Transfer Function 143.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4 Control system Components 174.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6 Control system Components 216.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
8 Time Domain Analysis of Control Systems 298.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
9 Feedback Characteristics of control Systems 449.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
10 Stability 5410.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
11 Root Locus Method 6411.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
12 Frequency Domain Analysis 9012.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
2
13 Bode Plot 9513.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
15 Nyquist Plot 10315.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
17 State Variable Approach 11217.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
18 Digital Control Systems 12218.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
3
List of Scilab Code
2.01-01 2.01.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 112.01-02 2.01.02sci . . . . . . . . . . . . . . . . . . . . . . . . . . 112.01-03 2.01.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 112.03 2.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.04 2.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.05-01 2.05.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 122.05-02 2.05.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 122.06 2.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.11 2.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.13 2.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.02 3.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.03 3.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.04 3.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.15 3.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.16 3.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.17 3.17.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.18 3.18.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.19 3.19.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.23 3.23.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.01 4.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.02 4.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.03 4.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.04 4.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.05 4.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19F1 parallel.sce . . . . . . . . . . . . . . . . . . . . . . . . . 21F2 serial.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . 216.01 6.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216.02 6.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4
6.03 6.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226.04 6.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236.05 6.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236.06 6.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236.07 6.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236.08 6.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246.09 6.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246.10 6.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256.11 6.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256.12 6.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266.13 6.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266.14 6.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276.15 6.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278.02 8.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298.03-01 8.03.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 298.03-02 8.03.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 308.03-03 8.03.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 308.04 8.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318.05 8.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318.06 8.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328.07 8.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328.08 8.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338.09 8.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348.10 8.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348.11 8.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358.12 8.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358.13 8.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368.14 8.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368.15 8.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378.16 8.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378.17 8.17.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388.19 8.19.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398.20 8.20.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398.23-01 8.23.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 408.23-02 8.23.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 408.23-03 8.23.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 418.23-04 8.23.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 418.24 8.24.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5
8.32 8.32.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429.01 9.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449.02 9.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459.03 9.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459.04 9.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469.05 9.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479.06 9.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479.07 9.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489.08 9.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499.09 9.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509.10 9.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519.11 9.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5210.02-01 10.02.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . 5410.02-02 10.02.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . 5410.02-03 10.02.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . 5510.03 10.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 5510.04 10.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 5610.05-01 10.05.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . 5610.05-02 10.05.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . 5710.06 10.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 5710.07 10.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 5810.08 10.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 5910.09 10.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 5910.10 10.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6010.11 10.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6110.12 10.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6110.13 10.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6210.14 10.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6210.15 10.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6310.16 10.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6311.01 11.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6411.02 11.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6411.03 11.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6411.04 11.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6511.05 11.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6711.06 11.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 6911.08 11.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7011.09 11.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6
11.10 11.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7111.11 11.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7311.12 11.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7311.13 11.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7411.14 11.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7411.15 11.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7411.16 11.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7511.17 11.17.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7611.19 11.19.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7811.20 11.20.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7911.21 11.21.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 7911.22 11.22.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 8011.23 11.23.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 8111.25 11.25.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 8211.26 11.26.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 8311.27 11.27.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 8411.28 11.28.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 8712.01 12.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9012.02 12.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9112.03 12.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9112.04 12.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9212.05 12.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9213.01 13.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9513.02 13.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9513.03 13.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9713.04 13.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9813.05 13.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 9813.06 13.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10015.01 15.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10315.02 15.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10315.03 15.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10415.04 15.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10515.05 15.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10615.06 15.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10715.07 15.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10815.08 15.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 10917.03 17.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11217.04 17.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
7
17.06 17.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11217.07 17.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11317.08 17.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11317.09 17.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11317.10 17.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11317.11 17.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11417.12 17.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11417.13 17.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11517.14 17.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11617.16 17.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11617.17 17.17.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11717.18 17.18.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11717.19 17.19.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11717.20 17.20.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11817.21 17.21.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11917.22 17.22.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 11917.23 17.23.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 120F3 ztransfer.sce . . . . . . . . . . . . . . . . . . . . . . . . . 12218.01 18.01.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . 12218.08 18.08.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . 122
8
List of Figures
11.1 Output Graph of S 11.01 . . . . . . . . . . . . . . . . . . . . 6511.2 Output Graph of S 11.02 . . . . . . . . . . . . . . . . . . . . 6611.3 Output Graph of S 11.03 . . . . . . . . . . . . . . . . . . . . 6711.4 Output of S 11.04 . . . . . . . . . . . . . . . . . . . . . . . . 6811.5 Output of S 11.05 . . . . . . . . . . . . . . . . . . . . . . . . 6911.6 Output of S 11.06 . . . . . . . . . . . . . . . . . . . . . . . . 7011.7 Output of S 11.08 . . . . . . . . . . . . . . . . . . . . . . . . 7111.8 Output of S 11.09 . . . . . . . . . . . . . . . . . . . . . . . . 7211.9 Output of S 11.13 . . . . . . . . . . . . . . . . . . . . . . . . 7511.10Output of S 11.14 . . . . . . . . . . . . . . . . . . . . . . . . 7611.11Output of S 11.15 . . . . . . . . . . . . . . . . . . . . . . . . 7711.12Output of S 11.16 . . . . . . . . . . . . . . . . . . . . . . . . 7811.13Output of S 11.17 . . . . . . . . . . . . . . . . . . . . . . . . 7911.14Output of S 11.19 . . . . . . . . . . . . . . . . . . . . . . . . 8011.15Output of S 11.20 . . . . . . . . . . . . . . . . . . . . . . . . 8111.16Output of S 11.21 . . . . . . . . . . . . . . . . . . . . . . . . 8211.17Output of S 11.22 . . . . . . . . . . . . . . . . . . . . . . . . 8311.18Output of S 11.23 . . . . . . . . . . . . . . . . . . . . . . . . 8411.19Output of S 11.25 . . . . . . . . . . . . . . . . . . . . . . . . 8511.20Output of S 11.26 . . . . . . . . . . . . . . . . . . . . . . . . 8611.21Output of S 11.27 . . . . . . . . . . . . . . . . . . . . . . . . 8811.22Output of S 11.28 . . . . . . . . . . . . . . . . . . . . . . . . 89
13.1 Output of S 13.01 . . . . . . . . . . . . . . . . . . . . . . . . 9613.2 Output of S 13.02 . . . . . . . . . . . . . . . . . . . . . . . . 9713.3 Output of S 13.03 . . . . . . . . . . . . . . . . . . . . . . . . 9913.4 Output of S 13.04 . . . . . . . . . . . . . . . . . . . . . . . . 10013.5 Output of S 13.05 . . . . . . . . . . . . . . . . . . . . . . . . 10113.6 Output of S 13.06 . . . . . . . . . . . . . . . . . . . . . . . . 102
9
15.1 Output of S 15.01 . . . . . . . . . . . . . . . . . . . . . . . . 10415.2 Output of S 15.02 . . . . . . . . . . . . . . . . . . . . . . . . 10515.3 Output of S 15.03 . . . . . . . . . . . . . . . . . . . . . . . . 10615.4 Output of S 15.04 . . . . . . . . . . . . . . . . . . . . . . . . 10715.5 Output of S 15.05 . . . . . . . . . . . . . . . . . . . . . . . . 10815.6 Output of S 15.06 . . . . . . . . . . . . . . . . . . . . . . . . 10915.7 Output of S 15.07 . . . . . . . . . . . . . . . . . . . . . . . . 11015.8 Output of S 15.08 . . . . . . . . . . . . . . . . . . . . . . . . 111
10
Chapter 2
Laplace Transform and MatrixAlgebra
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 )=β )
Example 3.04 3.04.sci
14
1 s=%s ;2 H=sysl in ( β c β , ( 4β ( s+2) β ( ( s +2.5) Λ3) ) / ( ( s+6) β ( ( s+4)Λ2) ) ) ;3 plzr (H)
Example 3.15 3.15.sci
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
18 C=C1+C2 ;19 C=simple (C) ;20 disp (C, βResultant Output=β )
Example 6.08 6.08.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 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
12 Wd=Wnβsqrt(1β zeta Λ2)13 Tp=%pi/Wd14 Mp=100βexp((β%piβ zeta ) /sqrt(1β zeta Λ2) )
Example 8.07 8.07.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
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
Example 8.20 8.20.sci
1 ieee (2 ) ;2 syms k T;3 num=k ;4 den=sβ(1+sβT) ;5 G=num/den ;6 disp (G, βG( s )=β )7 H=1;8 CL=G/ .H;9 CL=simple (CL) ;
39
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;
10 sys=simple ( sys ) ;11 disp ( sys , βC( s ) /R( s )=β )12 [ num, den]=numden( sys )
48
13 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
14 c o f a 1 = c o e f f s ( den , β s β , 1 )15 / / 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
16 Wn=sqrt ( c o f a 0 )17 Wn=dbl (Wn) ;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)21 zeta =0.6 ;22 Kt=((2β zeta βWn)β2) /20 ;23 disp (Kt , βKt=β )24 Wd=Wnβsqrt(1β zeta Λ2) ;25 disp (Wd, βWd=β )26 Tp=%pi/Wd;27 disp (Tp, βTp=β )28 Mp=100βexp((β%piβ zeta ) /sqrt(1β zeta Λ2) ) ;29 disp (Mp, βMp=β )30 Ts=4/( zeta βWn) ;31 disp (Ts , βTs=β )
Example 9.08 9.08.sci
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
13 / / 2 β z e t a βWn= z ( 1 , 2 )
14 zeta=z (1 , 2 ) /(2βWn) ;15 disp ( zeta , β zeta=β )
50
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
Example 10.05-01 10.05.01.sci
1 ieee (2 )2 s=%s ;3 m=sΛ4+6β s Λ3+21β s Λ2+36β s+204 r=coeff (m)5 n=length ( r ) ;6 routh=[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ]7 routh=[ routh ;βdet ( routh ( 1 : 2 , 1 : 2 ) ) / routh (2 , 1 ) ,βdet ( routh
( 1 : 2 , 2 : 3 ) ) / routh (2 , 2 ) , 0 ] ;8 routh=[ routh ;βdet ( routh ( 2 : 3 , 1 : 2 ) ) / routh (3 , 1 ) ,βdet ( routh
( 2 : 3 , 2 : 3 ) ) / routh (3 , 2 ) , 0 ] ;9 routh=[ routh ;βdet ( routh ( 3 : 4 , 1 : 2 ) ) / routh (4 , 1 ) , 0 , 0 ] ;
10 disp ( routh , β routh=β )
56
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
Example 10.05-02 10.05.02.sci
1 s=%s ;2 m=sΛ5+6β s Λ4+3β s Λ3+2β sΛ2+s+13 r=coeff (m)4 n=length ( r )5 routh=[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ]6 routh=[ routh ;βdet ( routh ( 1 : 2 , 1 : 2 ) ) / routh (2 , 1 ) ,βdet ( routh
( 1 : 2 , 2 : 3 ) ) / routh (2 , 2 ) , 0 ]7 routh=[ routh ;βdet ( routh ( 2 : 3 , 1 : 2 ) ) / routh (3 , 1 ) ,βdet ( routh
( 2 : 3 , 2 : 3 ) ) / routh (3 , 2 ) , 0 ]8 routh=[ routh ;βdet ( routh ( 3 : 4 , 1 : 2 ) ) / routh (4 , 1 ) ,βdet ( routh
( 3 : 4 , 2 : 3 ) ) / routh (4 , 2 ) , 0 ]9 routh=[ routh ;βdet ( routh ( 4 : 5 , 1 : 2 ) ) / routh (5 , 1 ) , 0 , 0 ]
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
p o l y n o m i a l
5 n=length ( r ) ;6 routh=[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ]7 syms eps ;8 routh=[ routh ; eps ,βdet ( routh ( 1 : 2 , 2 : 3 ) ) / routh (2 , 2 ) , 0 ] ;9 routh=[ routh ;βdet ( routh ( 2 : 3 , 1 : 2 ) ) / routh (3 , 1 ) ,βdet ( routh
( 2 : 3 , 2 : 3 ) ) / routh (3 , 2 ) , 0 ] ;10 routh=[ routh ;βdet ( routh ( 3 : 4 , 1 : 2 ) ) / routh (4 , 1 ) ,βdet ( routh
( 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
Example 10.08 10.08.sci
1 s=%s ;2 m=sΛ4+5β s Λ3+2β s Λ2+3β s+23 r=coeff (m)4 n=length ( r ) ;5 routh=[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ]6 routh=[ routh ;βdet ( routh ( 1 : 2 , 1 : 2 ) ) / routh (2 , 1 ) ,βdet ( routh
( 1 : 2 , 2 : 3 ) ) / routh (2 , 2 ) , 0 ] ;7 routh=[ routh ;βdet ( routh ( 2 : 3 , 1 : 2 ) ) / routh (3 , 1 ) ,βdet ( routh
( 2 : 3 , 2 : 3 ) ) / routh (3 , 2 ) , 0 ] ;8 routh=[ routh ;βdet ( routh ( 3 : 4 , 1 : 2 ) ) / routh (4 , 1 ) , 0 , 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
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
p o l y n o m i a l
5 n=length ( r ) ;6 routh=[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ]7 syms eps ;
59
8 routh=[ routh ; eps ,βdet ( routh ( 1 : 2 , 2 : 3 ) ) / routh (2 , 2 ) , 0 ] ;9 routh=[ routh ;βdet ( routh ( 2 : 3 , 1 : 2 ) ) / routh (3 , 1 ) ,βdet ( routh
( 2 : 3 , 2 : 3 ) ) / routh (3 , 2 ) , 0 ] ;10 routh=[ routh ;βdet ( routh ( 3 : 4 , 1 : 2 ) ) / routh (4 , 1 ) ,βdet ( routh
( 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
12 n=length ( r ) ;13 routh=[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ]14 routh=[ routh ;βdet ( routh ( 1 : 2 , 1 : 2 ) ) / routh (2 , 1 ) ,βdet ( routh
( 1 : 2 , 2 : 3 ) ) / routh (2 , 2 ) , 0 ] ;15 routh=[ routh ;βdet ( routh ( 2 : 3 , 1 : 2 ) ) / routh (3 , 1 ) ,βdet ( routh
( 2 : 3 , 2 : 3 ) ) / routh (3 , 2 ) , 0 ] ;16 routh=[ routh ;βdet ( routh ( 3 : 4 , 1 : 2 ) ) / routh (4 , 1 ) , 0 , 0 ] ;
60
17 disp ( routh , β routh=β )
Example 10.11 10.11.sci
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
r o u t h m a t r i x
13 routh=[ routh ;βdet ( t ) / routh (3 , 1 ) , 0 ] ;14 disp ( routh , β routh=β )
Example 10.13 10.13.sci
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 ]
10 n=length ( r ) ;11 routh=[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ]12 routh=[ routh ;βdet ( routh ( 1 : 2 , 1 : 2 ) ) / routh (2 , 1 ) ,βdet ( routh
( 1 : 2 , 2 : 3 ) ) / routh (2 , 2 ) , 0 ] ;13 routh=[ routh ;βdet ( routh ( 2 : 3 , 1 : 2 ) ) / routh (3 , 1 ) ,βdet ( routh
( 2 : 3 , 2 : 3 ) ) / routh (3 , 2 ) , 0 ] ;
62
14 routh=[ routh ;βdet ( routh ( 3 : 4 , 1 : 2 ) ) / routh (4 , 1 ) , 0 , 0 ] ;15 disp ( routh , β routh=β )
Example 10.15 10.15.sci
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 ] ;
10 routh=[ routh ;βdet ( routh ) / routh (2 , 1 ) , 0 ] ;11 disp ( routh , β routh=β )
Example 10.16 10.16.sci
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
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=β0.85; / / 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= β)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
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 ;
10 disp (O, βq=β )11 q=2;12 O=((2βq )+1)/(nβm) β180 ;13 disp (O, βq=β )14
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 ;
10 disp (O, βq=β )
73
11 q=2;12 O=((2βq )+1)/(nβm) β180 ;13 disp (O, βq=β )14
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 )
Example 11.21 11.21.sci
1 s=%s ;2 H=sysl in ( β c β , 1/ ( ( s+2+%i ) β( s+1)β( s+2β%i) ) ) ;3 evans (H, 100 )
79
Figure 11.14: Output of S 11.19
Example 11.22 11.22.sci
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
9 w=poly (0 , βw β ) ;10 m=wΛ3+9βwβ2511 n=roots (m)12 s=%iβn (1)13 p=horner (y , s )14 [R, Theta ]=polar (p)15 PM=180+Theta
82
Figure 11.17: Output of S 11.22
Example 11.25 11.25.sci
1 s=%s ;2 H=sysl in ( β c β , 1/ ( ( s+1)β s β( s+2)β( s+4) ) ) ;3 evans (H, 100 )
Example 11.26 11.26.sci
1 s=%s ;2 H=sysl in ( β c β , ( s+4)β( s+5) /( ( s+1)β( s+3) ) ) ;3 evans (H, 100 )
83
Figure 11.18: Output of S 11.23
Example 11.27 11.27.sci
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
12 Mr=1/(2β zeta βsqrt(1β zeta Λ2) )13 Wr=Wnβsqrt(1β zeta Λ2)14 Wc=Wnβsqrt ((1β2β zeta Λ2)+sqrt (4β zeta Λ4β4β zeta Λ2+2) )
90
15 BW=Wc / / BANDWIDTH
Example 12.02 12.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
2 F=sysl in ( β c β , [ 3 6 / ( ( s+8)β 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
12 Mr=1/(2β zeta βsqrt(1β zeta Λ2) )13 Wr=Wnβsqrt(1β zeta Λ2)14 Wc=Wnβsqrt ((1β2β zeta Λ2)+sqrt (4β zeta Λ4β4β zeta Λ2+2) )15 BW=Wc / / BANDWIDTH
Example 12.03 12.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 β , [ 8 1 / ( 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 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 )
91
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 Mr=1/(2β zeta βsqrt(1β zeta Λ2) )13 Wr=Wnβsqrt(1β zeta Λ2)14 Wc=Wnβsqrt ((1β2β zeta Λ2)+sqrt (4β zeta Λ4β4β zeta Λ2+2) )15 BW=Wc / / BANDWIDTH
Example 12.04 12.04.sci
1 / / 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 s=poly (0 , β s β ) ;3 / / 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
4 F=sysl in ( β c β , [ 8 1 / ( ( s+18)β 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 b a c k w a r d p a t h
6 B=sysl in ( β c β ,(1+0β s ) /(1+0β s ) ) ;7 / / 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 CL=F/ .B9 / / 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 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
11 / / 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
12 z=coeff ( y )13 / / 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
14 Wn=sqrt ( z (1 , 1 ) )15 / / 2 β z e t a βWn= z ( 1 , 2 )
16 zeta=z (1 , 2 ) /(2βWn)17 / / z e t a = d a m p i n g f a c t o r
18 / / NOTE= h e r e s q r t ( 1 β 2 z e t a Λ 2 ) b e c o m e s c o m p l e x s o t h e
o t h e r s o l u t i o n i s Wr =0 & Mr =1
19 Mr=120 Wr=021 Wc=Wnβ((1β2β zeta Λ2)+sqrt (4β zeta Λ4β4β zeta Λ2+2) )22 BW=Wc / / BANDWIDTH
Example 12.05 12.05.sci
1 ieee (2 ) ;2 syms k a ;3 num=k ;
92
4 den=s β( a+s ) ;5 G=num/den ;6 disp (G, βG( s )=β )7 H=1;8 CL=G/ .H;9 CL=simple (CL) ;
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 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 )
14 c o f a 1 = c o e f f s ( den , β s β , 1 ) ;15 / / 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
16 Wn=sqrt ( c o f a 0 )17 / / c o f a 1 = 2 β z e t a βWn
18 zeta=co f a 1 /(2βWn)19 Mr=1/(2β zeta βsqrt(1β zeta Λ2) ) / / ββββββββββ1)
20 printf ( βGiven ,Mr=1.25 \nβ ) ;21 / / On s o l v i n g e q ( 1 ) w e g e t k = 1 . 2 5 a Λ2βββββββ2
22 printf ( βk=1.25βaΛ2 \nβ )23 Wr=Wnβsqrt (1β2β zeta Λ2) / / βββββββββββββββ3)
24 printf ( βGiven , Wr=12.65 \nβ ) ;25 / / o n s o v i n g e q ( 3 ) , w e g e t 2 kβ a Λ2=320βββββββββββ4)
26 printf ( β2kβaΛ2=320 \nβ )27 / / n o w e q 2 &4 c a n b e s i m u l t a n e o u s l y s o v e d t o t a k e o u t
v a l u e s o f k & a
28 / / L e t k = x & a Λ 2 = y
29 A=[1 ,β1.25;2 ,β1] ; / / c o e f f i c i e n t m a t r i x
30 b = [ 0 ; 3 2 0 ] ;31 m=A\b ;32 x=m(1 ,1 ) ;33 k=x34 y=m(2 ,1 ) ;35 a=sqrt ( y )36 Wn=dbl ( eval (Wn) ) ;37 disp (Wn, βWn=β )
93
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
Example 18.01 18.01.01.sci
1 syms n z ;2 x=(β0.5)Λn3 y=(4β ( (0 .2 ) Λn) )4 f 1=symsum(xβ( zΛ(βn) ) ,n , 0 , %inf )5 f 2=symsum(yβ( zΛ(βn) ) ,n , 0 , %inf )6 y=( f1+f2 ) ;7 disp (y , βans=β )
Example 18.08 18.08.01.sci
122
1 exec z t r a n s f e r . s c e ;2 sequence =[0 2 0 0 β3 0 0 8 ]3 y=z t r a n s f e r ( sequence ) ;4 disp (y , βans=β )
123