You are on page 1of 124

Scilab Code for Control Systems Theory and Applications by Smarajit Ghosh1

Created by Anuradha Singhania 4th Year Student B. Tech. (Elec. & Commun. ) Sri Mata Vaishno Devi University, Jammu College Teacher Prof. Amit Kumar Garg Sri Mata Vaishno Devi University, Jammu Reviewer Prof. Madhu Belur, IIT Bombay 29 June 2010

by a grant from the National Mission on Education through ICT, http://spoken-tutorial.org/NMEICT-Intro. This Textbook companion and scilab codes written in it can be downloaded from www.scilab.in

1 Funded

Book Details
Authors: Smarajit Ghosh Title: Control Systems Publisher: Pearson Education Edition: 2nd Year: 2009 Place: New Delhi ISBN: 978-81-317-0828-6

Contents
List of Scilab Code 2 Laplace Transform and Matrix Algebra 2.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Transfer Function 3.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Control system Components 4.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Control system Components 6.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Time Domain Analysis of Control Systems 8.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Feedback Characteristics of control Systems 9.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Stability 10.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Root Locus Method 11.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Frequency Domain Analysis 12.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 11 11 14 14 17 17 21 21 29 29 44 44 54 54 64 64 90 90

13 Bode Plot 13.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . .

95 95

15 Nyquist Plot 103 15.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 17 State Variable Approach 112 17.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 18 Digital Control Systems 122 18.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

List of Scilab Code


2.01-01 2.01-02 2.01-03 2.03 2.04 2.05-01 2.05-02 2.06 2.11 2.13 3.02 3.03 3.04 3.15 3.16 3.17 3.18 3.19 3.23 4.01 4.02 4.03 4.04 4.05 F1 F2 6.01 6.02 2.01.01.sci . 2.01.02sci . 2.01.03.sci . 2.03.sci . . . 2.04.sci . . . 2.05.01.sci . 2.05.02.sci . 2.06.sci . . . 2.11.sci . . . 2.13.sci . . . 3.02.sci . . . 3.03.sci . . . 3.04.sci . . . 3.15.sci . . . 3.16.sci . . . 3.17.sci . . . 3.18.sci . . . 3.19.sci . . . 3.23.sci . . . 4.01.sci . . . 4.02.sci . . . 4.03.sci . . . 4.04.sci . . . 4.05.sci . . . parallel.sce serial.sce . . 6.01.sci . . . 6.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 11 11 12 12 12 12 13 13 13 14 14 14 15 15 15 15 16 16 17 18 18 19 19 21 21 21 22

6.03 6.04 6.05 6.06 6.07 6.08 6.09 6.10 6.11 6.12 6.13 6.14 6.15 8.02 8.03-01 8.03-02 8.03-03 8.04 8.05 8.06 8.07 8.08 8.09 8.10 8.11 8.12 8.13 8.14 8.15 8.16 8.17 8.19 8.20 8.23-01 8.23-02 8.23-03 8.23-04 8.24

6.03.sci . . 6.04.sci . . 6.05.sci . . 6.06.sci . . 6.07.sci . . 6.08.sci . . 6.09.sci . . 6.10.sci . . 6.11.sci . . 6.12.sci . . 6.13.sci . . 6.14.sci . . 6.15.sci . . 8.02.sci . . 8.03.01.sci 8.03.02.sci 8.03.03.sci 8.04.sci . . 8.05.sci . . 8.06.sci . . 8.07.sci . . 8.08.sci . . 8.09.sci . . 8.10.sci . . 8.11.sci . . 8.12.sci . . 8.13.sci . . 8.14.sci . . 8.15.sci . . 8.16.sci . . 8.17.sci . . 8.19.sci . . 8.20.sci . . 8.23.01.sci 8.23.02.sci 8.23.03.sci 8.23.04.sci 8.24.sci . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

22 23 23 23 23 24 24 25 25 26 26 27 27 29 29 30 30 31 31 32 32 33 34 34 35 35 36 36 37 37 38 39 39 40 40 41 41 42

8.32 9.01 9.02 9.03 9.04 9.05 9.06 9.07 9.08 9.09 9.10 9.11 10.02-01 10.02-02 10.02-03 10.03 10.04 10.05-01 10.05-02 10.06 10.07 10.08 10.09 10.10 10.11 10.12 10.13 10.14 10.15 10.16 11.01 11.02 11.03 11.04 11.05 11.06 11.08 11.09

8.32.sci . . . 9.01.sci . . . 9.02.sci . . . 9.03.sci . . . 9.04.sci . . . 9.05.sci . . . 9.06.sci . . . 9.07.sci . . . 9.08.sci . . . 9.09.sci . . . 9.10.sci . . . 9.11.sci . . . 10.02.01.sci 10.02.02.sci 10.02.03.sci 10.03.sci . . 10.04.sci . . 10.05.01.sci 10.05.02.sci 10.06.sci . . 10.07.sci . . 10.08.sci . . 10.09.sci . . 10.10.sci . . 10.11.sci . . 10.12.sci . . 10.13.sci . . 10.14.sci . . 10.15.sci . . 10.16.sci . . 11.01.sci . . 11.02.sci . . 11.03.sci . . 11.04.sci . . 11.05.sci . . 11.06.sci . . 11.08.sci . . 11.09.sci . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

42 44 45 45 46 47 47 48 49 50 51 52 54 54 55 55 56 56 57 57 58 59 59 60 61 61 62 62 63 63 64 64 64 65 67 69 70 71

11.10 11.11 11.12 11.13 11.14 11.15 11.16 11.17 11.19 11.20 11.21 11.22 11.23 11.25 11.26 11.27 11.28 12.01 12.02 12.03 12.04 12.05 13.01 13.02 13.03 13.04 13.05 13.06 15.01 15.02 15.03 15.04 15.05 15.06 15.07 15.08 17.03 17.04

11.10.sci 11.11.sci 11.12.sci 11.13.sci 11.14.sci 11.15.sci 11.16.sci 11.17.sci 11.19.sci 11.20.sci 11.21.sci 11.22.sci 11.23.sci 11.25.sci 11.26.sci 11.27.sci 11.28.sci 12.01.sci 12.02.sci 12.03.sci 12.04.sci 12.05.sci 13.01.sci 13.02.sci 13.03.sci 13.04.sci 13.05.sci 13.06.sci 15.01.sci 15.02.sci 15.03.sci 15.04.sci 15.05.sci 15.06.sci 15.07.sci 15.08.sci 17.03.sci 17.04.sci

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

71 73 73 74 74 74 75 76 78 79 79 80 81 82 83 84 87 90 91 91 92 92 95 95 97 98 98 100 103 103 104 105 106 107 108 109 112 112

17.06 17.07 17.08 17.09 17.10 17.11 17.12 17.13 17.14 17.16 17.17 17.18 17.19 17.20 17.21 17.22 17.23 F3 18.01 18.08

17.06.sci . . 17.07.sci . . 17.08.sci . . 17.09.sci . . 17.10.sci . . 17.11.sci . . 17.12.sci . . 17.13.sci . . 17.14.sci . . 17.16.sci . . 17.17.sci . . 17.18.sci . . 17.19.sci . . 17.20.sci . . 17.21.sci . . 17.22.sci . . 17.23.sci . . ztransfer.sce 18.01.01.sci 18.08.01.sci

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

112 113 113 113 113 114 114 115 116 116 117 117 117 118 119 119 120 122 122 122

List of Figures
11.1 Output 11.2 Output 11.3 Output 11.4 Output 11.5 Output 11.6 Output 11.7 Output 11.8 Output 11.9 Output 11.10Output 11.11Output 11.12Output 11.13Output 11.14Output 11.15Output 11.16Output 11.17Output 11.18Output 11.19Output 11.20Output 11.21Output 11.22Output 13.1 13.2 13.3 13.4 13.5 13.6 Output Output Output Output Output Output Graph of S 11.01 Graph of S 11.02 Graph of S 11.03 of S 11.04 . . . . of S 11.05 . . . . of S 11.06 . . . . of S 11.08 . . . . of S 11.09 . . . . of S 11.13 . . . . of S 11.14 . . . . of S 11.15 . . . . of S 11.16 . . . . of S 11.17 . . . . of S 11.19 . . . . of S 11.20 . . . . of S 11.21 . . . . of S 11.22 . . . . of S 11.23 . . . . of S 11.25 . . . . of S 11.26 . . . . of S 11.27 . . . . of S 11.28 . . . . of of of of of of S S S S S S 13.01 13.02 13.03 13.04 13.05 13.06 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 66 67 68 69 70 71 72 75 76 77 78 79 80 81 82 83 84 85 86 88 89 96 97 99 100 101 102

15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8

Output Output Output Output Output Output Output Output

of of of of of of of of

S S S S S S S S

15.01 15.02 15.03 15.04 15.05 15.06 15.07 15.08

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

104 105 106 107 108 109 110 111

10

Chapter 2 Laplace Transform and Matrix Algebra


Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spokentutorial.org) for the installation of Symbolic Toolbox.

2.1

Scilab Code

Example 2.01-01 2.01.01.sci


1 2 3

syms t s ; y=l a p l a c e ( 13 , t , s ) ; disp ( y , ans= ) Example 2.01-02 2.01.02sci

1 2 3

syms t s ; y=l a p l a c e ( 4+5%e(3 t ) , t , s ) ; disp ( y , ans= ) Example 2.01-03 2.01.03.sci

1 2 3

syms t s ; y=l a p l a c e ( 2 t 3%e( t ) , t , s ) ; disp ( y , ans= ) 11

Example 2.03 2.03.sci


1 2 3 4 5 6 7 8 9

p=poly ( [ 9 1 ] , s , c o e f f ) q=poly ( [ 3 7 1 ] , s , c o e f f ) f=p/q ; disp ( f , F( s )= ) x=s f ; y=l i m i t ( x , s , 0 ) ; / / f i n a l v a l u e disp ( y , f ( i n f )= ) z=l i m i t ( x , s , %inf ) ; / / i n i t i a l disp ( z , f ( 0 )= ) Example 2.04 2.04.sci

theorem

value

theorem

1 2 3 4

s=%s syms t ; disp ( ( s +3) / ( ( s +1) ( s +2) ( s +4) ) , F( s )= ) [A]= pfss ( ( s +3) / ( ( s +1) ( s +2) ( s +4) ) ) / / p a r t i a l
of F( s )

fraction

5 6 7 8 9

F1= i l a p l a c e (A( 1 ) , s , t ) F2= i l a p l a c e (A( 2 ) , s , t ) F3= i l a p l a c e (A( 3 ) , s , t ) F=F1+F2+F3 ; disp (F , f ( t )= ) Example 2.05-01 2.05.01.sci

1 2 3

syms t s ; y= l a p l a c e ( %e( t ) +5 t +6%e(3 t ) , t , s ) ; disp ( y , ans= ) Example 2.05-02 2.05.02.sci

1 2 3

syms t s ; y=l a p l a c e ( 5+6 t 2+3%e(2 t ) , t , s ) ; disp ( y , ans= ) 12

Example 2.06 2.06.sci


1 2 3

syms t s ; y=l a p l a c e ( 3 %e(3 t ) , t , s ) ; disp ( y , ans= ) Example 2.11 2.11.sci

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

p=poly ( [ 0 . 3 8 ] , s , c o e f f ) ; q=poly ( [ 0 0 . 5 4 3 2 . 4 8 1 ] , s , c o e f f ) ; F=p/q ; syms s ; x=s F ; y=l i m i t ( x , s , 0 ) ; / / y=db l ( y ) ; disp ( y , f ( i n f )= ) z=l i m i t ( x , s , %inf ) / / z=db l ( z ) ; disp ( z , f ( 0 )= ) Example 2.13 2.13.sci

final

value

theorem

//

i n i t i a l

value

theorem

1 2 3 4 5 6 7

s=%s ; p=poly ( [ 3 1 ] , s , c o e f f ) ; q=poly ( [ 0 1 1 2] , s , r o o t s ) ; f=p/q ; syms t s ; y=i l a p l a c e ( f , s , t ) ; disp ( y , f ( t )= )

13

Chapter 3 Transfer Function


Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spokentutorial.org) for the installation of Symbolic Toolbox.

3.1

Scilab Code

Example 3.02 3.02.sci


1 2 3 4

syms t s ; f=%e(3 t ) ; y=l a p l a c e ( %e(3 t ) , t , s ) ; disp ( y , G( s )= ) Example 3.03 3.03.sci

1 2 3 4 5 6 7 8

syms t s ; disp (%e(3 t ) , g ( t )= ) ; y1=l a p l a c e ( %e(3 t ) , t , s ) ; disp ( y1 , G( s )= ) disp (%e(4 t ) , r ( t )= ) ; y2=l a p l a c e ( %e(4 t ) , t , s ) ; disp ( y2 , R( s )= ) disp ( y1y2 , G( s )R( s )= ) Example 3.04 3.04.sci 14

1 2 3

s=%s ; H=s y s l i n ( c , ( 4 ( s +2) ( ( s +2.5) 3) ) / ( ( s +6) ( ( s +4) 2 ) ) ) ; plzr (H) Example 3.15 3.15.sci

1 2 3

syms t s y=l a p l a c e (%e(3 t ) sin (2 t ) , t , s ) ; disp ( y , ans= ) Example 3.16 3.16.sci

1 2

syms t s ; x=64%e(5 t ) /5+%e(3 t )


the system

// Given

step

Response

of

4 5

6 7

printf ( Derivative of step response g i v e s impulse r e s p o n s e \n ) y=d i f f ( x , t ) ; // D e r i v a t i v e of step response p r i n t f ( L a p l a c e Transform o f Impulse Response g i v e s th e T r a n s f e r Function \n ) p=l a p l a c e ( y , t , s ) ; disp ( p , T r a n s f e r Function= ) Example 3.17 3.17.sci

2 3 4 5

p r i n t f ( Given : P o l e s a r e s=1,(2+ i ) ,(2 i ) ; z e r o s =3+i ,3 i , Gain f a c t o r ( k )=5 \n ) num=poly([3+%i,3%i ] , s , r o o t s ) ; den=poly([1,2+%i,2%i ] , s , r o o t s ) ; G=(5num) / den ; disp (G, G( s )= ) Example 3.18 3.18.sci

1 2 3

s=%s ; G=s y s l i n ( c , ( 5 ( s +2) ) / ( ( s +3) ( s +4) ) ) ; disp (G, G( s )= ) 15

4 5 6 7

x=denom(G) ; disp ( x , C h a r a c t e r i s t i c s Polynomial= ) y=roots ( x ) ; disp ( y , P o l e s o f a system= ) Example 3.19 3.19.sci

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

p r i n t f ( Given : P o l e s a r e s =3, Z e r o s a r e s =2, Gain F a c t o r ( k )=5 \n ) num=poly ( [ 2 ] , s , r o o t s ) ; den=poly ( [ 3 ] , s , r o o t s ) ; G=5num/ den ; disp (G, G( s )= ) disp ( Input i s Step Function ) syms t s ; R=l a p l a c e ( 1 , t , s ) ; disp (R, R( s )= ) p r i n t f ( C( s )=R( s )G( s ) \n ) C=RG; disp (C, C( s )= ) c=i l a p l a c e (C, s , t ) ; disp ( c , c ( t )= ) Example 3.23 3.23.sci

1 2 3 4 5 6 7 8 9

// p o l e

zero

plot

for

g ( s ) =( s 2+3 s +2) / ( s 2+7 s + 1 2 )

s=%s ; p=poly ( [ 2 3 1 ] , s , c o e f f ) q=poly ( [ 1 2 7 1 ] , s , c o e f f ) V=s y s l i n ( c , p , q ) plzr (V) syms s t ; v =i l a p l a c e ( (2+(3 s )+s 2) / ( s 2+(7 s ) +12) , s , t ) disp ( v , V( t ) = )

16

Chapter 4 Control system Components


4.1 Scilab Code

Example 4.01 4.01.sci


1

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

p r i n t f ( Given a ) E x c i t a t i o n v o l t a g e ( Ein )=2V \n b ) S e t t i n g Ratio ( a )= 0 . 4 \n ) Ein =2; disp ( Ein , Ein= ) a =0.4; disp ( a , a= ) Rt =103; disp ( Rt , Rt= ) Rl =5103; disp ( Rl , Rl= ) p r i n t f ( Eo = ( a Ein ) /(1+( a(1a ) Rt ) / Rl ) \n ) Eo = ( a Ein ) /(1+( a(1a ) Rt ) / Rl ) ; disp ( Eo , output v o l t a g e ( E0 )= ) p r i n t f ( e =(( a 2 ) (1a ) ) / ( ( a(1a ) ) +(Rl /Rt ) ) \n ) e =(( a 2) (1a ) ) / ( ( a(1a ) ) +(Rl /Rt ) ) ; disp ( e , l o a d i n g e r r o r= ) p r i n t f ( E=Ein e \n ) 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 )
Loading error ( e )

18

disp (E , V o l t a g e e r r o r= )

17

Example 4.02 4.02.sci


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

17 18 19 20 21 22 23 24 25 26 27

p r i n t f ( n=5 , H e l i c a l turn \n ) n=5; / / H e l i c a l t u r n disp ( n , n= ) p r i n t f ( N=9000 , Winding Turn \n ) N=9000; / / W i n d i n g T u r n disp (N, N= ) p r i n t f ( 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 \n ) 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 disp (R, R= ) p r i n t f ( Ein=90 , Input v o l t a g e \n ) Ein =90; / / I n p u t v o l t a g e disp ( Ein , Ein= ) p r i n t f ( r =5050 , R e s i s t a n c e a t mid p o i n t \n ) r =5050; / / R e s i s t a n c e a t m i d p o i n t disp ( r , r= ) p r i n t f ( D=r 5000 , D e v i a t i o n from nominal a t midp o i n t \ n ) 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 disp (D, D= ) p r i n t f ( L=D/R100 , L i n e a r i t y \n ) L=D/R 1 0 0 ; / / L i n e a r i t y disp (L , L= ) p r i n t f ( R=Ein /N , R e s o l u t i o n \n ) R=Ein /N; / / R e s o l u t i o n disp (R, R= ) p r i n t f ( Kp=Ein /(2 p i n ) , P o t e n t i o m e t e r Constant \n ) Kp=Ein /(2 %pin ) ; / / P o t e n t i o m e t e r C o n s t a n t disp (Kp, Kp= ) Example 4.03 4.03.sci

2 3 4

p r i n t f ( s i n c e S2 i s t h e r e f e r a n c e s t a t o r winding , Es2= KVcos0 \n where Es2 & Er a r e rms v o l t a g e s \n ) k=1 Theta =60; d i s p ( Theta , Theta= ) 18

5 6 7 8 9 10 11

12 13 14 15 16 17 18 19 20 21 22 23 24

V=28; d i s p (V, V( a p p l i e d )= ) p r i n t f ( Es2=V cos ( Theta ) \n ) Es2=kV c o s ( Theta ( %pi /180) ) ; d i s p ( Es2 , Es2= ) p r i n t f ( Es1=kV cos ( Theta 120)\n ) Es1=kV c o s ( ( Theta 120) ( %pi /180) ) ; // Given Theta=60 in degrees d i s p ( Es1 , Es1= ) p r i n t f ( Es3=kV c o s ( Theta +120) \n ) Es3=kV c o s ( ( Theta +120) ( %pi /180) ) ; d i s p ( Es3 , Es3= ) p r i n t f ( Es31=s q r t ( 3 ) kEr s i n ( Theta ) ) Es31=sqrt ( 3 ) kV sin ( Theta ( %pi /180) ) ; disp ( Es31 , Es31 = ) p r i n t f ( Es12=sqrt ( 3 ) kEr sin ( ( Theta 120) ) Es12=s q r t ( 3 ) kV s i n ( ( Theta 120) ( %pi /180) ) ; d i s p ( Es12 , Es12= ) p r i n t f ( Es23=s q r t ( 3 ) kEr s i n ( ( Theta +120) ) Es23=s q r t ( 3 ) kV s i n ( ( Theta +120) ( %pi /180) ) ; d i s p ( Es23 , Es23= ) Example 4.04 4.04.sci

1 2 3 4 5 6 7 8 9

p r i n t f ( S e n s i t i v i t y =5v /1000rpm \n ) Vg=5; disp (Vg , Vg= ) p r i n t f ( w( i n r a d i a n s / s e c ) =(1000/60) 2 p i \n ) w=(1000/60) 2 %pi ; disp (w, w= ) p r i n t f ( Kt=Vg/w \n ) Kt=Vg/w; d i s p ( Kt , Gain c o n s t a n t ( Kt )= ) Example 4.05 4.05.sci

1 2

p r i n t f ( Torque= KmVm=2 \n ) t =2; 19

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

disp ( t , Torque ( t )= ) Fm= 0 . 2 ; disp (Fm, C o e f f i c i e n t o f V i s c o u s f r i c t i o n (Fm)= ) N=4 I =0.2 F1=0.05 p r i n t f ( Wnl=t /Fm ) Wnl=t /Fm; disp (Wnl , No Load Speed (Wnl)= ) p r i n t f ( Fwt=I +(N2F1 ) \n ) Fwt=I +(N2F1 ) ; disp ( Fwt , Total V i s c o u s F r i c t i o n ( Fwt )= ) p r i n t f ( Te=t (Fwtw) \n ) Te=0.8 / / l o a d w=(tTe ) /Fwt ; disp (w, Speed o f Motor (w)= )

20

Chapter 6 Control system Components


Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spokentutorial.org) for the installation of Symbolic Toolbox. To Run the following codes use the same destination for the function as well as the main code.

6.1

Scilab Code

Example F1 parallel.sce
1 2 3

function [ y]= p a r a l l e l ( sys1 , s y s 2 ) y=s y s 1+s y s 2 endfunction Example F2 serial.sce

1 2 3 4

function [ y]= s e r i e s ( sys1 , s y s 2 ) y=s y s 1 s y s 2 endfunction Example 6.01 6.01.sci

1 2

exec s e r i e s . s c e ; s=%s ; 21

3 4 5 6 7 8 9 10 11

s y s 1=s y s l i n ( c , ( s +3) / ( s +1) ) s y s 2=s y s l i n ( c , 0 . 2 / ( s +2) ) s y s 3=s y s l i n ( c , 5 0 / ( s +4) ) s y s 4=s y s l i n ( c , 1 0 / ( s ) ) a=s e r i e s ( sys1 , s y s 2 ) ; b=s e r i e s ( a , s y s 3 ) ; y=s e r i e s ( b , s y s 4 ) ; y=simp ( y ) ; disp ( y , C( s ) /R( s )= ) This code requires S F1. Example 6.02 6.02.sci

1 2 3 4 5 6 7 8 9

exec p a r a l l e l . s c e ; s=%s ; s y s 1=s y s l i n ( c , 1 / s ) s y s 2=s y s l i n ( c , 2 / ( s +1) ) s y s 3=s y s l i n ( c , 3 / ( s +3) ) a=p a r a l l e l ( sys1 , s y s 2 ) ; y=p a r a l l e l ( a , s y s 3 ) ; y=simp ( y ) ; disp ( y , C( s ) /R( s )= ) This code requires S F2. Example 6.03 6.03.sci

1 2 3 4 5 6 7 8 9 10

exec s e r i e s . s c e ; s=%s ; s y s 1=s y s l i n ( c , 3 / ( s ( s +1) ) ) s y s 2=s y s l i n ( c , s 2 / ( 3 ( s +1) ) ) s y s 3=s y s l i n ( c , 6 / ( s ) ) a=(1) s y s 3 ; b=s e r i e s ( sys1 , s y s 2 ) ; y=b / . a // f e e d b a c k operation y=simp ( y ) disp ( y , C( s ) /R( s )= ) 22

Example 6.04 6.04.sci


1 2 3 4 5 6 7

exec p a r a l l e l . s c e ; syms G1 G2 G3 H; a=s e r i e s (G1 , G2) ; b=p a r a l l e l ( a , G3) ; y=b / .H / / n e g a t i v e f e e d b a c k y=s i m p l e ( y ) disp ( y , C( s ) /R( s )= ) Example 6.05 6.05.sci

operation

1 2 3 4 5 6 7

exec s e r i e s . s c e ; syms G1 G2 H1 H2 s ; 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 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 y=s e r i e s ( b , G2) ; y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.06 6.06.sci

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

exec p a r a l l e l . s c e ; exec s e r i e s . s c e ; syms G1 G2 G3 G4 G5 G6 H1 H2 ; a=p a r a l l e l (G3 , G5) ; b=p a r a l l e l ( a,G4) ; c=s e r i e s (G1 , G2) ; d=c / . H1 ; e=s e r i e s ( b , d ) ; f=e / . H2 ; y=s e r i e s ( f , G6) ; y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.07 6.07.sci

23

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

exec s e r i e s . s c e ; syms G1 G2 G3 H1 H2 R X;
// p u t t i n g x =0 , t h e n solving the block

a=G3 / . H1 ; b=s e r i e s (G1 , G2) ; c=s e r i e s ( a , b ) ; x1=c / . H2 ; C1=Rx1 ; disp ( x1 , C1( s ) /R( s )= )
// p u t t i n g r =0 , then solving the block

d=s e r i e s (G1 , G2) ; e=s e r i e s ( d , H2) ; f=G3 / . H1 ; x2=f / . e ; C2=Xx2 ; disp ( x2 , C2( s ) /X( s )= )
// r e s u l t a n t output C= C 1 + C 2

C=C1+C2 ; C=s i m p l e (C) ; disp (C, R e s u l t a n t Output= ) Example 6.08 6.08.sci

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

exec p a r a l l e l . s c e ; exec s e r i e s . s c e ; syms G1 G2 G3 H1 H2 ;


// s h i f t the take o f f point after the block G2

a=G3/G2 ; b=p a r a l l e l ( a , 1 ) ; c=s e r i e s (G1 , G2) ; d=c / . H1 / / n e g a t i v e e=s e r i e s ( d , b ) ; y=e / . H2 ; y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.09 6.09.sci

feedback

operation

24

1 2 3

exec s e r i e s . s c e syms G1 G2 G3 H1 H2 H3 ;
// Remove the feedback function loop H2 having feedback path transfer

4 5

a=G3 / . H2 ;
// I n t e r c h a n g e cascade the summer by its . as well as replace the block equivalent block

6 7 8 9 10 11

b=s e r i e s (G1 , G2) ; c=b / . H1 ; / / N e g a t i v e d=s e r i e s ( c , a ) ; y=d / . H3 ; / / N e g a t i v e y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.10 6.10.sci

Feedback

Operation

Feedback

Operation

1 2 3 4 5 6 7 8 9 10 11

exec p a r a l l e l . s c e ; exec s e r i e s . s c e ; syms G1 G2 G3 G4 G5 H1 H2 ; a=G2 / . H1 ; / / n e g a t i v e f e e d b a c k b=s e r i e s (G1 , a ) ; c=s e r i e s ( b , G3) ; d=p a r a l l e l ( c , G4) ; e=s e r i e s ( d , G5) ; y=e / . H2 ; // n e g a t i v e feedback y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.11 6.11.sci

operation

operation

1 2 3 4 5 6 7 8

exec p a r a l l e l . s c e ; exec s e r i e s . s c e ; syms G1 G2 G3 G4 G5 G6 G7 H1 H2 H3 ; a=p a r a l l e l (G1 , G2) ; b=p a r a l l e l ( a , G3) ;


// s h i f t the take off point to the right of the block G4

c=G4 / . H1 ; d=G5/G4 ;

// n e g a t i v e // n e g a t i v e

feedback feedback

operation operation

25

9 10 11 12 13 14 15 16 17

e=p a r a l l e l ( d , 1 ) ; f=G6 / . H2 ; // n e g a t i v e g=s e r i e s ( b , c ) ; h=s e r i e s ( g , e ) ; i=s e r i e s ( h , f ) ; j=s e r i e s ( i , G7) ; y=j / . H3 ; y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.12 6.12.sci

feedback

operation

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

exec s e r i e s . s c e ; exec p a r a l l e l . s c e ; syms G1 G2 G3 G4 H1 H2 H3 ;


// s h i f t the take o f f point after the block G1

a=G3/G1 ; b=p a r a l l e l ( a , G2) ; 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 d=1/b ; // N e g a t i v e Feedback Operation e=p a r a l l e l ( d , H3) ; f=s e r i e s ( e , H2) ; g=s e r i e s ( c , b ) ; h=g / . f ; // N e g a t i v e Feedback Operation y=s e r i e s ( h , G4) ; y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.13 6.13.sci

1 2 3 4 5 6 7 8

exec s e r i e s . s c e ; exec p a r a l l e l . s c e ; syms G1 G2 G3 G4 H1 H2 ;


// r e d u c e the internal feedback loop

a=G2 / . H2 ;
// p l a c e the summer l e f t to the block G1

b=G3/G1 ;
// e x c h a n g e the summer

26

9 10 11 12 13 14 15

c=p a r a l l e l ( b , 1 ) ; d=s e r i e s ( a , G1) ; e=s e r i e s ( d , G4) ; f=e / . H1 ; y=s e r i e s ( c , f ) ; y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.14 6.14.sci

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

exec s e r i e s . s c e ; exec p a r a l l e l . s c e ; syms G1 G2 G3 G4 H1 H2 ;


// s h i f t the take o f f point to the right of the block G3

a=H1/G3 ; b=s e r i e s (G2 , G3) ; c=p a r a l l e l (H2 , a ) ; d=b / . c ; e=s e r i e s ( d , G1) ; f=e / . a ; y=s e r i e s ( f , G4) ; y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= ) Example 6.15 6.15.sci

1 2 3 4 5

exec s e r i e s . s c e ; exec p a r a l l e l . s c e ; syms G1 G2 G3 G4 H1 H2 H3 ;


// s h i f t // s h i f t block the the H1 take o f f other &H2 point to the right to the of the block of the H1 take o f f point right

6 7 8 9 10 11

a=s e r i e s (H1 , H2) ; b=1/a ; c=1/H1 ; d=G3 / . a ;


// move the summer to the l e f t of the block G2

e=G4/G2 ; 27

12 13 14 15 16 17 18 19 20

f=s e r i e s ( d , G2) ;
// e x c h a n g e the summer

g=f / . H1 ; h=p a r a l l e l (G1 , e ) ; i=s e r i e s ( h , g ) ; j=s e r i e s ( a , H3) ; y=i / . j ; y=s i m p l e ( y ) ; disp ( y , C( s ) /R( s )= )

28

Chapter 8 Time Domain Analysis of Control Systems


Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spokentutorial.org) for the installation of Symbolic Toolbox

8.1

Scilab Code

Example 8.02 8.02.sci


1 2 3 4 5 6 7 8 9

s=%s ; p=poly ( [ 3 1 ] , s , c o e f f ) ; q=poly ( [ 0 1 0 . 9 5 0 . 2 1 ] , s , c o e f f ) ; G=p/q ; disp (G, G( s )= ) H=1; y=GH; / / T y p e 1 S y s t e m disp ( y , G( s )H( s )= )
// R e f e r i n g system the table & 8.2 Ka =0 given in the book , For type 1 Kp= % i n f

10 11 12 13

p r i n t f ( For type1 Kp=i n f & Ka=0 \n ) syms s ; Kv=l i m i t ( s y , s , 0 ) ; / / K v = v e l o c i t y e r r o r c o e f f i c i e n t disp (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 (Kv)= )

29

Example 8.03-01 8.03.01.sci


1 2 3 4 5 6 7 8

s=%s ; p=poly ( [ 1 0 ] , s , c o e f f ) ; q=poly ( [ 0 0 1 ] , s , c o e f f ) ; G=p/q ; H= 0 . 7 ; y=GH; / / t y p e 2 disp ( y , G( s )H( s )= )


// r e f e r i n g Kp= % i n f the & table 8.2 given in the book , for type 1 Kv= % i n f

9 10 11

p r i n t f ( For type1 Kp=i n f & Kv=i n f \n ) syms s ; Ka=l i m i t ( s 2y , s , 0 ) ; / / K a = a c c e l a r a t i o n


c o e f f i c i e n t

error

12

disp (Ka , Ka= ) Example 8.03-02 8.03.02.sci

1 2 3 4 5 6

p=poly ( [ 5 ] , s , c o e f f ) ; q=poly ( [ 5 3 1 ] , s , c o e f f ) ; G=p/q H=0.6 y=GH / / t y p e 0


// r e f e r i n g Ka =0 & the Kv =0 table 8.2 given in the book , for type 1

7 8

syms s Kp=l i m i t ( s y/ s , s , 0 )

//

Kp= p o s i t i o n a l

error

c o e f f i c i e n t

Example 8.03-03 8.03.03.sci


1 2 3 4 5 6

p=poly ( [ 1 0 . 1 3 0 . 4 ] , s , c o e f f ) ; q=poly ( [ 0 0 5 3 1 ] , s , c o e f f ) ; G=10p/q / / g a i n FACTOR = 1 0 H=0.8 y=GH / / t y p e 2 30

// r e f e r i n g Kp= % i n f

the &

table

8.2

given

in

the

book

, for

type

Kv= % i n f

8 9

syms s Ka=l i m i t ( s 2y , s , 0 ) Example 8.04 8.04.sci

/ / Ka= a c c e l a r a t i o n

error

c o e f f i c i e n t

1 2 3 4 5 6 7 8

p=poly ( [ 4 1 ] , s , c o e f f ) ; q=poly ( [ 0 0 6 5 1 ] , s , c o e f f ) ; syms K r e a l ; y=Kp/q / / g a i n FACTOR =K disp ( y , G( s )H( s )= )


// G ( s ) H ( s ) =y // r e f e r i n g Kp= % i n f , and it is 8.2 of type 2 in the book , for type 2 the & table given

Kv= % i n f

9 10 11

p r i n t f ( For type1 Kp=i n f & Kv=i n f \n ) syms A s t ; Ka=l i m i t ( s 2y , s , 0 ) ; / / K a = a c c e l a r a t i o n


c o e f f i c i e n t

error

12 13 14 15 16 17 18 19

disp (Ka , Ka= )


// g i v e n input is r ( t ) =A ( t 2 ) / 2 & R( s )= l a p l a c e ( r ( t ) )

p r i n t f ( Given r ( t )=A( t 2) /2 \n ) R=l a p l a c e ( A t 2/2 , t , s ) ; disp (R, R( s )= )


// s t e a d y state error =Lt s >0 sR ( S ) /1+G ( s ) H ( S )

e=l i m i t ( s R/(1+y ) , s , 0 ) disp ( e , Ess= ) Example 8.05 8.05.sci

1 2 3 4 5 6 7

p=poly ( [ 6 0 ] , s , c o e f f ) ; q=poly ( [ 1 2 7 1 ] , s , c o e f f ) ; G=p/q ; disp (G, G( s )= ) H=1; y=GH F=1/(1+y ) ; 31

8 9 10 11 12 13 14

disp (F , 1/(1+G( s )H( s ) )= ) syms t s ; Ko=l i m i t ( s F/ s , s , 0 ) / / K o = L t s >0 ( 1 / ( 1 + G ( s ) H ( S ) ) d=d i f f ( s F/ s , s ) ; K1=l i m i t ( d i f f ( s F/ s , s ) , s , 0 ) / / K 1 = L t s >0 ( d F ( s ) / d s K2=l i m i t ( d i f f ( d , s ) , s , 0 ) / / K 2 = L t s >0 ( d 2 F ( s ) / d s )
// g i v e n ) ) input is r ( t ) =4+3 t +8( t 2 ) /2

& R( s )= l a p l a c e ( r ( t

15 16 17 18 19

a=(4+3 t +8( t 2) / 2 ) b=d i f f (4+3 t +8( t 2) /2 , t ) c=d i f f ( b , t ) e=Koa+K1b+K2 c / / e r r o r b y disp ( e , e r r o r ) Example 8.06 8.06.sci

dynamic

c o e f f i c i e n t

method

1 2

s=poly ( 0 , s ) ; / / D e f i n e s s a s F=s y s l i n ( c , [ 2 5 / ( ( s +1) s ) ] ) ;


function in forward path

polynomial // C r e a t e s

variable transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7

CL=F / .B
//

// C a l c u l a t e s CL with

closed loop

transfer

function

compare

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the the denominator c o e f f i c i e n t s of of CL the

y=denom(CL) z=c o e f f ( y )

// e x t r a c t i n g // e x t r a c t i n g polynomial , comparing

denominator
8 9 10 11 12 13 14

/ / Wn 2 = z ( 1 , 1 )

the //

c o e f f i c i e n t s Wn= n a t u r a l frequency

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

z e t a=z ( 1 , 2 ) /(2Wn) // z e t a =damping Wd Wn sqrt (1 z e t a 2) = Tp=%pi/Wd Mp=100exp((%pi z e t a ) / sqrt (1 z e t a 2) ) Example 8.07 8.07.sci

factor

s=poly ( 0 , s ) ;

// D e f i n e s

as

polynomial

variable

32

F=s y s l i n ( c , [ 2 0 / ( s 2+5 s +5) ] ) ;


function in forward path

// C r e a t e s

transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7

CL=F / .B
//

// C a l c u l a t e s CL with

closed loop

transfer

function

compare

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the the denominator c o e f f i c i e n t s of of CL the

y=denom(CL) z=c o e f f ( y )

// e x t r a c t i n g // e x t r a c t i n g polynomial , comparing

denominator
8 9 10 11 12 13 14

/ / Wn 2 = z ( 1 , 1 )

the //

c o e f f i c i e n t s Wn= n a t u r a l frequency

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

z e t a=z ( 1 , 2 ) /(2Wn) // z e t a =damping Wd Wn sqrt (1 z e t a 2) = Tp=%pi/Wd / / Tp= p e a k t i m e Mp=100exp((%pi z e t a ) / sqrt (1 z e t a 2) ) / / p e a k


overshoot

factor

15 16 17 18

Td=(1+0.7 z e t a ) /Wn / / Td= d e l a y t i m e a=atan ( sqrt (1 z e t a 2) / z e t a ) Tr=(%pia ) /Wd // Tr= r i s e time Ts=4/( z e t a Wn) // Ts= s e t t l i n g time Example 8.08 8.08.sci

1 2 3 4 5 6

p=poly ( [ 1 4 0 , 3 5 ] , s , c o e f f ) ; q=poly ( [ 0 , 1 0 , 7 , 1 ] , s , c o e f f ) ; G=p/q H=1 y=GH / / t y p e 1


// r e f e r i n g Kp= % i n f the & table 8.2 given in the book , for type 1 Ka =0

7 8 9 10 11 12 13

syms s Kv=l i m i t ( s y , s , 0 )
// g i v e n input is

/ / Kv=

velocity

error

c o e f f i c i e n t

r ( t ) =5 t

& R( s )= l a p l a c e ( r ( t ) )

R=l a p l a c e ( 5 t , t , s )
// s t e a d y state error =Lt s >0 sR ( S ) /1+G ( s ) H ( S ) for ramp input

e=l i m i t ( s R/(1+y ) , s , 0 ) / / e = e r r o r disp ( e , s t e a d y s t a t e e r r o r ) 33

Example 8.09 8.09.sci


1 2 3 4 5 6 7

p=poly ( [ 4 0 , 2 0 ] , s , c o e f f ) ; q=poly ( [ 0 , 0 , 5 , 6 , 1 ] , s , c o e f f ) ; G=p/q ; H=1; y=GH; / / t y p e 2 disp ( y , G( s )H( s= )


// r e f e r i n g Kp= % i n f the & table 8.2 given in the book , for type 2 Kv= % i n f

8 9

syms s t ; Ka=l i m i t ( s 2y , s , 0 )
c o e f f i c i e n t // g i v e n input is

/ / Ka=

accelaration

error

10 11 12 13 14

r ( t ) =1+3 t + t 2 / 2

& R( s )= l a p l a c e ( r ( t ) )

R=l a p l a c e ( (1+3 t +( t 2/2) ) , t , s )


// s t e a d y state error =Lt s >0 sR ( S ) /1+G ( s ) H ( S ) for ramp input

e=l i m i t ( s R/(1+y ) , s , 0 ) / / e = e r r o r disp ( e , s t e a d y s t a t e e r r o r ) Example 8.10 8.10.sci

1 2 3

s = poly ( 0 , s ) s y s = s y s l i n ( c , ( 2 0 ) / ( s 2+7 s +10) ) a=s y s / . ( 2 ( s +1) ) / / s i m p l i f y i n g t h e


loop

internal

feedback

4 5 6 7 8 9 10 11 12 13 14

b=202a ; disp ( b , G( s ) ) c =1; disp ( c , H( s ) ) OL=b c ; disp (OL, G( s )H( s ) ) , G( s ) H( s ) ) syms t s ; Kp=l i m i t ( s OL/ s , s , 0 ) / / K p = p o s i t i o n e r r o r c o e f f i c i e n t Kv=l i m i t ( s OL, s , 0 ) / / K v = v e l o c i t y e r r o r c o e f f i c i e n t Ka=l i m i t ( s 2OL, s , 0 ) / / K a = 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 16 17 18 19 20 21 22 23 24 25 26 27 28 29

// g i v e n

input

r ( t ) =6

R=l a p l a c e ( 6 , t , s )
// s t e a d y state error =Lt s >0 sR ( S ) /1+G ( s ) H ( S ) for given input

e1=l i m i t ( s R/(1+OL) , s , 0 ) ; disp ( e1 , e r r o r )


// g i v e n input r ( t ) =8 t

// e= e r r o r

M a p l a c e ( 8 t , t , s ) =l
// s t e a d y state error =Lt s >0 sR ( S ) /1+G ( s ) H ( S ) for given input

e2=l i m i t ( s M/(1+OL) , s , 0 ) ; disp ( e2 , e r r o r )


// g i v e n input

// e= e r r o r

r ( t ) = 1 0 + 4 t +3 t 2 / 2

N=l a p l a c e ( 10+4 t +(3 t 2) /2 , t , s )


// s t e a d y state error =Lt s >0 sR ( S ) /1+G ( s ) H ( S ) for given input

e3=l i m i t ( s N/(1+OL) , s , 0 ) ; disp ( e3 , e r r o r ) Example 8.11 8.11.sci

// e= e r r o r

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

s = poly ( 0 , s ) s y s 1 = s y s l i n ( c , ( s ) / ( s +6) ) ; s y s 2 = s y s l i n ( c , ( s +2) / ( s +3) ) ; s y s 3 = s y s l i n ( c , ( 5 ) / ( ( s +3) s 3 ) ) ; a=s y s 2+s y s 3 ; disp ( a , H( s ) ) b=s y s 1 ; disp ( b , G( S ) ) y=ab ; disp ( y , G( S )H( S ) ) syms s Kp=l i m i t ( s y/ s , s , 0 ) / / K p = p o s i t i o n e r r o r c o e f f i c i e n t Kv=l i m i t ( s y , s , 0 ) / / K v = v e l o c i t y e r r o r c o e f f i c i e n t Ka=l i m i t ( s 2y , s , 0 ) / / K a = 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 2

s=%s ; syms k t ; 35

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

y=k / ( ( s +1) s 2( s +4) ) ; disp ( y , G( s )H( s )= ) r =1+(8 t ) +(18 t 2/2) ; disp ( r , r ( t )= ) R=l a p l a c e ( r , t , s ) ; disp (R, R( s )= ) e=l i m i t ( ( s R) /(1+y ) , s , 0 ) disp ( e , Ess= ) p r i n t f ( Given Ess = 0 . 8 \n ) e =0.8; k=72/e ; d i s p ( k , k=) Example 8.13 8.13.sci

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

syms s t k ; s = poly ( 0 , s ) ; y=k / ( s ( s +2) ) ; / / G ( disp ( y , G( s )H( s ) )

s )H( s )

/ / R= l a p l a c e ( 0 . 2 t , t , s )

R=l a p l a c e ( 0 . 2 t , t , s ) e=l i m i t ( s R/(1+y ) , s , 0 )


// g i v e n e <=0.02

a =[0.02]; b=[ 0.4]; m insolve (a , b) ; =l disp (m, k ) Example 8.14 8.14.sci

// S o l v e s

The

Linear

Equation

1 2 3 4 5 6 7 8

syms s , t , k ; s=%s ; y=k / ( s ( s +2) (1+0.5 s ) ) disp ( y , G( s )H( s ) )


/ / R= l a p l a c e ( 3 t , t , s )

//G( s )H( s )

R=l a p l a c e ( 3 t , t , s ) e=l i m i t ( s R/(1+y ) , s , 0 ) ; disp ( e , s t e a d y s t a t e e r r o r ) 36

9 10 11

k=4; / / g i v e n y=e ; 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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

s = poly ( 0 , s ) ; s y s = s y s l i n ( c , 1 8 0 / ( s ( s +6) ) ) disp ( sys , G( s )H( s ) ) syms t s ;


/ / R= l a p l a c e ( 4 t , t , s )

//G( s )H( s )

R=l a p l a c e ( 4 t , t , s ) ; e=l i m i t ( s R/(1+ s y s ) , s , 0 ) ; y=db l ( e ) ; disp ( y , s t e a d y s t a t e e r r o r ) syms k r e a l ;


// v a l u e of k if error reduced by 6% ; / / 1

e1=l i m i t ( s R/(1+k / ( s ( s +6) ) ) , s , 0 ) e1 =0.94 e / / 2


// now solving these two equations

a =[47]; b =[ 9000]; m insolve (a , b) ; =l disp (m, k ) Example 8.16 8.16.sci

1 2

s=%s ; F=s y s l i n ( c , ( 8 1 ) / ( s 2+6 s ) ) ;


function in forward path

// C r e a t e s

transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7

CL=F / .B
//

// C a l c u l a t e s CL with

closed loop

transfer

function

compare

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the the denominator c o e f f i c i e n t s of of CL the

y=denom(CL) z=c o e f f ( y )

// e x t r a c t i n g // e x t r a c t i n g polynomial , comparing

denominator
8

/ / Wn 2 = z ( 1 , 1 )

the

c o e f f i c i e n t s

37

9 10 11 12 13 14

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

//

Wn= n a t u r a l

frequency

z e t a=z ( 1 , 2 ) /(2Wn) // z e t a =damping Wd Wn sqrt (1 z e t a 2) = Tp=%pi/Wd / / Tp= p e a k t i m e Mp=100exp((%pi z e t a ) / sqrt (1 z e t a 2) ) / / p e a k


overshoot

factor

Example 8.17 8.17.sci


1 2

s=%s ; F=s y s l i n ( c , ( 2 5 ) / ( s 2+7 s ) ) ;


function in forward path

// C r e a t e s

transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7 8

k =20/25; // k= g a i n factor CL=k (F / .B) / / C a l c u l a t e s c l o s e d


// compare CL with

loop

transfer

function

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the the denominator c o e f f i c i e n t s of of CL the

y=denom(CL) z=c o e f f ( y )

// e x t r a c t i n g // e x t r a c t i n g polynomial , comparing

denominator
9 10 11 12 13 14 15

/ / Wn 2 = z ( 1 , 1 )

the //

c o e f f i c i e n t s Wn= n a t u r a l frequency

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

z e t a=z ( 1 , 2 ) /(2Wn) // z e t a =damping Wd Wn sqrt (1 z e t a 2) = Tp=%pi/Wd / / Tp= p e a k t i m e Mp=100exp((%pi z e t a ) / sqrt (1 z e t a 2) ) / / p e a k


overshoot

factor

16 17 18 19 20 21

Td=(1+0.7 z e t a ) /Wn / / Td= d e l a y t i m e a=atan ( sqrt (1 z e t a 2) / z e t a ) Tr=(%pia ) /Wd // Tr= r i s e time Ts=4/( z e t a Wn) // Ts= s e t t l i n g time
// y ( t )= e x p r e s s i o n for output

22

y =(20/25) (1 (exp(1 z e t a Wn t ) / sqrt (1 z e t a 2) ) sin (Wd t+atan ( z e t a / sqrt (1 z e t a 2) ) ) ) ; disp ( y , Y( t ) )

38

Example 8.19 8.19.sci


1 2

s=%s ; F=s y s l i n ( c , ( 1 4 4 ) / ( s 2+12 s ) ) ;


function in forward path

// C r e a t e s

transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7 8

k =20/25; // k= g a i n factor CL=k (F / .B) / / C a l c u l a t e s c l o s e d


// compare CL with

loop

transfer

function

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the the denominator c o e f f i c i e n t s of of CL the

y=denom(CL) z=c o e f f ( y )

// e x t r a c t i n g // e x t r a c t i n g polynomial , comparing

denominator
9 10 11 12 13 14 15

/ / Wn 2 = z ( 1 , 1 )

the //

c o e f f i c i e n t s Wn= n a t u r a l frequency

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

z e t a=z ( 1 , 2 ) /(2Wn) // z e t a =damping Wd Wn sqrt (1 z e t a 2) = Tp=%pi/Wd / / Tp= p e a k t i m e Mp=100exp((%pi z e t a ) / sqrt (1 z e t a 2) ) / / p e a k


overshoot

factor

16 17 18 19

Td=(1+0.7 z e t a ) /Wn / / Td= d e l a y t i m e a=atan ( sqrt (1 z e t a 2) / z e t a ) Tr=(%pia ) /Wd // Tr= r i s e time Ts=4/( z e t a Wn) // Ts= s e t t l i n g time Example 8.20 8.20.sci

1 2 3 4 5 6 7 8 9

i eee ( 2 ) ; syms k T; num=k ; den=s (1+ s T) ; G=num/ den ; disp (G, G( s )= ) H=1; CL=G/ .H; CL=s i m p l e (CL) ;

39

10

disp (CL, C( s ) /R( s )= )


transfer function CL with // compare

// C a l c u l a t e s

closed loop

11 12

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) // e x t r a c t s num & den of symbolic

[ num , den ]=numden (CL)


function ( CL )

13 14

den=den /T; c o f a 0 = c o e f f s ( den , s , 0 )


function ( CL )

//

coeff

of

den

of

symbolic

15 16 17 18

c o f a 1 = c o e f f s ( den , s , 1 )
/ / Wn 2 = cof a 0 , comparing the c o e f f i c i e n t s

Wn =sqrt ( c o f a 0 ) disp (Wn, n a t u r a l f r e q u e n c y Wn )


frequency // c o f a 1 = 2 z e t a Wn

//

Wn= n a t u r a l

19 20

z e t a=c o f a 1 /(2Wn) Example 8.23-01 8.23.01.sci

1 2 3 4 5 6 7 8 9

s= poly ( 0 , s ) ; s y s = s y s l i n ( c , 1 0 / ( s +2) ) ; / / G ( disp ( sys , G( s )H( s ) ) F=1/(1+ s y s ) syms t s ; Co=l i m i t ( s F/ s , s , 0 ) / / K o = L t s >0 a =(3) ; e=Coa ; disp ( e , s t e a d y s t a t e e r r o r ) Example 8.23-02 8.23.02.sci

s )H( s )

(1/(1+G( s )H( S ) )

1 2 3 4 5 6 7 8

s= poly ( 0 , s ) ; s y s = s y s l i n ( c , 1 0 / ( s +2) ) ; / / G ( s ) H ( s ) disp ( sys , G( s )H( s ) ) F=1/(1+ s y s ) syms t s ; Co=l i m i t ( s F/ s , s , 0 ) / / K o = L t s >0 ( 1 / ( 1 + G ( d=d i f f ( s F/ s , s ) C1=l i m i t ( d i f f ( s F/ s , s ) , s , 0 ) / / K 1 = L t s >0 40

s )H( S ) )

( dF ( s ) / d s )

9 10 11 12

a=(2 t ) ; b=d i f f ( ( 2 t ) , t ) ; e=Coa+C1b ; disp ( e , s t e a d t s t a t e e r r o r ) Example 8.23-03 8.23.03.sci

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

s= poly ( 0 , s ) ; s y s = s y s l i n ( c , 1 0 / ( s +2) ) ; / / G ( s ) H ( s ) disp ( sys , G( s )H( s ) ) F=1/(1+ s y s ) syms t s ; Co=l i m i t ( s F/ s , s , 0 ) / / K o = L t s >0 ( 1 / ( 1 + G ( s ) H ( S ) ) d=d i f f ( s F/ s , s ) C1=l i m i t ( d i f f ( s F/ s , s ) , s , 0 ) / / K 1 = L t s >0 ( d F ( s ) / d s C2=l i m i t ( d i f f ( d , s ) , s , 0 ) / / K 2 = L t s >0 ( d 2 F ( s ) / d s ) a =(( t 2 ) / 2) ; b=d i f f ( ( t 2) /2 , t ) ; c=d i f f ( b , t ) ; e=Coa+C1b+C2 c ; disp ( e , s t e a d y s t a t e e r r o r ) Example 8.23-04 8.23.04.sci

1 2 3 4 5 6 7 8 9 10

s= poly ( 0 , s ) ; s y s = s y s l i n ( c , 1 0 / ( s +2) ) ; / / G ( s ) H ( s ) disp ( sys , G( s )H( s ) ) F=1/(1+ s y s ) syms t s ; Co=l i m i t ( s F/ s , s , 0 ) / / K o = L t s >0 ( 1 / ( 1 + G ( s ) H ( S ) ) d=d i f f ( s F/ s , s ) C1=l i m i t ( d i f f ( s F/ s , s ) , s , 0 ) / / K 1 = L t s >0 ( d F ( s ) / d s C2=l i m i t ( d i f f ( d , s ) , s , 0 ) / / K 2 = L t s >0 ( d 2 F ( s ) / d s )
// g i v e n ) input is r ( t ) =1+2 t +( t 2 ) / 2

& R( s )= l a p l a c e ( r ( t )

11 12 13

a=(1+2 t +( t 2) /2 ) ; b=d i f f ( a , t ) ; c=d i f f ( b , t ) ; 41

14

e=Coa+C1b+C2 c

// e r r o r

by

dynamic

c o e f f i c i e n t

method

Example 8.24 8.24.sci


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

s= poly ( 0 , s ) ; s y s 1 = s y s l i n ( c , ( s +3) / ( s +5) ) ; s y s 2= s y s l i n ( c , ( 1 0 0 ) / ( s +2) ) ; s y s 3= s y s l i n ( c , ( 0 . 1 5 ) / ( s +3) ) ; G=s y s 1 s y s 2 s y s 3 25 H=1; y=GH; / / G ( s ) H ( s ) disp ( y , G( s )H( s ) ) F=1/(1+y ) syms t s ; Co=l i m i t ( s F/ s , s , 0 ) / / K o = L t s >0 ( 1 / ( 1 + G ( s ) H ( S ) ) d=d i f f ( s F/ s , s ) C1=l i m i t ( d i f f ( s F/ s , s ) , s , 0 ) / / K 1 = L t s >0 ( d F ( s ) / d s C2=l i m i t ( d i f f ( d , s ) , s , 0 ) / / K 2 = L t s >0 ( d 2 F ( s ) / d s ) a=(1+(2 t ) +(5( t 2/2) ) ) ; b=d i f f ( a , t ) ; c=d i f f ( b , t ) ; e=Coa+C1b+C2 c ; disp ( e , s t e a d t s t a t e e r r o r ) Example 8.32 8.32.sci

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

s=%s ; s y s=s y s l i n ( c ,(9(1+2 s ) ) / ( s 2+0.6 s +9) ) ; disp ( sys , C( s ) /R( s )= )


// g i v e n r ( t ) =u ( t )

syms t s ; R=l a p l a c e ( 1 , t , s ) ; disp (R, R( s )= ) C=R s y s ; disp (C, C( s )= ) c=i l a p l a c e (C, s , t ) disp ( c , c ( t )= ) G=9/( s 3+0.6 s 2 ) ; 42

13 14 15 16 17 18 19 20 21 22 23

disp (G, G( s )= ) H=1; y=1+GH; syms t s ; Kp=l i m i t ( s G/ s , s , 0 ) Kv=l i m i t ( s G, s , 0 ) Ka=l i m i t ( s 2G, s , 0 ) R=l a p l a c e ( (1+ t +( t 2/2) ) , t , s )
// s t e a d y state error =Lt s >0 sR ( S ) /1+G ( s ) H ( S ) for ramp input

e=l i m i t ( s R/(1+y ) , s , 0 ) ; / / e = e r r o r disp ( e , s t e a d y s t a t e e r r o r ( Ess ) )

43

Chapter 9 Feedback Characteristics of control Systems


Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spokentutorial.org) for the installation of Symbolic Toolbox

9.1

Scilab Code

Example 9.01 9.01.sci


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

s=%s ; G=s y s l i n ( c , 2 0 / ( s ( s +4) ) ) H= 0 . 3 5 ; y=GH; S=1/(1+y ) ; disp ( S , 1/(1+G( s ) H( s ) ) )


// g i v e n w=1.2

w=1.2 s=%iw S=horner ( S , s ) / / c a l c u l a t e s v a l u e o f a=abs ( S ) disp ( a , s e n s i t i v i t y o f open l o o p )

at

44

16 17 18 19 20

F=y/(1+y ) disp (F , (G( s ) H( s ) ) /(1+G( s ) H( s ) ) ) S=horner (F , s ) / / c a l c u l a t e s v a l u e o f b=abs ( S ) disp ( b , s e n s i t i v i t y o f c l o s e d l o o p ) Example 9.02 9.02.sci

at

1 2 3 4 5 6 7 8 9 10

s=%s ; s y s 1=s y s l i n ( c , 9 / ( s ( s +1.8) ) ) ; syms Td ; s y s 2 =1+(s Td) ; s y s 3=s y s 1 s y s 2 ; H=1; CL=s y s 3 / .H; / / C a l c u l a t e s c l o s e d l o o p disp (CL, C( s ) /R( s ) )
// compare CL with

transfer

function

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) // e x t r a c t s num & den of symbolic

[ num , den ]=numden (CL)


function CL

11 12

den=den / 5 ; c o f a 0 = c o e f f s ( den , s , 0 )
function CL

//

coeff

of

den

of

symbolic

13 14 15 16

c o f a 1 = c o e f f s ( den , s , 1 )
/ / Wn 2 = cof a 0 , comparing the c o e f f i c i e n t s

Wn =sqrt ( c o f a 0 ) disp (Wn, n a t u r a l f r e q u e n c y Wn )


frequency // c o f a 1 = 2 z e t a Wn

//

Wn= n a t u r a l

17 18 19 20 21 22 23

z e t a=c o f a 1 /(2Wn) z e t a =1; disp ( z e t a , f o r c r i t i c a l y damped f u n c t i o n z e t a ) Td=((2Wn) 1.8) /9 Ts=4/( z e t a Wn) ; Ts=d bl ( Ts ) ; disp ( Ts , s e t t l i n g time Ts ) Example 9.03 9.03.sci

s=%s ; 45

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

G=s y s l i n ( c , 4 0 / ( s ( s +4) ) ) H= 0 . 5 0 ; y=GH; S=1/(1+y ) ; disp ( S , 1/(1+G( s ) H( s ) ) )


// g i v e n w=1.3

w=1.3 s=%iw S=horner ( S , s ) a=abs ( S ) disp ( a , s e n s i t i v i t y o f open l o o p ) F=y/(1+y ) disp (F , (G( s ) H( s ) ) /(1+G( s ) H( s ) ) ) S=horner (F , s ) b=abs ( S ) disp ( b , s e n s i t i v i t y o f c l o s e d l o o p ) Example 9.04 9.04.sci

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

s=%s ; syms s ; syms Wn z e t a A H r e a l ; T= 6 . 2 8 ; Wn=(8%pi ) /T; z e t a =0.3 n= Wn 2 ; d=s 2+2 z e t a Wn s+ Wn 2 ; G1=n/d ; disp (G1 , G1( s ) ) G=AG1 ; disp (G, G( s ) ) S1=( d i f f (G,A) ) (A/G) ; a=s i m p l e ( S1 ) ; disp ( a , open l o o p s e n s i t i v i t y f o r changes i n A ) M =G/ .H; p=s i m p l e (M) S2=( d i f f ( p ,A) ) (A/p ) ; b=s i m p l e ( S2 ) ; 46

20 21 22 23

disp ( b , c l o s e d l o o p s e n s i t i v i t y f o r changes i n A ) S3=( d i f f ( p ,H) ) (H/p ) ; c=s i m p l e ( S3 ) ; disp ( c , c l o s e d l o o p s e n s i t i v i t y f o r changes i n H ) Example 9.05 9.05.sci

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

s=%s ; s y s 1=s y s l i n ( c , ( s +3)/ s ) ; syms u rp k H RL ; num2=uRL s ( s +2) ; den2=(rp+RL) ( s +3) ; s y s 2=num2/ den2 ; num3=k ; den3=s +2; s y s 3=num3/ den3 ; s y s=s y s 1 s y s 2 s y s 3 ; disp ( sys , G( s )= ) ; RL=10103; rp =4103; s y s=eval ( s y s ) s y s=f l o a t ( s y s ) disp ( sys , s y s= ) ; disp (H, H( s ) ) ; M y s / .H / / G ( s ) / 1 + G ( s ) H ( S ) =s M i m p l e (M) =s S=( d i f f (M, u ) ) ( u/M) ; S=s i m p l e ( S ) ; disp ( S , system s e n s i t i v i t y due t o v a r i a t i o n o f u= ) ; H= 0 . 3 ; u=12; S=eval ( S ) / / e q 1 S=0.04; k =((7/S ) 7)/18 ; / / f r o m e q 1 disp ( k , K= ) Example 9.06 9.06.sci 47

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

G=210; H= 0 . 1 2 ; syms Eo Er p r i n t f ( f o r c l o s e d l o o p system ) s y s=G/ .H; / / E o / E r =G / ( 1 + GH ) disp ( sys , Eo/Er= ) Eo=240 / / g i v e n Er=Eo / 8 . 0 1 5 2 ; disp ( Er , Er= ) p r i n t f ( f o r open l o o p system ) disp (G, Eo/Er= ) Er=Eo/G; G=210; disp ( Er , Er= )
// p r i n t f ( s i n c e gain is G is reduced by 12%, the new value of 784.8 V) ;

16 17 18 19 20 21 22

S=1/(1+GH) disp ( S , ( %change i n M) / ( %change i n G)= ) disp ( 1 2 , %CHANGE IN G= ) y =120.03869; disp ( y , %CHANGE IN M ) = p r i n t f ( f o r open l o o p system ) disp ( 2 8 . 8 1 0 0 / 2 4 0 , %change i n Eo ) Example 9.07 9.07.sci

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

s=%s ; s y s 1=s y s l i n ( c , 2 0 / ( s ( s +2) ) ) ; syms Kt ; s y s 2=Kt s ; s y s 3=s y s 1 / . s y s 2 ; p=s i m p l e ( s y s 3 ) ; disp ( p , G( s )= ) H=1; s y s=s y s 3 / .H; s y s=s i m p l e ( s y s ) ; disp ( sys , C( s ) /R( s )= ) [ num , den ]=numden ( s y s ) 48

13

c o f a 0 = c o e f f s ( den , s , 0 )
function CL

//

coeff

of

den

of

symbolic

14 15 16 17 18

c o f a 1 = c o e f f s ( den , s , 1 )
/ / Wn 2 = cof a 0 , comparing the c o e f f i c i e n t s

Wn =sqrt ( c o f a 0 ) Wn =db l (Wn) ; disp (Wn, n a t u r a l f r e q u e n c y Wn ) =


natural frequency // c o f a 1 = 2 z e t a Wn

//

Wn=

19 20 21 22 23 24 25 26 27 28 29 30 31

z e t a=c o f a 1 /(2Wn) zeta =0.6; Kt=((2 z e t a Wn) 2) / 2 0 ; disp ( Kt , Kt= ) Wd Wn sqrt (1 z e t a 2) ; = disp (Wd, Wd ) = Tp=%pi/Wd; disp (Tp , Tp= ) Mp=100exp((%pi z e t a ) / sqrt (1 z e t a 2) ) ; disp (Mp, Mp= ) Ts=4/( z e t a Wn) ; disp ( Ts , Ts= ) Example 9.08 9.08.sci

1 2 3 4 5 6 7 8

s=%s ; p r i n t f ( 1 ) z e t a & Wn without Kd ) G=60 s y s l i n ( c , 1 / ( s ( s +4) ) ) ; disp (G, G( S )= ) CL=G/ .H; disp (CL, C( s ) /R( s )= ) 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 z=c o e f f ( 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
denominator polynomial , comparing the // c o e f f i c i e n t s Wn= n a t u r a l / / Wn 2 = z ( 1 , 1 )

of of

CL the

9 10 11 12 13

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

frequency

z e t a=z ( 1 , 2 ) /(2Wn) s y s 1=s y s l i n ( c , 1 / ( s ( s +4) ) ) ; 49

14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

syms Kd ; p r i n t f ( 2 )Kd f o r z e t a =0.60 with c o n t r o l l e r ) s y s 2=s Kd ; s y s 3=s y s 1 / . s y s 2 ; G=s y s 3 6 0 ; disp (G, G( s )= ) H=1; s y s=G/ .H; disp ( sys , C( s ) /R( s )= ) [ num , den ]=numden ( s y s ) c o f a 0 = c o e f f s ( den , s , 0 ) c o f a 1 = c o e f f s ( den , s , 1 )
/ / Wn 2 = cof a 0 , comparing the c o e f f i c i e n t s

Wn =sqrt ( c o f a 0 ) Wn =db l (Wn) ; disp (Wn, n a t u r a l f r e q u e n c y Wn ) =


// c o f a 1 = 2 z e t a Wn

z e t a =0.60 Kd=(2 z e t a Wn)4 Example 9.09 9.09.sci

1 2 3 4 5 6 7 8 9

s=%s ; p r i n t f ( 1 ) without c o n t r o l l e r ) G=s y s l i n ( c , 1 2 0 / ( s ( s +12.63) ) ) ; disp (G, G( s )= ) H=1; CL=G/ .H; disp (CL, C( s ) /R( s )= ) 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 z=c o e f f ( 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
denominator polynomial , comparing the c o e f f i c i e n t s / / Wn 2 = z ( 1 , 1 )

of of

CL the

10 11 12 13 14 15

Wn =sqrt ( z ( 1 , 1 ) ) ; disp (Wn, Wn ) =


/ / 2 z e t a Wn= z ( 1 , 2 )

//

Wn= n a t u r a l

frequency

z e t a=z ( 1 , 2 ) /(2Wn) ; disp ( z e t a , z e t a= ) 50

16 17 18 19 20 21 22 23

24 25 26 27 28 29 30 31 32

p r i n t f ( 2 ) with c o n t r o l l e r ) G=s y s l i n ( c , ( 1 2 0 ( 3 0 + s ) ) / ( s ( s +12.63) 30) ) ; d i s p (G, G( s )= ) CL=G/ .H; d i s p (CL, C( s ) /R( s )= ) den=denom (CL) den=den /30 // e x t r a c t i n g t he denominator o f CL z=c o e f f ( den ) // e x t r a c t i n g t he c o e f f i c i e n t s o f t he denominator p o l y n o m i a l //Wn2=z ( 1 , 1 ) , comparing t he c o e f f i c i e n t s Wn q r t ( z ( 1 , 1 ) ) ; =s d i s p (Wn, Wn ) = // Wn a t u r a l f r e q u e n c y =n //2 z e t a Wn ( 1 , 2 ) =z z e t a=z ( 1 , 2 ) /(2Wn) ; Mp=100 exp ((%pi z e t a ) / s q r t (1 z e t a 2) ) ; d i s p (Mp, Mp= ) Ts=4/( z e t a Wn) ; d i s p ( Ts , Ts= ) Example 9.10 9.10.sci

1 2 3 4 5 6 7 8 9 10

s=%s ; p r i n t f ( 1 ) without c o n t r o l l e r ) G=64 s y s l i n ( c , 1 / ( s ( s +4) ) ) ; disp (G, G( s )= ) H=1; CL=G/ .H; disp (CL, C( s ) /R( s )= )
// E x t r a c t i n g the denominator of CL

y=denom(CL)
// E x t r a c t i n g polynomial the c o e f f i c i e n t s of the denominator

11 12 13 14 15 16

z=c o e f f ( y )
/ / Wn 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s

Wn =sqrt ( z ( 1 , 1 ) ) ;
/ / Wn= n a t u r a l frequency

disp (Wn, Wn ) = p r i n t f ( 2 ) with c o n t r o l l e r ) 51

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

syms K; s y s 1=s y s l i n ( c , 1 / ( s ( s +4) ) ) ; s y s 2=s y s 1 / . ( s K) ; G=64 s y s 2 d i s p (G, G( s )= ) s y s=G/ .H; s y s=s i m p l e ( s y s ) ; d i s p ( sys , C( s ) /R( s )= ) [ num , den ]=numden ( s y s ) // C o e f f o f den o f s y m b o l i c f u n c t i o n CL c o f a 0 = c o e f f s ( den , s , 0 ) c o f a 1 = c o e f f s ( den , s , 1 ) //Wn2= c o f a 0 , comparing t he c o e f f i c i e n t s Wn q r t ( c o f a 0 ) =s Wn =db l (Wn) ; //Wn a t u r a l f r e q u e n c y =n d i s p (Wn, n a t u r a l f r e q u e n c y Wn ) = // c o f a 1 =2 z e t a Wn z e t a=c o f a 1 /(2Wn) zeta =0.6; k=(16 z e t a )4 d i s p ( k , K= ) Example 9.11 9.11.sci

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

p r i n t f ( 2 ) with c o n t r o l l e r ) syms K; s y s 1=s y s l i n ( c , 1 / ( s ( s +1.2) ) ) ; s y s 2=s y s 1 / . ( s K) ; G=16 s y s 2 ; G=s i m p l e (G) d i s p (G, G( s )= ) s y s=G/ .H; s y s=s i m p l e ( s y s ) ; d i s p ( sys , C( s ) /R( s )= ) [ num , den ]=numden ( s y s ) den=den / 5 ; // so t h a t c o e f f o f s 2=1 52

13

14 15 16 17 18

19 20 21 22 23 24 25 26 27 28 29 30 31

c o f a 0 = c o e f f s ( den , s , 0 ) // c o e f f o f den o f s y m b o l i c f u n c t i o n CL c o f a 1 = c o e f f s ( den , s , 1 ) //Wn2= c o f a 0 , comparing t he c o e f f i c i e n t s Wn q r t ( c o f a 0 ) =s Wn =db l (Wn) ; d i s p (Wn, n a t u r a l f r e q u e n c y Wn ) = // Wn = natural frequency // c o f a 1 =2 z e t a Wn // z e t a=c o f a 1 /(2Wn) zeta =0.56; k=(8 z e t a ) 1.2 d i s p ( k , K= ) Wd Wn s q r t (1 z e t a 2) ; = d i s p (Wd, Wd ) = Tp=%pi/Wd; d i s p (Tp , Tp= ) Mp=100 exp ((%pi z e t a ) / s q r t (1 z e t a 2) ) ; d i s p (Mp, Mp= ) Ts=4/( z e t a Wn) ; d i s p ( Ts , Ts= )

53

Chapter 10 Stability
Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spokentutorial.org) for the installation of Symbolic Toolbox. You can also refer the inbuilt function(routh-t) for generating Routh Table.

10.1

Scilab Code

Example 10.02-01 10.02.01.sci


1 2 3 4 5 6 7 8 9

s = poly ( 0 , s ) ; p=poly ( [ 1 2 ] , s , c o e f f ) ; q=poly ( [ 0 2 4 1 ] , s , c o e f f ) ; G=p/q ; H=poly ( [ 0 . 5 ] , s , c o e f f ) ;


// c h a r a c t e r i s t i c equation is 1+G ( s ) H ( s ) =0

y=1+GH r=numer( y ) disp ( =0 , r , c h a r a c t e r i s t i c s e q u a t i o n i s ) Example 10.02-02 10.02.02.sci

1 2 3

s = poly ( 0 , s ) ; p=poly ( [ 7 ] , s , c o e f f ) ; q=poly ( [ 2 3 1 ] , s , c o e f f ) ; 54

4 5 6 7 8 9

G=p/q ; H=poly ( [ 0 1 ] , s , c o e f f ) ;
// c h a r a c t e r i s t i c equation is 1+G ( s ) H ( s ) =0

y=1+GH r=numer( y ) disp ( =0 , r , c h a r a c t e r i s t i c s e q u a t i o n i s ) Example 10.02-03 10.02.03.sci

1 2 3 4 5 6 7

s = poly ( 0 , s ) ; G=s y s l i n ( c , 2 / ( s 2+2 s ) ) H=s y s l i n ( c , 1 / s ) ;


// c h a r a c t e r i s t i c equation is 1+G ( s ) H ( s ) =0

y=1+GH r=numer( y ) disp ( =0 , r , c h a r a c t e r i s t i c s e q u a t i o n i s ) Example 10.03 10.03.sci

1 2 3 4 5 6 7

s=%s ; m 3+5 s 2+10 s +3; =s r=c o e f f (m) n=length ( r ) ; r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ; r outh =[ routh ;det ( routh ) / routh ( 2 , 1 ) , 0 ] ; 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
routh matrix

sub

block

of

8 9 10 11 12 13 14 15 16 17 18

r outh =[ routh ;det ( t ) / t ( 2 , 1 ) , 0 ] c =0; for i =1:n i f ( routh ( i , 1 )< 0 ) c=c +1; end end i f ( c>=1) p r i n t f ( system i s u n s t a b l e ) e l s e ( system i s s t a b l e ) end 55

Example 10.04 10.04.sci


1 2 3 4 5 6 7

s=%s ; m 3+2 s 2+3 s +10; =s r=c o e f f (m) n=length ( r ) ; r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ; r outh =[ routh ;det ( routh ) / routh ( 2 , 1 ) , 0 ] ; 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
routh matrix

sub

block

of

8 9 10 11 12 13 14 15 16 17 18

r outh =[ routh ;det ( t ) / t ( 2 , 1 ) , 0 ] c =0; for i =1:n i f ( routh ( i , 1 ) <0) c=c +1; end end i f ( c>=1) p r i n t f ( system i s u n s t a b l e ) e l s e ( system i s s t a b l e ) end Example 10.05-01 10.05.01.sci

1 2 3 4 5 6 7

9 10

i eee ( 2 ) s=%s ; m 4+6 s 3+21 s 2+36 s +20 =s r=c o e f f (m) n=length ( r ) ; r outh =[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ] r outh =[ routh ;det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,det ( routh ( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) , 0 , 0 ] ; disp ( routh , routh= ) 56

11 12 13 14 15 16 17 18 19 20

c =0; for i =1:n i f ( routh ( i , 1 ) <0) c=c +1; end end i f ( c>=1) p r i n t f ( system i s u n s t a b l e ) e l s e ( system i s s t a b l e ) end Example 10.05-02 10.05.02.sci

1 2 3 4 5 6

9 10 11 12 13 14 15 16 17 18 19

s=%s ; m 5+6 s 4+3 s 3+2 s 2+ s+1 =s r=c o e f f (m) n=length ( r ) r outh =[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ] r outh =[ routh ;det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] r outh =[ routh ;det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,det ( routh ( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] r outh =[ routh ;det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) ,det ( routh ( 3 : 4 , 2 : 3 ) ) / routh ( 4 , 2 ) , 0 ] r outh =[ routh ;det ( routh ( 4 : 5 , 1 : 2 ) ) / routh ( 5 , 1 ) , 0 , 0 ] c =0; for i =1:n i f ( routh ( i , 1 ) <0) c=c +1; end end i f ( c>=1) p r i n t f ( system i s u n s t a b l e ) e l s e ( system i s s t a b l e ) end Example 10.06 10.06.sci 57

1 2 3 4

i eee ( 2 ) s=%s ; m 5+2 s 4+4 s 3+8 s 2+3 s+1 =s r=c o e f f (m) ; / / E x t r a c t s t h e c o e f f i c i e n t


polynomial

of

the

5 6 7 8 9

10

11 12 13 14

n=length ( r ) ; r outh =[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ] syms eps ; r outh =[ routh ; eps ,det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,det ( routh ( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) ,det ( routh ( 3 : 4 , 2 : 3 ) ) / routh ( 4 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 4 : 5 , 1 : 2 ) ) / routh ( 5 , 1 ) , 0 , 0 ] ; disp ( routh , routh= )
/ / To check the s t a b i l i t y // P u t t i n g the value of

r outh ( 4 , 1 )=8 l i m i t ( 5/ eps , eps , 0 ) ;


e p s =0 in routh (4 ,1)

15 16

disp ( routh ( 4 , 1 ) , routh ( 4 , 1 )= ) r outh ( 5 , 1 )= l i m i t ( routh ( 5 , 1 ) , eps , 0 ) ;


value of e p s =0 in routh (5 ,1)

// P u t t i n g

the

17 18 19

disp ( routh ( 5 , 1 ) , routh ( 5 , 1 ) = ) r outh p r i n t f ( There a r e two sign changes o f f i r s t column , hence t h e system i s u n s t a b l e \n ) Example 10.07 10.07.sci

1 2 3

s=%s ; m 5+2 s 4+2 s 3+4 s 2+4 s+8 =s r outh=routh t (m) / / T h i s F u n c t i o n


table

generates

the

Routh

4 5 6 7 8 9

c =0; for i =1:n i f ( routh ( i , 1 ) <0) c=c +1; end end 58

10 11 12 13

i f ( c>=1) p r i n t f ( system i s u n s t a b l e ) e l s e ( system i s s t a b l e ) end Example 10.08 10.08.sci

1 2 3 4 5 6

8 9 10 11 12 13 14 15 16 17 18

s=%s ; m 4+5 s 3+2 s 2+3 s+2 =s r=c o e f f (m) n=length ( r ) ; r outh =[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ] r outh =[ routh ;det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,det ( routh ( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) , 0 , 0 ] c =0; for i =1:n i f ( routh ( i , 1 ) <0) c=c +1; end end i f ( c>=1) p r i n t f ( system i s u n s t a b l e ) e l s e ( system i s s t a b l e ) end Example 10.09 10.09.sci

1 2 3 4

i eee ( 2 ) ; s=%s ; m 5+ s 4+3 s 3+3 s 2+4 s+8 =s r=c o e f f (m) ; / / E x t r a c t s t h e


polynomial

c o e f f i c i e n t

of

the

5 6 7

n=length ( r ) ; r outh =[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ] syms eps ; 59

8 9

10

11 12 13 14

r outh =[ routh ; eps ,det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,det ( routh ( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) ,det ( routh ( 3 : 4 , 2 : 3 ) ) / routh ( 4 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 4 : 5 , 1 : 2 ) ) / routh ( 5 , 1 ) , 0 , 0 ] ; disp ( routh , routh= )
/ / To check the s t a b i l i t y // P u t t i n g the value

r outh ( 4 , 1 )=l i m i t ( routh ( 4 , 1 ) , eps , 0 ) ;


of e p s =0 in routh (4 ,1)

15 16

disp ( routh ( 4 , 1 ) , routh ( 4 , 1 )= ) r outh ( 5 , 1 )= l i m i t ( routh ( 5 , 1 ) , eps , 0 ) ;


value of e p s =0 in routh (5 ,1)

// P u t t i n g

the

17 18 19

disp ( routh ( 5 , 1 ) , routh ( 5 , 1 ) = ) r outh p r i n t f ( There a r e two sign changes o f f i r s t column , hence t h e system i s u n s t a b l e \n ) Example 10.10 10.10.sci

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

i eee ( 2 ) ; syms s k ; m 4+4 s 3+7 s 2+6 s+k ; =s c o f a 0 = c o e f f s (m, s , 0 ) ; c o f a 1 = c o e f f s (m, s , 1 ) ; c o f a 2 = c o e f f s (m, s , 2 ) ; c o f a 3 = c o e f f s (m, s , 3 ) ; c o f a 4 = c o e f f s (m, s , 4 ) ; r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 cof a 4 ]

15

16

n=length ( r ) ; r outh =[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ] r outh =[ routh ;det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,det ( routh ( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) , 0 , 0 ] ; 60

17

disp ( routh , routh= ) Example 10.11 10.11.sci

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

i eee ( 2 ) ; syms s k ; m=(24/100) s 3+ s 2+ s+k ; c o f a 0 = c o e f f s (m, s , 0 ) ; c o f a 1 = c o e f f s (m, s , 1 ) ; c o f a 2 = c o e f f s (m, s , 2 ) ; c o f a 3 = c o e f f s (m, s , 3 ) ; r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ] n=length ( r ) ; r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] r outh =[ routh ;det ( routh ) / routh ( 2 , 1 ) , 0 ] 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
routh matrix

sub

block

of

13 14 15 16 17 18 19 20

r outh =[ routh ;det ( t ) / routh ( 3 , 1 ) , 0 ] disp ( routh , routh= ) ; r outh ( 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 k =1/0.24; disp ( k , K( m a r g i n a l )= ) disp ( =0 , ( s 2)+k , a u x i l l a r y e q u a t i o n ) s=sqrt(k ) ; disp ( s , Frequency o f o s c i l l a t i o n ( i n rad / s e c )= ) Example 10.12 10.12.sci

1 2 3 4 5 6 7 8 9 10

i eee ( 2 ) ; syms p K s ; m 3+(p s 2 ) +(K+3) s +(2(K+1) ) =s c o f a 0 = c o e f f s (m, s , 0 ) ; c o f a 1 = c o e f f s (m, s , 1 ) ; c o f a 2 = c o e f f s (m, s , 2 ) ; c o f a 3 = c o e f f s (m, s , 3 ) ; r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ] n=length ( r ) ; r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ; 61

11 12

r outh =[ routh ;det ( routh ) / routh ( 2 , 1 ) , 0 ] ; 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


routh matrix

sub

block

of

13 14

r outh =[ routh ;det ( t ) / routh ( 3 , 1 ) , 0 ] ; disp ( routh , routh= ) Example 10.13 10.13.sci

1 2 3 4 5

i eee ( 2 ) ; s=%s ; m=2 s 4+(4 s 2)+1 r outh=routh t (m) roots (m)


(m)

// G e n e r a t e s // G i v e s the

the

Routh of

Table the Polynomial

Roots

disp ( 0 , th e plane of disp ( 0 , th e plane of disp ( 4 , th e = )

number o f r o o t s l y i n g i n th e l e f t h a l f sp l a n e= ) number o f r o o t s l y i n g i n th e r i g h t h a l f sp l a n e= ) number o f r o o t s l y i n g on t he i m a g i n a r y a x i s

Example 10.14 10.14.sci


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

13

i eee ( 2 ) ; syms s k ; m 4+6 s 3+10 s 2+8 s+k ; =s c o f a 0 = c o e f f s (m, s , 0 ) ; c o f a 1 = c o e f f s (m, s , 1 ) ; c o f a 2 = c o e f f s (m, s , 2 ) ; c o f a 3 = c o e f f s (m, s , 3 ) ; c o f a 4 = c o e f f s (m, s , 4 ) ; 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 ] n=length ( r ) ; r outh =[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ] r outh =[ routh ;det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ; r outh =[ routh ;det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,det ( routh ( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ; 62

14 15

r outh =[ routh ;det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) , 0 , 0 ] ; disp ( routh , routh= ) Example 10.15 10.15.sci

1 2 3 4 5 6 7 8 9 10 11

i eee ( 2 ) ; syms s T; m 2+(2T) s+1 =s c o f a 0 = c o e f f s (m, s , 0 ) ; c o f a 1 = c o e f f s (m, s , 1 ) ; c o f a 2 = c o e f f s (m, s , 2 ) ; r =[ c o f a 0 c o f a 1 c o f a 2 ] n=length ( r ) ; r outh =[ r ( [ 3 , 1 ] ) ; r ( 2 ) , 0 ] ; r outh =[ routh ;det ( routh ) / routh ( 2 , 1 ) , 0 ] ; disp ( routh , routh= ) Example 10.16 10.16.sci

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

i eee ( 2 ) s=%s ; m 6+2 s 5+7 s 4+10 s 3+14 s 2+8 s+8 =s r outh=routh t (m) ; disp ( routh , routh= ) c =0; for i =1:n i f ( routh ( i , 1 ) <0) c=c +1; end end i f ( c>=1) p r i n t f ( system i s u n s t a b l e ) e l s e ( system i s s t a b l e ) end

63

Chapter 11 Root Locus Method


Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spokentutorial.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 2 3 4

s=%s ; s y s 1=s y s l i n ( c , 1 / ( s +1) ) ; evans ( sys1 , 2 0 0 ) p r i n t f ( I f k i s v a r i e d from 0 t o any v a l u e , r o o t l o c u s v a r i e s from k t o 0 \n ) Example 11.02 11.02.sci

1 2 3 4

s=%s ; s y s 1=s y s l i n ( c , ( s +1) / ( s +4) ) ; evans ( sys1 , 1 0 0 ) p r i n t f ( r o o t l o c u s b e g i n s a t s=4 & ends a t s=1 ) Example 11.03 11.03.sci

64

Figure 11.1: Output Graph of S 11.01


1 2 3 4

s=%s ; s y s 1=s y s l i n ( c , ( s+3%i ) ( s+3+%i ) / ( ( s+2%i ) ( s+2+%i ) ) ) ; evans ( sys1 , 1 0 0 ) p r i n t f ( R o o t l o c u s s t a r t s from s=2+i & 2 i ends a t s =3+i &3 i \n ) Example 11.04 11.04.sci

1 2 3

s=%s ; H=s y s l i n ( c , ( s +1) / ( s +2) ) ; evans (H, 1 0 0 ) 65

Figure 11.2: Output Graph of S 11.02


4

p r i n t f ( C l e a r l y from th e graph i t o b s e r v e d t h a t g i v e n p o i n t 1+ i & 3+ i does not l i e on th e r o o t l o c u s \n )


// there lie is on another the locus process of the to check whether the points system

6 7 8 9

P=1+%i ; / / P= s e l e c t e d point k1=1/r e a l ( horner (H, P) ) Ns=H( num ) ; Ds=H( den ) ; roots ( Ds+k1Ns ) // do es not
root

contains

as

particular

10 11

P=3+%i ; / / P= s e l e c t e d k2=1/r e a l ( horner (H, P) ) ;

point

66

Figure 11.3: Output Graph of S 11.03


12 13

Ns=H( num ) ; Ds=H( den ) roots ( Ds+k2Ns ) // do es


root

not

contains

as

particular

Example 11.05 11.05.sci


1 2 3 4

s=%s ; H=s y s l i n ( c , 1 / ( s ( s +1) ( s +3) ) ) ; evans (H, 1 0 0 ) p r i n t f ( C l e a r l y from t he graph i t o b s e r v e d t h a t g i v e n p o i n t 0.85 l i e s on t he r o o t l o c u s \n ) 67

Figure 11.4: Output of S 11.04


5

//

there lie

is on

another the locus

process of the

to

check

whether

the

points

system

6 7 8 9 10

P= 0.85; / / P= s e l e c t e d point k=1/r e a l ( horner (H, P) ) ; disp ( k , k = ) Ns=H( num ) ; Ds=H( den ) ; r o o t s ( Ds+kNs ) // c o n t a i n s P as p a r t i c u l a r r o o t

68

Figure 11.5: Output of S 11.05 Example 11.06 11.06.sci


1 2 3 4

s=%s ; H=s y s l i n ( c , 1 / ( ( s +1) ( s +5) ) ) ; evans (H, 1 0 0 ) p r i n t f ( C l e a r l y from t he graph i t o b s e r v e d t h a t g i v e n p o i n t 0.85 l i e s on t he r o o t l o c u s \n )


// there lie is on another the locus process of the to check whether the points system point

6 7 8

P=3+5%i ; / / P= s e l e c t e d k=1/r e a l ( horner (H, P) ) ; disp ( k , k = )

69

Figure 11.6: Output of S 11.06


9 10

Ns=H( num ) ; Ds=H( den ) ; r o o t s ( Ds+kNs ) // c o n t a i n s P as p a r t i c u l a r r o o t Example 11.08 11.08.sci

1 2 3 4

s=%s ; H=s y s l i n ( c , ( s +2) / ( ( s +1) s ( s +4) ) ) ; evans (H, 1 0 0 ) p r i n t f ( From t he graph we o b s e r v e d that , \n a ) The no o f l o c i ending a t i n f i s 2 \n b ) Three l o c i w i l l s t a r t from s= 0,1 & 4,\n c ) One l o c i w i l l end a t 2 & 70

Figure 11.7: Output of S 11.08 r e m a i n i n g two w i l l end a t i n f ) Example 11.09 11.09.sci


1 2 3

s=%s ; H=s y s l i n ( c , ( s +2) / ( ( s +1) s ( s +4) ) ) ; evans (H, 1 0 0 ) Example 11.10 11.10.sci

n=3; 71

Figure 11.8: Output of S 11.09


2 3 4 5 6 7 8 9 10 11 12

disp ( n , no o f p o l e s= ) m=1; disp (m, no o f p o l e s= ) q=0; O=((2 q ) +1) / ( n 1 8 0 ; m) disp (O, q= ) q=1; O=((2 q ) +1) / ( n 1 8 0 ; m) disp (O, q= ) p r i n t f ( C e n t r o i d =((sum o f a l l r e a l p a r t o f p o l e s o f G( s )H( s ) ) (sum o f a l l r e a l p a r t o f z e r o s o f G( s )H( s ) ) / ( 72

13 14

n m) \n ) C=((014)(2) ) / 2 ; disp (C, c e n t r o i d= ) Example 11.11 11.11.sci

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

n=3; disp ( n , no o f p o l e s= ) m=0; disp (m, no o f p o l e s= ) q=0; O=((2 q ) +1) / ( n 1 8 0 ; m) disp (O, q= ) q=1; O=((2 q ) +1) / ( n 1 8 0 ; m) disp (O, q= ) q=2; O=((2 q ) +1) / ( n 1 8 0 ; m) disp (O, q= ) p r i n t f ( C e n t r o i d =((sum o f a l l r e a l p a r t o f p o l e s o f G( s )H( s ) ) (sum o f a l l r e a l p a r t o f z e r o s o f G( s )H( s ) ) / ( n m) \n ) C=((011)(0) ) / 3 ; disp (C, c e n t r o i d= ) Example 11.12 11.12.sci

16 17

1 2 3 4 5 6 7 8 9 10

n=4; disp ( n , no o f p o l e s= ) m=1; disp (m, no o f p o l e s= ) q=0; O=((2 q ) +1) / ( n 1 8 0 ; m) disp (O, q= ) q=1; O=((2 q ) +1) / ( n 1 8 0 ; m) disp (O, q= ) 73

11 12 13 14 15

q=2; O=((2 q ) +1) / ( n 1 8 0 ; m) disp (O, q= ) p r i n t f ( C e n t r o i d =((sum o f a l l r e a l p a r t o f p o l e s o f G( s )H( s ) ) (sum o f a l l r e a l p a r t o f z e r o s o f G( s )H( s ) ) / ( n m) \n ) C=((0245)(3) ) / 3 ; disp (C, c e n t r o i d= ) Example 11.13 11.13.sci

16 17

1 2 3 4

s=%s ; H=s y s l i n ( c , ( s +2) / ( ( s +1) s ( s +3) ) ) ; plzr (H) p r i n t f ( There a r e two a d j a c e n t p l a c e d p o l e s a t s=0 &s =1 \n ) p r i n t f ( One breakaway p o i n t e x i s t s between s=0 & s=1 \ n ) Example 11.14 11.14.sci

1 2 3 4

s=%s ; H=s y s l i n ( c , ( ( s +2) ( s +4) ) / ( ( s 2 ) ( s +5) ) ) ; plzr (H) p r i n t f ( There a r e two a d j a c e n t p l a c e d z e r o s a t s=2 &s =4 \n ) p r i n t f ( One b r e a k i n p o i n t e x i s t s between s=2 & s=4 \n ) Example 11.15 11.15.sci

1 2 3 4

s=%s ; H=s y s l i n ( c , ( s +6) / ( ( s +1) ( s +3) ) ) ; plzr (H) p r i n t f ( There a r e two a d j a c e n t p l a c e d p o l e s a t s=3 &s =1 \n ) 74

Figure 11.9: Output of S 11.13


5

p r i n t f ( One breakaway p o i n t e x i s t s between s=3 & s=1 \n ) p r i n t f ( One b r e a k i n p o i n t e x i s t s t o th e l e f t o f z e r o s a t s=6 \n ) Example 11.16 11.16.sci

1 2 3 4

s=%s ; H=s y s l i n ( c , 1 / ( ( s +1) s ( s +3) ) ) ; plzr (H) p r i n t f ( There a r e two a d j a c e n t p l a c e d p o l e s a t s=0 &s 75

Figure 11.10: Output of S 11.14 =1 \n ) p r i n t f ( One breakaway p o i n t e x i s t s between s=0 & s=1 \ n ) Example 11.17 11.17.sci
1 2 3 4 5

s=%s ; H=s y s l i n ( c , 1 / ( ( s +1) s ( s +3) ) ) ; evans (H, 1 0 0 ) syms k ; m 3+6 s 2+8 s+k ; =s 76

Figure 11.11: Output of S 11.15


6 7 8 9 10 11 12 13 14 15

c o f a 0 = c o e f f s (m, s , 0 ) ; c o f a 1 = c o e f f s (m, s , 1 ) ; c o f a 2 = c o e f f s (m, s , 2 ) ; c o f a 3 = c o e f f s (m, s , 3 ) ; r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ] n=length ( r ) ; r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ; r outh =[ routh ;det ( routh ) / routh ( 2 , 1 ) , 0 ] ; 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
routh matrix

sub

block

of

16

r outh =[ routh ;det ( t ) / t ( 2 , 1 ) , 0 ] 77

Figure 11.12: Output of S 11.16


17 18 19 20 21

disp ( 4 8 , K( m a r g i n a l )= ) disp ( =0 , ( 6 s 2 )+k , a u x i l l a r y e q u a t i o n ) k =48; s=sqrt(k / 6) ; disp ( s , s= ) Example 11.19 11.19.sci

1 2 3

s=%s ; H=s y s l i n ( c , 1 / ( ( s+1+%i ) s ( s+1%i ) ) ) ; evans (H, 1 0 0 ) 78

Figure 11.13: Output of S 11.17 Example 11.20 11.20.sci


1 2 3

s=%s ; H=s y s l i n ( c , 1 / ( ( s +3) s ( s +5) ) ) ; evans (H, 1 0 0 ) Example 11.21 11.21.sci

1 2 3

s=%s ; H=s y s l i n ( c , 1 / ( ( s+2+%i ) ( s +1) ( s+2%i ) ) ) ; evans (H, 1 0 0 ) 79

Figure 11.14: Output of S 11.19 Example 11.22 11.22.sci


1 2 3 4 5 6 7 8

s=%s ; num=r e a l ( poly ( [ 1 ] , s , c o e f f ) ) den=r e a l ( poly([1,2+%i,2%i ] , s ) ) H=num/ den evans (H, 1 0 0 ) k =1.5; disp ( k , K( d e s i g n )= )
// Kpure calculates the value of k at imaginary crossover

[ K,Y]=kpure (H) 80

Figure 11.15: Output of S 11.20


10 11 12

GM =K/k ; disp (GM, 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 /k ( d e s i g n )= ) disp (GM, g a i n margin= ) Example 11.23 11.23.sci

1 2 3 4 5

s=%s ; H=s y s l i n ( c , 1 / ( s ( ( s +3) 2 ) ) ) ; evans (H, 1 0 0 ) K=25; y=KH; / / e q 1 ) 81

Figure 11.16: Output of S 11.21


6 7 8 9 10 11 12 13 14 15

disp (KH, G( s )H( s )= ) ; disp ( =1 ,KH, mod(G( s )H( s ) ) ) ;


// on solving eq 1 for s =%i w this we get an equation m

w=poly ( 0 , w ) ; m =w3+9w25 n=roots (m) s=%in ( 1 ) p=horner ( y , s ) [ R, Theta ]= polar ( p ) PM=180+Theta

82

Figure 11.17: Output of S 11.22 Example 11.25 11.25.sci


1 2 3

s=%s ; H=s y s l i n ( c , 1 / ( ( s +1) s ( s +2) ( s +4) ) ) ; evans (H, 1 0 0 ) Example 11.26 11.26.sci

1 2 3

s=%s ; H=s y s l i n ( c , ( s +4) ( s +5) / ( ( s +1) ( s +3) ) ) ; evans (H, 1 0 0 ) 83

Figure 11.18: Output of S 11.23

Example 11.27 11.27.sci


1 2 3 4 5 6 7 8 9

s=%s ; syms k Wn; H=s y s l i n ( c , 1 / ( ( s +3) 2 s ) ) ; evans (H, 1 0 0 ) / / r o o t l o c u s p r i n t f ( To d e t e r m i n e t h e v a l u e o f Wn \n ) disp ( kH, G( s )H( s )= ) y=1+(kH) ; disp ( =0 , y , 1+G( s )H( s ) ) evans (H, 1 0 0 ) 84

Figure 11.19: Output of S 11.25


10 11 12 13 14 15 16 17 18 19 20 21

[ num , den ]=numden ( y ) c o f a 0 = c o e f f s (num , s , 0 ) ; c o f a 1 = c o e f f s (num , s , 1 ) ; c o f a 2 = c o e f f s (num , s , 2 ) ; c o f a 3 = c o e f f s (num , s , 3 ) ; r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ] n=length ( r ) ; r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ; r outh =[ routh ;det ( routh ) / routh ( 2 , 1 ) , 0 ] ; 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 85

sub

block

of

Figure 11.20: Output of S 11.26


routh
22 23 24 25 26 27 28 29 30

matrix

r outh =[ routh ;det ( t ) / t ( 2 , 1 ) , 0 ]


// to obtain Wn

disp ( =0 , ( ( 6 s 2) +54) , a u x i l l a r y eq ) p=(6( s 2 ) )+k ; s=%iWn k =54; p=eval ( p ) Wn =sqrt ( k /6 ) p r i n t f ( With gvn v a l u e s o f z e t a adding a g r i d on r o o t l o c u s \n )

31

86

32 33

zeta =0.5; / / g i v e n sgrid ( z e t a ,Wn, 7 )


continuous and wn .

// add

grid

over

an

existing values for zeta

splane

root

with

given

34

35

p r i n t f ( NOTE: c l i c k on th e p o i n t where l o c u s i n t e r s e c t s z =0.5 f o r d e s i r e d v a l u e o f k \n ) k=1/r e a l ( horner (H, [ 1 , %i ] locate ( 1 ) ) ) / / T o o b t a i n t h e


gain at a given point of the locus

36 37 38

p=locate ( 1 )

// d e s i r e d

point

on

the

root

locus

Example 11.28 11.28.sci


1 2 3

s=%s ; H=s y s l i n ( c , 1 / ( ( s +4) s ( s +6) ) ) ; evans (H, 1 0 0 )

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.spokentutorial.org) for the installation of Symbolic Toolbox.

12.1

Scilab Code

Example 12.01 12.01.sci


1 2

s=poly ( 0 , s ) ; / / D e f i n e s s a s F=s y s l i n ( c , [ 2 2 5 / ( ( s +6) s ) ] ) ;


function in forward path

polynomial // C r e a t e s

variable transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7

CL=F / .B
//

// C a l c u l a t e s CL with

closed loop

transfer

function

compare

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the the denominator c o e f f i c i e n t s of of CL the

y=denom(CL) z=c o e f f ( y )

// e x t r a c t i n g // e x t r a c t i n g polynomial , comparing

denominator
8 9 10 11 12 13 14

/ / Wn 2 = z ( 1 , 1 )

the //

c o e f f i c i e n t s Wn= n a t u r a l frequency

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

z e t a=z ( 1 , 2 ) /(2Wn) // z e t a =damping factor Mr=1/(2 z e t a sqrt (1 z e t a 2) ) Wr= Wn sqrt (1 z e t a 2) Wc= Wn sqrt ((1 2 z e t a 2)+sqrt (4 z e t a 44 z e t a 2+2) ) 90

15

BW =Wc

/ / BANDWIDTH

Example 12.02 12.02.sci


1 2

s=poly ( 0 , s ) ; / / D e f i n e s s a s F=s y s l i n ( c , [ 3 6 / ( ( s +8) s ) ] ) ;


function in forward path

polynomial // C r e a t e s

variable transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7

CL=F / .B
//

// C a l c u l a t e s CL with

closed loop

transfer

function

compare

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the the denominator c o e f f i c i e n t s of of CL the

y=denom(CL) z=c o e f f ( y )

// e x t r a c t i n g // e x t r a c t i n g polynomial , comparing

denominator
8 9 10 11 12 13 14 15

/ / Wn 2 = z ( 1 , 1 )

the

c o e f f i c i e n t s // Wn= n a t u r a l frequency

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

z e t a=z ( 1 , 2 ) /(2Wn) // z e t a =damping factor Mr=1/(2 z e t a sqrt (1 z e t a 2) ) Wr= Wn sqrt (1 z e t a 2) Wc= Wn sqrt ((1 2 z e t a 2)+sqrt (4 z e t a 44 z e t a 2+2) ) BW =Wc / / BANDWIDTH Example 12.03 12.03.sci

1 2

s=poly ( 0 , s ) ; / / D e f i n e s s a s F=s y s l i n ( c , [ 8 1 / ( s 2+7 s ) ] ) ;


function in forward path

polynomial // C r e a t e s

variable transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7

CL=F / .B
//

// C a l c u l a t e s CL with

closed loop

transfer

function

compare

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the the denominator c o e f f i c i e n t s of of CL the

y=denom(CL) z=c o e f f ( y )

// e x t r a c t i n g // e x t r a c t i n g polynomial , comparing

denominator
8 9 10

/ / Wn 2 = z ( 1 , 1 )

the

c o e f f i c i e n t s // Wn= n a t u r a l frequency

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

91

11 12 13 14 15

z e t a=z ( 1 , 2 ) /(2Wn) // z e t a =damping factor Mr=1/(2 z e t a sqrt (1 z e t a 2) ) Wr= Wn sqrt (1 z e t a 2) Wc= Wn sqrt ((1 2 z e t a 2)+sqrt (4 z e t a 44 z e t a 2+2) ) BW =Wc / / BANDWIDTH Example 12.04 12.04.sci

1 2 3 4 5 6 7 8 9 10 11

// D e f i n e s

as

polynomial

variable

s=poly ( 0 , s ) ;
// C r e a t e s transfer function in forward path

F=s y s l i n ( c , [ 8 1 / ( ( s +18) s ) ] ) ;
// C r e a t e s transfer function in backward path

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


// C a l c u l a t e s closed loop transfer function

CL=F / .B
// compare CL with Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) the denominator of the of CL

y=denom(CL) / /
// E x t r a c t i n g polynomial

extracting the

c o e f f i c i e n t s

denominator

12 13 14 15 16 17 18

z=c o e f f ( y )
/ / Wn 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s

Wn =sqrt ( z ( 1 , 1 ) )
/ / 2 z e t a Wn= z ( 1 , 2 )

z e t a=z ( 1 , 2 ) /(2Wn)
// zeta =damping here factor becomes Mr =1 complex so the / / NOTE = other s q r t (1 2 z e t a 2 ) is Wr = 0 &

solution

19 20 21 22

Mr=1 Wr=0 Wc= Wn((1 2 z e t a 2)+sqrt (4 z e t a 44 z e t a 2+2) ) BW =Wc / / BANDWIDTH Example 12.05 12.05.sci

1 2 3

i eee ( 2 ) ; syms k a ; num=k ; 92

4 5 6 7 8 9 10

den=s ( a+s ) ; G=num/ den ; disp (G, G( s )= ) H=1; CL=G/ .H; CL=s i m p l e (CL) ; disp (CL, C( s ) /R( s )= )
transfer function CL with // compare

// C a l c u l a t e s

closed loop

11 12

Wn 2 / ( s 2 + 2 z e t a Wn+Wn 2 ) // e x t r a c t s num & den of symbolic

[ num , den ]=numden (CL) ;


function ( CL )

13

c o f a 0 = c o e f f s ( den , s , 0 ) ;
symbolic function ( CL )

//

coeff

of

den

of

14 15 16 17 18 19 20 21 22 23 24 25 26 27

c o f a 1 = c o e f f s ( den , s , 1 ) ;
/ / Wn 2 = cof a 0 , comparing the c o e f f i c i e n t s

Wn =sqrt ( c o f a 0 )
// c o f a 1 = 2 z e t a Wn

z e t a=c o f a 1 /(2Wn) Mr=1/(2 z e t a sqrt (1 z e t a 2) ) p r i n t f ( Given ,Mr=1.25 \n ) ;


/ / On solving eq (1) we get

/ / 1)

k = 1 . 2 5 a 2 2

p r i n t f ( k =1.25 a 2 \n ) Wr= Wn sqrt (12 z e t a 2) / / 3) p r i n t f ( Given , Wr=12.65 \n ) ;


// on soving eq ( 3 ) , we get 2 k a 2=320 4)

p r i n t f ( 2ka2=320 \n )
// now eq 2 &4 of & k can &a be simultaneously soved to take out values

28 29 30 31 32 33 34 35 36 37

//

Let

k=x

a 2= y // c o e f f i c i e n t matrix

A= [ 1 , 1 . 2 5 ; 2 , 1 ] ; b=[0;320]; m =A\b ; x= 1 , 1 ) ; m( k=x y= 2 , 1 ) ; m( a=sqrt ( y ) Wn =db l ( eval (Wn) ) ; disp (Wn, Wn ) =

93

38 39 40 41 42 43

z e t a=db l ( eval ( z e t a ) ) ; disp ( z e t a , z e t a = ) Ts=4/( z e t a Wn) ; d i s p ( Ts , S e t t l i n g Time ( Ts )= ) Wc= Wn((1 (2 z e t a 2) )+s q r t (4 z e t a 44 z e t a 2+2) ) d i s p (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 2

s=poly ( 0 , s ) ; / / D e f i n e s F=s y s l i n ( c , [ 2 0 / ( s +2) ] )


forward path

as

polynomial

variable function in

// C r e a t e s

transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) )


function in backward path

// C r e a t e s

transfer

4 5 6 7 8

OL=FB / / C a l c u l a t e s fmin = 0 . 1 ; / / M i n f r e q fmax =100; / / M a x f r e q scf (1) ; c l f ; bode (OL, fmin , fmax ) ;
loop system in

open l o o p in in Hz Hz

transfer

function

// P l o t s

frequency

response

of

open

Bode

diagram gain and phase margin and

show margins (OL)


associated

// d i s p l a y

crossover

frequencies

Example 13.02 13.02.sci


1

s=poly ( 0 , s ) ;

// D e f i n e s

as

polynomial

variable

95

Figure 13.1: Output of S 13.01


2

F=s y s l i n ( c , [ 2 0 / ( ( 2 + s ) s ) ] ) ;
function in forward path

// C r e a t e s

transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

// C r e a t e s

transfer

4 5 6 7

OL=FB ; / / C a l c u l a t e s o p e n l o o p fmin = 0 . 0 1 ; / / M i n f r e q i n H z fmax =20; / / M a x f r e q i n H z scf (1) ; c l f ; 96

transfer

function

Figure 13.2: Output of S 13.02


8

bode (OL, fmin , fmax ) ;


loop system in

// P l o t s

frequency

response

of

open

Bode

diagram gain and phase margin and

show margins (OL)


associated

// d i s p l a y

crossover

frequencies

Example 13.03 13.03.sci


1 2

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 F=s y s l i n ( c , [ 4 0 / ( ( 2 + s ) s ( s +5) ) ] ) / / C r e a t e s t r a n s f e r


function in forward path

97

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) )


function in backward path

// C r e a t e s

transfer

4 5 6 7 8

OL=FB ; / / C a l c u l a t e s fmin = 0 . 1 ; / / M i n f r e q fmax =20; / / M a x f r e q scf (1) ; c l f ; bode (OL, fmin , fmax ) ;
loop system in

open l o o p in in Hz Hz

transfer

function

// P l o t s

frequency

response

of

open

Bode

diagram // C a l c u l a t e s frequency gain

[ GainMargin , freqGM]=g margin (OL)


margin [ dB ] and corresponding

[ Hz ] [ deg ]

10

[ Phase , freqPM]=p margin (OL)


and corresponding freq

// C a l c u l a t e s of phase

phase margin

[ Hz ]

11

PhaseMargin=180+Phase
[ deg ]

// C a l c u l a t e s

actual

phase

margin

12

show margins (OL)


associated

// d i s p l a y

gain

and

phase

margin

and

crossover

frequencies

Example 13.04 13.04.sci


1 2

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 F=s y s l i n ( c , [ 4 0 / ( ( s +5)(2+ s ) s 2 ) ] ) / / C r e a t e s t r a n s f e r


function in forward path // C r e a t e s transfer

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) ) ;


function in backward path

4 5 6 7 8

OL=FB ; / / C a l c u l a t e s fmin = 0 . 1 ; / / M i n f r e q fmax =20; / / M a x f r e q scf (1) ; c l f ; bode (OL, fmin , fmax ) ;
loop system in

open l o o p in in Hz Hz

transfer

function

// P l o t s

frequency

response

of

open

Bode

diagram gain and phase margin and

show margins (OL)


associated

// d i s p l a y

crossover

frequencies

Example 13.05 13.05.sci


1

s=poly ( 0 , s ) ;

// D e f i n e s

as

polynomial

variable

98

Figure 13.3: Output of S 13.03


2

F=s y s l i n ( c , [ ( 4 0 0 ( s +2) ) / ( ( s +5)(10+ s ) s 2 ) ] )


Creates transfer function in forward path

//

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) )


function in backward path

// C r e a t e s

transfer

4 5 6 7 8

OL=FB / / C a l c u l a t e s fmin = 0 . 1 ; / / M i n f r e q fmax =20; / / M a x f r e q scf (1) ; c l f ; bode (OL, fmin , fmax ) ;
loop system in

open l o o p in in Hz Hz

transfer

function

// P l o t s

frequency

response

of

open

Bode

diagram gain and phase margin and

show margins (OL)


associated

// d i s p l a y

crossover

frequencies

99

Figure 13.4: Output of S 13.04

Example 13.06 13.06.sci


1 2

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 F=s y s l i n ( c , [ ( 2 8 8 ( s +4) ) / ( ( s +2) (144+4.8 s+s 2 ) s ) ] )


// C r e a t e s transfer function in forward path

B=s y s l i n ( c ,(1+0 s ) /(1+0 s ) )


function in backward path

// C r e a t e s

transfer

4 5 6

OL=FB / / fmin = 0 . 1 ; fmax =100;

Calculates // Min / / Max freq freq

open l o o p in in Hz Hz

transfer

function

100

Figure 13.5: Output of S 13.05


7 8

scf (1) ; c l f ; bode (OL, fmin , fmax ) ;


loop system in

// P l o t s

frequency

response

of

open

Bode

diagram gain and phase margin and

show margins (OL)


associated

// d i s p l a y

crossover

frequencies

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 2 3 4 5

s=%s ; s y s=s y s l i n ( c , 1 / ( s +2) ) nyquist ( s y s ) show margins ( sys , n y q u i s t ) p r i n t f ( S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s ) \n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e RHP i s z e r o \n hence t h e system i s s t a b l e ) Example 15.02 15.02.sci

1 2 3 4 5

s=%s ; s y s=s y s l i n ( c , 1 / ( s ( s +2) ) ) nyquist ( s y s ) show margins ( sys , n y q u i s t ) p r i n t f ( S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s ) \n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e RHP i s z e r o \n hence t h e system i s s t a b l e )

103

Figure 15.1: Output of S 15.01 Example 15.03 15.03.sci


1 2 3 4 5

s=%s ; s y s=s y s l i n ( c , 1 / ( s 2( s +2) ) ) nyquist ( s y s ) show margins ( sys , n y q u i s t ) p r i n t f ( S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s ) \n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e 104

Figure 15.2: Output of S 15.02 RHP i s not e q u a l t o z e r o \n hence t he system i s unstable ) Example 15.04 15.04.sci
1 2 3 4 5

s=%s ; s y s=s y s l i n ( c , 1 / ( s 3( s +2) ) ) nyquist ( s y s ) show margins ( sys , n y q u i s t ) p r i n t f ( S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s ) \n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e 105

Figure 15.3: Output of S 15.03 RHP i s N>0 \n hence t he system i s u n s t a b l e ) Example 15.05 15.05.sci
1 2 3 4 5

s=%s ; s y s=s y s l i n ( c , 1 / ( s 2( s +2) ) ) nyquist ( s y s ) show margins ( sys , n y q u i s t ) p r i n t f ( S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s ) \n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e RHP i s N>0 \n hence t he system i s u n s t a b l e ) 106

Figure 15.4: Output of S 15.04 Example 15.06 15.06.sci


1 2 3 4 5 6 7

s=%s ; P1=1; P2=2; s y s=s y s l i n ( c , 1 / ( ( s +1) ( s +2) ) ) nyquist ( s y s ) show margins ( sys , n y q u i s t ) p r i n t f ( S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s ) \n\n Here t he number o f z e r o s o f 1+G( s )H( s ) i n t he RHP i s z e r o \n\n Hence t h e system i s s t a b l e )

107

Figure 15.5: Output of S 15.05 Example 15.07 15.07.sci


1 2 3 4 5 6 7 8 9

s=%s ; s y s=s y s l i n ( c , 1 2 / ( s ( s +1) ( s +2) ) ) nyquist ( s y s ) show margins ( sys , n y q u i s t ) gm=g margin ( s y s ) i f (gm<=0) p r i n t f ( system i s u n s t a b l e ) else p r i n t f ( system i s s t a b l e ) ; end ;

108

Figure 15.6: Output of S 15.06 Example 15.08 15.08.sci


1 2 3 4 5 6

7 8

s=%s ; s y s=s y s l i n ( c , ( 3 0 ) / ( ( s 2+2 s +2) ( s +3) ) ) nyquist ( s y s ) gm=g margin ( s y s ) show margins ( sys , n y q u i s t ) p r i n t f ( S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s ) \n Here t he number o f z e r o s o f 1+G( s )H( s ) i n th e RHP i s z e r o \n Hence t h e system i s s t a b l e ) i f (gm<=0) p r i n t f ( system i s u n s t a b l e ) 109

Figure 15.7: Output of S 15.07


9 10 11

else p r i n t f ( system i s s t a b l e ) 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.spokentutorial.org) for the installation of Symbolic Toolbox.

17.1

Scilab Code

Example 17.03 17.03.sci


1 2 3 4 5 6

s=%s ;
// C r e a t i n g cont time transfer function

TFcont=s y s l i n ( c , 3 / ( s 4+(2 s 3) +(3 s ) +2) ) SScont=t f 2 s s ( TFcont )


/ / CCF form

[ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScon ( 3 ) ) Example 17.04 17.04.sci

1 2

3 4

s=%s ; TFcont=s y s l i n ( c , [ ( 7 + 2 s + 3( s 2) ) / (5 + 12 s + 5( s 2) + s 3 ) ] ) SScont=t f 2 s s ( TFcont ) [ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) ) Example 17.06 17.06.sci

112

1 2 3 4 5 6

s=%s ;
// C r e a t i n g cont time transfer function

TFcont=s y s l i n ( c , [ ( 5 ( s +1) ( s +2) ) / ( ( s +4) ( s +5) ) ] ) SScont=t f 2 s s ( TFcont )


/ / CCF form

[ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) ) Example 17.07 17.07.sci

1 2 3 4 5 6

s=%s ;
// C r e a t i n g cont time transfer function

TFcont=s y s l i n ( c , ( s +1) / ( ( s +2) ( s +5) ( s +3) ) ) SScont=t f 2 s s ( TFcont )


/ / CCF form

[ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) ) Example 17.08 17.08.sci

1 2 3 4 5 6

s=%s ;
// C r e a t i n g cont time transfer function

TFcont=s y s l i n ( c , ( 6 ) / ( ( s +2) 2( s +1) ) ) SScont=t f 2 s s ( TFcont )


/ / CCF form

[ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) ) Example 17.09 17.09.sci

1 2 3 4 5 6

A=[0 1; 6 5] [ Row Col ]= s i z e (A) / / S i z e o f a m a t r i x l=poly ( 0 , l ) ; m eye (Row, Col )A / / l I A =l n=det (m) / / T o F i n d T h e D e t e r m i n a n t roots ( n ) / / T o F i n d T h e V a l u e O f l Example 17.10 17.10.sci

of

l i A

A=[2 1 ; 0 3] 113

2 3 4 5 6 7 8 9 10

B= [ 0 ; 1 ] C=[1 1 ] s=poly ( 0 , s ) ; [ Row Col ]= s i z e (A) // S i z e of a matrix m eye (Row, Col )A / / s I A =s n=det (m) / / To F i n d T h e D e t e r m i n a n t of p=inv (m) / / To F i n d T h e I n v e r s e O f y=CpB ; / / T o F i n d C ( s I A ) 1 B disp ( y , T r a n s f e r Function= ) Example 17.11 17.11.sci

s i A s I A

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

14 15 16 17 18 19 20 21 22

A=[0 1; 6 5] x=[1;0]; disp ( x , x ( t ) = ) s=p o l y ( 0 , s ) ; [ Row Col ]= s i z e (A) // S i z e o f a matrix m eye (Row, Col )A =s // s I A n=d e t (m) //To Find The Determinant o f s i A p=i n v (m) ; // To Find The I n v e r s e Of s I A syms t s ; d i s p ( p , p hi ( s )= ) // R e s o l v e n t Matrix f o r i =1:Row f o r j =1: Col // Taking I n v e r s e L a p l a c e o f each element o f Matrix p h i ( s) q ( i , j )=i l a p l a c e ( p ( i , j ) , s , t ) ; end ; end ; d i s p ( q , p h i ( t )= ) // S t a t e T r a n s i t i o n Matrix r=i n v ( q ) ; r=s i m p l e ( r ) ; //To Find ph i ( t ) d i s p ( r , p h i ( t )= ) y=qx ; //x ( t )=p h i ( t ) x ( 0 ) d i s p ( y , S o l u t i o n To The g i v e n eq .= ) Example 17.12 17.12.sci 114

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

30

31 32

A=[0 1; 6 5] B= [ 0 ; 1 ] x=[1;0] disp ( x , x ( t ) = ) s=p o l y ( 0 , s ) ; [ Row Col ]= s i z e (A) // S i z e o f a matrix A m eye (Row, Col )A // s I A =s n=d e t (m) //To Find The Determinant o f s i A p=i n v (m) ; // To Find The I n v e r s e Of s I A syms t s m; d i s p ( p , p hi ( s )= ) // R e s o l v e n t Matrix f o r i =1:Row f o r j =1: Col // I n v e r s e L a p l a c e o f each element o f Matrix ( p hi ( s ) ) q ( i , j )=i l a p l a c e ( p ( i , j ) , s , t ) ; end ; end ; d i s p ( q , p h i ( t )= ) // S t a t e T r a n s i t i o n Matrix t =(t ; m) q=e v a l ( q ) //At t=t , e v a l u a t i n g q i . e p hi ( t m m) // I n 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 o n ) r=i n t e g ( qB,m) m=0 // Upper l i m i t i s t g=e v a l ( r ) // P u t t i n g t h e v a l u e o f upper l i m i t i n q m =t // Lower Limit i s 0 h=e v a l ( r ) // P u t t i n g t he v a l u e o f l o w e r l i m i t i n q y=(hg ) ; d i s p ( y , y= ) p r i n t f ( x ( t )= p hi ( t ) x ( 0 ) + i n t e g ( ph i ( t B) w. r . t m m) from 0 t 0 t \n ) // x ( t )=ph i ( t ) x ( 0 )+i n t e g ( ph i ( t B) w. r . t m from 0 t 0 m) t y1=(qx )+y ; d i s p ( y1 , x ( t )= ) Example 17.13 17.13.sci

A=[3 0 ; 2 4 ] 115

2 3 4 5

B= [ 0 ; 1 ] Cc=cont mat (A, B) ; disp ( Cc , C o n t r o l a b i l i t y Matrix= )


/ / To Check Whether of the m a t r i x ( Cc ) is singular i . e determint Cc =0

6 7

8 9 10

i f determ ( Cc ) ==0; p r i n t f ( S i n c e t h e matrix i s S i n g u l a r , t he system i s not c o n t r o l l a b l e \n ) ; else ; p r i n t f ( The system i s c o n t r o l l a b l e \n ) end ; Example 17.14 17.14.sci

1 2 3 4 5 6

A=[2 1 ; 0 3] B= [ 4 ; 1 ] C=[1 0 ] [O]=obsv mat (A,C) ; disp (O, O b s e r v a b i l i t y Matrix= )


/ / To Check Whether of the m a t r i x ( Cc ) i s singular i . e determint Cc =0

7 8

9 10 11

i f determ (O) ==0; p r i n t f ( S i n c e t h e matrix i s S i n g u l a r , t he system i s not O b s e rv a b l e \n ) ; else ; p r i n t f ( The system i s O bs e r v a b l e \n ) end ; Example 17.16 17.16.sci

1 2 3

s=%s ;
// C r e a t i n g cont time transfer function

4 5 6

TFcont=s y s l i n ( c , ( ( 5 s 2 ) +(2 s ) +6) / ( s 3+(7 s 2 ) +(11 s ) +8) ) SScont=t f 2 s s ( TFcont )


/ / CCF form

[ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) )

116

Example 17.17 17.17.sci


1 2 3 4 5 6

s=%s ;
// C r e a t i n g cont time transfer function

TFcont=s y s l i n ( c , ( 8 ) / ( s ( s +2) ( s +3) ) ) SScont=t f 2 s s ( TFcont )


/ / CCF form

[ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) ) Example 17.18 17.18.sci

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

14 15 16 17 18 19 20

A=[0 1; 3 4] x=[1;0]; disp ( x , x ( t ) = ) s=p o l y ( 0 , s ) ; [ Row Col ]= s i z e (A) // S i z e o f a matrix m eye (Row, Col )A =s // s I A n=d e t (m) //To Find The Determinant o f s i A p=i n v (m) ; / / To Find The I n v e r s e Of s I A syms t s ; d i s p ( p , p hi ( s )= ) // R e s o l v e n t Matrix f o r i =1:Row f o r j =1: Col // Taking I n v e r s e L a p l a c e o f each element o f Matrix p h i ( s) q ( i , j )=i l a p l a c e ( p ( i , j ) , s , t ) ; end ; end ; d i s p ( q , p h i ( t )= ) // S t a t e T r a n s i t i o n Matrix r=i n v ( q ) ; r=s i m p l e ( r ) ; //To Find p hi ( t ) d i s p ( r , p h i ( t )= ) Example 17.19 17.19.sci

1 2 3

A=[0 1; 3 4] B= [ 0 ; 1 ] C=[1 0 ] 117

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

16 17 18 19 20 21 22

23 24 25 26 27 28

29

30 31 32 33

x=[0;0] disp ( x , x ( t ) = ) s=p o l y ( 0 , s ) ; [ Row Col ]= s i z e (A) // S i z e o f a matrix A m eye (Row, Col )A // s I A =s n=d e t (m) //To Find The Determinant o f s i A p=i n v (m) ; // To Find The I n v e r s e Of s I A syms t s m; d i s p ( p , p hi ( s )= ) // R e s o l v e n t Matrix f o r i =1:Row f o r j =1: Col // Taking I n v e r s e L a p l a c e o f each element o f Matrix ( ph i ( s)) q ( i , j )=i l a p l a c e ( p ( i , j ) , s , t ) ; end ; end ; d i s p ( q , p h i ( t )= ) // S t a t e T r a n s i t i o n Matrix t =(t m) q=e v a l ( q ) //At t=t , e v a l u a t i n g q i . e p hi ( t m m) r=i n t e g ( qB,m) // I n t e g r a t e q w. r . t m ( I n d e f i n i t e Integration ) m=0 // Upper l i m i t i s t g=e v a l ( r ) // P u t t i n g t h e v a l u e o f upper l i m i t i n q m =t // Lower Limit i s 0 h=e v a l ( r ) // P u t t i n g t he v a l u e o f l o w e r l i m i t i n q y=(hg ) ; p r i n t f ( x ( t )= p hi ( t ) x ( 0 ) + i n t e g ( ph i ( t B) w. r . t m m) from 0 t 0 t \n ) // x ( t )=ph i ( t ) x ( 0 ) + i n t e g ( ph i ( t B) w. r . t m from 0 m) t0 t y1=(qx )+y ; d i s p ( y1 , x ( t )= ) y2=Cy1 ; d i s p ( y2 , Output Response= ) Example 17.20 17.20.sci

A=[0 1; 2 0 ] 118

2 3 4 5

B= [ 0 ; 3 ] Cc=cont mat (A, B) ; disp ( Cc , C o n t r o l a b i l i t y Matrix= )


/ / To Check Whether of the m a t r i x ( Cc ) is singular i . e determint Cc =0

6 7

8 9 10

i f determ ( Cc ) ==0; p r i n t f ( S i n c e t h e matrix i s S i n g u l a r , t he system i s not c o n t r o l l a b l e \n ) ; else ; p r i n t f ( The system i s c o n t r o l l a b l e \n ) end ; Example 17.21 17.21.sci

1 2 3 4 5 6

A=[3 0 ; 0 2] B= [ 4 ; 1 ] C=[2 0 ] [O]=obsv mat (A,C) ; disp (O, O b s e r v a b i l i t y Matrix= )


/ / To Check Whether of the m a t r i x ( Cc ) is singular i . e determint Cc =0

7 8

9 10 11

i f determ (O) ==0; p r i n t f ( S i n c e t h e matrix i s S i n g u l a r , t he system i s not O b s e rv a b l e \n ) ; else ; p r i n t f ( The system i s O bs e r v a b l e \n ) end ; Example 17.22 17.22.sci

1 2 3 4 5 6 7 8

i eee ( 2 ) A=[3 0 0 ; 0 1 1 ; 0 0 1] B= [ 0 ; 1 ; 0 ] s=poly ( 0 , s ) ; [ Row Col ]= s i z e (A) // S i z e of m eye (Row, Col )A =s / / s I A n=det (m) / / To F i n d p=inv (m) ; / / To F i n d 119

matrix

The The

Determinant Inverse Of

of s I A

s i A

9 10

syms t s ; disp ( p , ph i ( s )= )

// R e s o l v e n t

Matrix

Example 17.23 17.23.sci


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

23 24 25 26 27 28 29

30

A=[2 0 ; 1 1] B= [ 0 ; 1 ] x=[0;0] disp ( x , x ( t ) = ) s=p o l y ( 0 , s ) ; [ Row Col ]= s i z e (A) // S i z e o f a matrix A m eye (Row, Col )A // s I A =s n=d e t (m) //To Find The Determinant o f s i A p=i n v (m) ; // To Find The I n v e r s e Of s I A syms t s m; d i s p ( p , p hi ( s )= ) // R e s o l v e n t Matrix t =(t m) q=e v a l ( q ) //At t=t , e v a l u a t i n g q i . e p hi ( t m m) // I n 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 o n ) r=i n t e g ( qB,m) m=0 // Upper l i m i t i s t g=e v a l ( r ) // P u t t i n g t h e v a l u e o f upper l i m i t i n q m =t // Lower Limit i s 0 h=e v a l ( r ) // P u t t i n g t he v a l u e o f l o w e r l i m i t i n q y=(hg ) ; d i s p ( y , y= ) p r i n t f ( x ( t )= p hi ( t ) x ( 0 ) + i n t e g ( ph i ( t B) w. r . t m m) from 0 t 0 t \n ) // x ( t )=ph i ( t ) x ( 0 )+i n t e g ( ph i ( t B)w. r . t m from 0 t 0 t m) y1=(qx )+y ; d i s p ( y1 , x ( t )= ) // CONTROLABILITY OF THE SYSTEM Cc=cont mat (A, B) ; d i s p ( Cc , C o n t r o l a b i l i t y Matrix= ) //To Check Whether t h e matrix ( Cc ) i s s i n g u l a r i . e d e t e r m i n t o f Cc=0 i f determ ( Cc ) ==0;

120

31

32 33 34

p r i n t f ( S i n c e t h e matrix i s S i n g u l a r , th e system i s not c o n t r o l l a b l e \n ) ; else ; p r i n t f ( The system i s c o n t r o l l a b l e \n ) end ;

121

Chapter 18 Digital Control Systems


For the execution of the programm keep the main programm and the Function in the same folder.

18.1

Scilab Code

Example F3 ztransfer.sce
1 2 3 4

function [ Z t r a n s f e r ]= z t r a n s f e r ( s e q u e n c e ) z = poly ( 0 , z , r ) Z t r a n s f e r=s e q u e n c e (1/ z ) [ 0 : ( length ( s e q u e n c e ) 1) ] endfunction Example 18.01 18.01.01.sci

1 2 3 4 5 6 7

syms n z ; x=( 0.5) n y = ( 4 ( ( 0 . 2 ) n ) ) f 1=symsum ( x ( z(n ) ) , n , 0 , %inf ) f 2=symsum ( y ( z(n ) ) , n , 0 , %inf ) y=( f 1+f 2 ) ; disp ( y , ans= ) Example 18.08 18.08.01.sci

122

1 2 3 4

exec z t r a n s f e r . s c e ; s e q u e n c e =[0 2 0 0 3 0 0 8 ] y=z t r a n s f e r ( s e q u e n c e ) ; disp ( y , ans= )

123

You might also like