Scilab Textbook Companion for Linear Control Systems by B. S. Manke 1 Created by Ashish Kumar B.Tech (Pursuing) Electronics Engineering M. N. N. I. T., Allahabad College Teacher Dr. Rajesh Gupta, MNNIT, Allahabad Cross-Checked by K Sryanarayan and Sonanya Tatikola. IIT Bombay May 16, 2016
1 Funded
by a grant from the National Mission on Education through ICT, http://spoken-tutorial.org/NMEICT-Intro. This Textbook Companion and Scilab codes written in it can be downloaded from the ”Textbook Companion Project” section at the website http://scilab.in
Book Description Title: Linear Control Systems Author: B. S. Manke Publisher: Khanna Publishers Edition: 9 Year: 2009 ISBN: 81-7409-107-6
1
Scilab numbering policy used in this document and the relation to the above book. Exa Example (Solved example) Eqn Equation (Particular equation of the above book) AP Appendix to Example(Scilab Code that is an Appednix to a particular Example of the above book) For example, Exa 3.51 means solved example 3.51 of this book. Sec 2.3 means a scilab code whose theory is explained in Section 2.3 of the book.
2
Contents List of Scilab Codes
4
1 INTRODUCTION
6
2 TRANSFER FUNCTIONS
14
3 BLOCK DIAGRAMS
17
4 SIGNAL FLOW GRAPHS
31
5 MODELLING A CONTROL SYSTEM
40
6 TIME RESPONSE ANALYSIS OF CONTROL SYSTEMS
49
7 STABILITY ANALYSIS OF CONTROL SYSTEMS
72
8 COMPENSATION OF CONTROL SYSTEMS
130
9 INTRODUCTION TO STATE SPACE ANALYSIS OF CONTROL SYSTEMS 141 11 SOLUTION OF PROBLEMS USING COMPUTER
156
12 CLASSIFIED SOLVED EXAMPLES
195
3
List of Scilab Codes Exa 1.6.1.i inverse laplace transform . . . Exa 1.6.1.iiinverse laplace transform . . . Exa 1.6.1.iiiinverse laplace transform . . . Exa 1.6.1.ivinverse laplace transform . . . Exa 1.6.1.vinverse laplace transform . . . Exa 1.6.1.viprogram laplace transform . . . Exa 1.6.2 solution of differential equation Exa 1.6.3 solution of differential equation Exa 1.6.4 solution of differential equation Exa 1.6.5 initial value . . . . . . . . . . . Exa 1.6.7 final value . . . . . . . . . . . . Exa 1.6.8 steady state value . . . . . . . Exa 1.6.9 initial values . . . . . . . . . . Exa 1.6.10 final value . . . . . . . . . . . . Exa 2.4.1 pole zero plot . . . . . . . . . . Exa 2.4.2 final value . . . . . . . . . . . . Exa 3.2.1 Transfer Function . . . . . . . Exa 3.2.2 Transfer Function . . . . . . . Exa 3.2.3 Transfer Function . . . . . . . Exa 3.2.4 Transfer Function . . . . . . . Exa 3.2.5 Transfer Function . . . . . . . Exa 3.2.6 Transfer Function . . . . . . . Exa 3.2.7 Transfer Function . . . . . . . Exa 3.2.8 Transfer Function . . . . . . . Exa 3.2.9 Transfer Function . . . . . . . Exa 3.2.10 Transfer Function . . . . . . . Exa 3.2.11 Transfer Function . . . . . . . Exa 3.2.12 Transfer Function . . . . . . . 4
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
6 6 7 7 8 8 9 9 10 10 11 11 12 13 14 16 17 18 19 19 20 21 22 23 24 25 26 26
Exa 3.2.13 Transfer Function . . . . . . . . . . . . . . . . . . . Exa 3.2.14 Transfer Function . . . . . . . . . . . . . . . . . . . Exa 3.2.15 Transfer Function . . . . . . . . . . . . . . . . . . . Exa 4.3.1 Overall Transmittance . . . . . . . . . . . . . . . . . Exa 4.3.2 Overall Transmittance . . . . . . . . . . . . . . . . . Exa 4.4.1 Closed Loop Transfer Function . . . . . . . . . . . . Exa 4.4.2 Overall Gain . . . . . . . . . . . . . . . . . . . . . . Exa 4.4.3 to find various signal flow graph parameter . . . . . Exa 4.4.4 Transfer function using mason gain formula . . . . . Exa 4.4.5 Transfer function using mason gain formula . . . . . Exa 4.4.6 Transfer function using mason gain formula . . . . . Exa 4.4.7 Transfer function using mason gain formula . . . . . Exa 4.4.8 Transfer function using mason gain formula . . . . . Exa 4.4.9 Overall Transfer Function . . . . . . . . . . . . . . . Exa 4.4.10 Transfer function using mason gain formula . . . . . Exa 5.9.4 Calculate Reference Voltage Vr . . . . . . . . . . . . Exa 5.9.5 Calculate Reference Voltage Vr . . . . . . . . . . . . Exa 5.9.6 Calculate Gain of Amplifier Ka . . . . . . . . . . . . Exa 5.9.7 Transfer Function of Generator . . . . . . . . . . . . Exa 5.9.8 Overall Transfer Function of given System . . . . . . Exa 5.9.9 Overall Transfer Function of given System . . . . . . Exa 5.9.10 Overall Transfer Function of given System . . . . . . Exa 5.9.11 Overall Transfer Function of given System . . . . . . Exa 5.9.12 Overall Transfer Function of given System . . . . . . Exa 5.9.13 Overall Transfer Function of Two Phase ac Motor . Exa 5.9.14 Transfer Function Of Motor . . . . . . . . . . . . . . Exa 6.10.1 time response for step function . . . . . . . . . . . . Exa 6.10.2 Time Response for unit Impulse and Step function . Exa 6.10.3 Time Response for Unit Step Function . . . . . . . . Exa 6.10.4 Time Response for Unit Step Function . . . . . . . . Exa 6.10.5 Calculate Wn zeta Wd tp Mp . . . . . . . . . . . . . Exa 6.10.6 Time Response . . . . . . . . . . . . . . . . . . . . . Exa 6.10.7 determine factor by which K should be reduced . . . Exa 6.10.8 Determine Steady State Speed and Error . . . . . . Exa 6.10.9 determine J f K . . . . . . . . . . . . . . . . . . . . Exa 6.10.10Determine Transfer Function Wn zeta . . . . . . . . Exa 6.10.11Determine Characterstics eq and Steady State Error Exa 6.10.12determine WnWd zeta and steady state error . . . . 5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28 29 29 31 32 32 33 33 34 35 36 37 37 38 39 40 41 41 42 43 43 44 45 46 46 47 49 50 51 51 52 53 54 55 56 57 59 60
Exa 6.10.13determine K ts tp and Mp . . . . . . . . . . . . . . . Exa 6.10.14determine Mp Ess and steady state value . . . . . . Exa 6.10.16determine Wn zeta and M . . . . . . . . . . . . . . . Exa 6.10.17determine Kp Kv and Ka . . . . . . . . . . . . . . . Exa 6.10.18determine Kp Kv and Ka . . . . . . . . . . . . . . . Exa 6.10.19determine steady state error . . . . . . . . . . . . . . Exa 6.10.20determine steady state error and error coefficient . . Exa 6.10.21determine steady state error and error coefficient . . Exa 6.10.22determine voltage Er and change in terminalvoltage Exa 6.10.23determine sensitivity wrt K and H . . . . . . . . . . Exa 1.0 root locus . . . . . . . . . . . . . . . . . . . . . . . . Exa 2.0 root locus . . . . . . . . . . . . . . . . . . . . . . . . Exa 3.0 root locus . . . . . . . . . . . . . . . . . . . . . . . . Exa 7.5.1 stability using Routh hurwitz criterion . . . . . . . . Exa 7.5.2 stability using Routh hurwitz criterion . . . . . . . . Exa 7.5.3 stability using Routh hurwitz criterion . . . . . . . . Exa 7.5.4 stability using Routh hurwitz criterion . . . . . . . . Exa 7.5.5 stability using Routh hurwitz criterion . . . . . . . . Exa 7.5.6 stability using Routh hurwitz criterion . . . . . . . . Exa 7.5.7.a stability using Routh hurwitz criterion . . . . . . . . Exa 7.5.7.bvalue of K of characterstics equation . . . . . . . . . Exa 7.5.8 value of K in terms of T1 and T2 . . . . . . . . . . . Exa 7.17.1 stability using Nyquist criterion . . . . . . . . . . . . Exa 7.17.2.istability using Nyquist criterion . . . . . . . . . . . . Exa 7.17.2.iistability using Nyquist criterion . . . . . . . . . . . . Exa 7.17.3 stability using Nyquist criterion . . . . . . . . . . . . Exa 7.17.5 Phase Margin . . . . . . . . . . . . . . . . . . . . . . Exa 7.17.7 stability using Nyquist criterion . . . . . . . . . . . . Exa 7.17.9 gain margin and phase margin . . . . . . . . . . . . Exa 7.17.18gain phase plot . . . . . . . . . . . . . . . . . . . . . Exa 7.19.1 stability using bode plot . . . . . . . . . . . . . . . . Exa 7.19.2 gain margin and phase margin . . . . . . . . . . . . Exa 7.19.3 stability using bode plot . . . . . . . . . . . . . . . . Exa 7.24.1 root locus description . . . . . . . . . . . . . . . . . Exa 7.24.2 root locus description . . . . . . . . . . . . . . . . . Exa 7.24.3 root locus description . . . . . . . . . . . . . . . . . Exa 7.24.4 root locus . . . . . . . . . . . . . . . . . . . . . . . . Exa 7.24.6 root locus . . . . . . . . . . . . . . . . . . . . . . . . 6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
61 62 63 64 65 66 67 68 69 70 72 72 75 76 76 77 78 79 80 81 82 83 85 85 88 91 97 97 99 101 101 103 104 106 107 110 113 115
Exa 7.24.7 root locus . . . . . . . . . . . . . . . . . . . . . . . . . Exa 7.24.8 root locus . . . . . . . . . . . . . . . . . . . . . . . . . Exa 7.24.9 root locus . . . . . . . . . . . . . . . . . . . . . . . . . Exa 7.24.10Overall Transfer Function and Root Locus . . . . . . . Exa 7.24.11root locus . . . . . . . . . . . . . . . . . . . . . . . . . Exa 8.6.1 design suitable compensator . . . . . . . . . . . . . . . Exa 8.6.2 design phase lead compensator . . . . . . . . . . . . . Exa 8.6.3 design suitable compensator . . . . . . . . . . . . . . . Exa 9.8.1 Check for Contrallability of System . . . . . . . . . . . Exa 9.8.2 Check for Contrallability of System . . . . . . . . . . . Exa 9.9.1.a Check for Observability of System . . . . . . . . . . . Exa 9.9.1.bCheck for Observability of System . . . . . . . . . . . Exa 9.10.4.aObtain State Matrix . . . . . . . . . . . . . . . . . . . Exa 9.10.4.bObtain State Matrix . . . . . . . . . . . . . . . . . . . Exa 9.10.5 Obtain State Matrix . . . . . . . . . . . . . . . . . . . Exa 9.10.6 Obtain State Matrix . . . . . . . . . . . . . . . . . . . Exa 9.10.7 Obtain State Matrix . . . . . . . . . . . . . . . . . . . Exa 9.10.9 Obtain State Matrix . . . . . . . . . . . . . . . . . . . Exa 9.10.10Obtain State Matrix . . . . . . . . . . . . . . . . . . . Exa 9.10.11Obtain Time Response . . . . . . . . . . . . . . . . . . Exa 9.10.12.i Obtain Zero Input Response . . . . . . . . . . . . . . Exa 9.10.12.ii Obtain Zero State Response . . . . . . . . . . . . . . . Exa 9.10.13Obtain Time Response . . . . . . . . . . . . . . . . . . Exa 9.10.14Obtain Time Response using Diagonalization Process . Exa 9.10.15Obtain Time Response using Diagonalization Process . Exa 9.10.16Determine Transfer Matrix . . . . . . . . . . . . . . . Exa 9.10.17Determine Transfer Matrix . . . . . . . . . . . . . . . Exa 9.10.18Determine Transfer Matrix . . . . . . . . . . . . . . . Exa 9.10.20Check for Contrallability of System . . . . . . . . . . . Exa 9.10.21Check for Contrallability and Observability . . . . . . Exa 9.10.22Check for Contrallability and Observability . . . . . . Exa 11.1 pole zero Plot . . . . . . . . . . . . . . . . . . . . . . . Exa 11.2 transfer function . . . . . . . . . . . . . . . . . . . . . Exa 11.3 transfer function . . . . . . . . . . . . . . . . . . . . . Exa 11.4 determine Wn zeta and Mp . . . . . . . . . . . . . . . Exa 11.5 time response for unit step function . . . . . . . . . . Exa 11.7 time response for unit step function . . . . . . . . . . Exa 11.8 time response for unit step function . . . . . . . . . . 7
117 120 122 124 126 130 131 135 141 142 142 143 143 144 144 145 145 145 146 146 147 148 149 149 150 151 152 152 153 153 154 156 156 158 158 159 160 161
Exa 11.9 time response for unit step function . . . . . . . . Exa 11.10.acalculate tr Tp Mp . . . . . . . . . . . . . . . . . . Exa 11.10.bcalculate Td tr Tp Mp . . . . . . . . . . . . . . . . Exa 11.11 expression for unit step response . . . . . . . . . . Exa 11.12 unit step and impulse response . . . . . . . . . . . Exa 11.13 determine transfer function . . . . . . . . . . . . . Exa 11.14 determine Wn Wd Tp zeta and steady state error . Exa 11.15 determine Wn Wd zeta and steady state error . . . Exa 11.16 determine Kp Kv Ka . . . . . . . . . . . . . . . . . Exa 11.17 determine Kp Kv Ka . . . . . . . . . . . . . . . . . Exa 11.18 determine Kp Kv Ka . . . . . . . . . . . . . . . . . Exa 11.19 determine transfer function . . . . . . . . . . . . . Exa 11.21.aroots of characterstics equation . . . . . . . . . . . Exa 11.21.bbode plot . . . . . . . . . . . . . . . . . . . . . . . Exa 11.22 gain margin and phase margin . . . . . . . . . . . Exa 11.24 stability using Nyquist criterion . . . . . . . . . . . Exa 11.25 stability using Nyquist criterion . . . . . . . . . . . Exa 11.26.i stability using Nyquist criterion . . . . . . . . . . . Exa 11.26.iistability using Nyquist criterion . . . . . . . . . . . Exa 11.27 root locus . . . . . . . . . . . . . . . . . . . . . . . Exa 11.28 root locus . . . . . . . . . . . . . . . . . . . . . . . Exa 11.29 root locus . . . . . . . . . . . . . . . . . . . . . . . Exa 11.30 root locus . . . . . . . . . . . . . . . . . . . . . . . Exa 11.31 design lead compensator . . . . . . . . . . . . . . . Exa 11.32 nicholas chart . . . . . . . . . . . . . . . . . . . . . Exa 11.33 obtain state matrix . . . . . . . . . . . . . . . . . . Exa 11.34 obtain state matrix . . . . . . . . . . . . . . . . . . Exa 11.35 obtain state matrix . . . . . . . . . . . . . . . . . . Exa 11.36 state transition matrix . . . . . . . . . . . . . . . . Exa 11.37 check for contrallability of system . . . . . . . . . . Exa 11.38 determine transfer function . . . . . . . . . . . . . Exa 11.39 determine transfer matrix . . . . . . . . . . . . . . Exa 12.1 Transfer Function . . . . . . . . . . . . . . . . . . Exa 12.2 Transfer Function . . . . . . . . . . . . . . . . . . Exa 12.3 Transfer Function . . . . . . . . . . . . . . . . . . Exa 12.4 Transfer Function . . . . . . . . . . . . . . . . . . Exa 12.5 Transfer Function . . . . . . . . . . . . . . . . . . Exa 12.7 Determine Peak Time and Peak Overshoot . . . . 8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
162 162 163 164 165 165 166 167 168 169 169 170 171 171 173 175 176 178 179 181 183 184 185 186 187 191 191 192 192 193 193 194 195 196 196 197 198 199
Exa 12.8 Time Response and Peak Overshoot . . . . . . . Exa 12.9 Determine Peak Overshoot . . . . . . . . . . . . Exa 12.10 Determine Unit Step Response . . . . . . . . . . Exa 12.11 Determine Unit Step and Unit Impulse Response Exa 12.12 Determine Wn Wd zeta and steady state error . Exa 12.13 Determine Wn Wd zeta and steady state error . Exa 12.15 Stability Using Routh Hurwitz Criterion . . . . . Exa 12.16 Stability Using Routh Hurwitz Criterion . . . . . Exa 12.17 Stability Using Routh Hurwitz Criterion . . . . . Exa 12.18 Stability Using Routh Hurwitz Criterion . . . . . Exa 12.19 Stability Using Routh Hurwitz Criterion . . . . . Exa 12.21 Determine Frequency of Oscillations . . . . . . . Exa 12.23.i Stability Using Nyquist Criterion . . . . . . . . . Exa 12.23.iiStability Using Nyquist Criterion . . . . . . . . . Exa 12.23.iiiStability Using Nyquist Criterion . . . . . . . . . Exa 12.27 Gain and Phase Margin . . . . . . . . . . . . . . Exa 12.33 Determine Close Loop Stability . . . . . . . . . . Exa 12.42 Root Locus . . . . . . . . . . . . . . . . . . . . . Exa 12.43 Root Locus and Value of K . . . . . . . . . . . . Exa 12.44 Root Locus and Value of K . . . . . . . . . . . . Exa 12.45 Root Locus and Value of K . . . . . . . . . . . . Exa 12.46 Root Locus and Value of K . . . . . . . . . . . . Exa 12.48 Root Locus and Value of K . . . . . . . . . . . . Exa 12.49 Root Locus and Value of K . . . . . . . . . . . . Exa 12.50 Root Locus and Closed loop Transfer Function . Exa 12.51 Root Locus and Gain and Phase Margin . . . . . Exa 12.54 Obtain State Matrix . . . . . . . . . . . . . . . . Exa 12.55 Obtain State Matrix . . . . . . . . . . . . . . . . Exa 12.56 Obtain State Transistion Matrix . . . . . . . . . Exa 12.57 Obtain Time Response . . . . . . . . . . . . . . . Exa 12.59 Obtain Time Response . . . . . . . . . . . . . . . Exa 12.61 Obtain Transfer Matrix . . . . . . . . . . . . . . AP 1 SERIES OF TWO FUNCTION . . . . . . . . . . AP 2 PARALLEL OF TWO FUNCTION . . . . . . .
9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
200 200 201 202 203 203 204 205 206 207 208 209 210 211 214 217 220 222 224 226 229 231 233 235 236 238 240 240 241 242 242 243 244 244
List of Figures 2.1
pole zero plot . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 7.10 7.11 7.12 7.13 7.14 7.15 7.16 7.17 7.18 7.19 7.20 7.21 7.22 7.23 7.24 7.25 7.26 7.27
root locus . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . stability using Nyquist criterion . . stability using Nyquist criterion . . stability using Nyquist criterion . . stability using Nyquist criterion . . stability using Nyquist criterion . . stability using Nyquist criterion . . stability using Nyquist criterion . . stability using Nyquist criterion . . Phase Margin . . . . . . . . . . . . stability using Nyquist criterion . . gain phase plot . . . . . . . . . . . stability using bode plot . . . . . . gain margin and phase margin . . . stability using bode plot . . . . . . root locus description . . . . . . . . root locus description . . . . . . . . root locus description . . . . . . . . root locus . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . root locus . . . . . . . . . . . . . . Overall Transfer Function and Root root locus . . . . . . . . . . . . . . 10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Locus . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
15 73 74 75 84 86 87 89 90 92 93 95 96 98 100 102 103 105 106 108 111 113 116 118 120 123 125 127
8.1 8.2 8.3 8.4 8.5 8.6
design design design design design design
suitable compensator . suitable compensator . phase lead compensator phase lead compensator suitable compensator . suitable compensator .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
132 133 135 136 139 140
11.1 pole zero Plot . . . . . . . . . . 11.2 bode plot . . . . . . . . . . . . 11.3 gain margin and phase margin . 11.4 stability using Nyquist criterion 11.5 stability using Nyquist criterion 11.6 stability using Nyquist criterion 11.7 stability using Nyquist criterion 11.8 root locus . . . . . . . . . . . . 11.9 root locus . . . . . . . . . . . . 11.10root locus . . . . . . . . . . . . 11.11root locus . . . . . . . . . . . . 11.12design lead compensator . . . . 11.13design lead compensator . . . . 11.14nicholas chart . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
157 172 174 175 177 178 180 182 183 184 185 188 189 190
12.1 Stability Using Nyquist Criterion . . . . . . . 12.2 Stability Using Nyquist Criterion . . . . . . . 12.3 Stability Using Nyquist Criterion . . . . . . . 12.4 Stability Using Nyquist Criterion . . . . . . . 12.5 Stability Using Nyquist Criterion . . . . . . . 12.6 Stability Using Nyquist Criterion . . . . . . . 12.7 Gain and Phase Margin . . . . . . . . . . . . 12.8 Determine Close Loop Stability . . . . . . . . 12.9 Root Locus . . . . . . . . . . . . . . . . . . . 12.10Root Locus and Value of K . . . . . . . . . . 12.11Root Locus and Value of K . . . . . . . . . . 12.12Root Locus and Value of K . . . . . . . . . . 12.13Root Locus and Value of K . . . . . . . . . . 12.14Root Locus and Value of K . . . . . . . . . . 12.15Root Locus and Value of K . . . . . . . . . . 12.16Root Locus and Closed loop Transfer Function
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
210 212 213 215 216 218 219 221 222 225 227 229 231 233 235 237
11
12.17Root Locus and Gain and Phase Margin . . . . . . . . . . .
12
239
Chapter 1 INTRODUCTION
Scilab code Exa 1.6.1.i inverse laplace transform 1 2 3 4 5 6 7 8 9 10 11
// C a p t i o n : i n v e r s e l a p l a c e t r a n s f o r m // e x a m p l e 1 . 6 . 1 . ( i ) // p a g e 7 // F ( s ) =1/( s ∗ ( s +1) ) s = %s ; syms t ; [ A ]= pfss (1/(( s ) *( s +1) ) ) // p a r t i a l f r a c t i o n o f F ( s ) F1 = ilaplace ( A (1) ,s , t ) F2 = ilaplace ( A (2) ,s , t ) F = F1 + F2 ; disp (F , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.1.ii inverse laplace transform 1 2 3 4
// C a p t i o n : i n v e r s e l a p l a c e t r a n s f o r m // e x a m p l e 1 . 6 . 1 . ( i i ) // p a g e 7 // F ( s )=s +6/( s ( s ˆ2+4 s +3) ) 13
5 s = %s ; 6 syms t ; 7 [ A ]= pfss (( s +6) /( s *( s ^2+4* s +3) ) ) // p a r t i a l 8 9 10 11 12 13
o f F( s ) A (1) =2/ s ; F1 = ilaplace ( A (1) ,s , t ) F2 = ilaplace ( A (2) ,s , t ) F3 = ilaplace ( A (3) ,s , t ) F = F1 + F2 + F3 ; disp (F , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.1.iii inverse laplace transform 1 // C a p t i o n : i n v e r s e l a p l a c e t r a n s f o r m 2 // e x a m p l e 1 . 6 . 1 . ( i i i ) 3 // p a g e 8 4 // F ( s ) =1/( s ˆ2+4 s +8) 5 s = %s ; 6 syms t ; 7 disp (1/( s ^2+4* s +8) ,”F ( s )=” ) 8 f = ilaplace (1/( s ^2+4* s +8) ,s , t ) 9 disp (f , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.1.iv inverse laplace transform 1 // C a p t i o n : i n v e r s e l a p l a c e t r a n s f o r m 2 // e x a m p l e 1 . 6 . 1 . ( i v ) 3 // p a g e 8 4 // F ( s )=s +2/( s ˆ2+4 s +6) 5 s = %s ; 6 syms t ; 7 disp (( s +2) /( s ^2+4* s +6) ,”F ( s )=” ) 8 F = ilaplace (( s +2) /( s ^2+4* s +6) ,s , t )
14
fraction
9
disp (F , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.1.v inverse laplace transform 1 // C a p t i o n : i n v e r s e l a p l a c e t r a n s f o r m 2 // e x a m p l e 1 . 6 . 1 . ( v ) 3 // p a g e 8 4 // F ( s ) =5/( s ( s ˆ2+4 s +5) ) 5 s = %s ; 6 syms t ; 7 [ A ]= pfss (5/( s *( s ^2+4* s +5) ) ) // p a r t i a l
fraction of
F( s ) 8 F1 = ilaplace ( A (1) ,s , t ) 9 F2 = ilaplace ( A (2) ,s , t ) 10 F = F1 + F2 ; 11 disp (F , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.1.vi program laplace transform 1 2 3 4
5 6 7 8 9 10
// C a p t i o n : p r o g r a m l a p l a c e t r a n s f o r m // e x a m p l e 1 . 6 . 1 . ( v ) // p a g e 9 // t h i s p r o b l e m i s s o l v e d i n two p a r t s b e c a u s e i n t h i s p r o b l e m p f s s f u n c t i o n d o n o t work . So , F i r s t we f i n d p a r t i a l f r a c t i o n u s i n g method a s we do i n maths and t h e n s e c o n d l y we f i n d i n v e r s e l a p l a c e transform as usual . // p a r t i a l f r a c t i o n s = %s syms t ; num =( s ^2+2* s +3) ; den =( s +2) ^3; g = syslin ( ’ c ’ , num / den ) ; 15
11 12 13 14 15 16 17 18 19 20 21 22
rd = roots ( den ) ; [ n d k ]= factors ( g ) a (3) = horner ( g * d (1) ^3 , rd (1) ) a (2) = horner ( derivat ( g * d (1) ^3) , rd (1) ) a (1) = horner ( derivat ( derivat ( g * d (1) ^3) ) , rd (1) ) // i n v e r s e l a p l a c e // p a r t i a l f r a c t i o n w i l l be : a ( 1 ) / ( s +1)+a ( 2 ) / ( ( s +2) ˆ 2 )+a ( 3 ) / ( ( s +2) ˆ 3 ) F1 = ilaplace (1/ d (1) ,s , t ) F2 = ilaplace ( -2/( d (1) ^2) ,s , t ) F3 = ilaplace (2*1.5/( d (1) ^3) ,s , t ) F = F1 + F2 + F3 disp (F , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.2 solution of differential equation 1 2 3 4 5 6 7 8 9 10 11 12 13
// C a p t i o n : s o l u t i o n o f d i f f e r e n t i a l e q u a t i o n // e x a m p l e 1 . 6 . 2 // p a g e 9 // a f t e r t a k i n g l a p l a c e t r a n s f o r m and a p p l y i n g g i v e n c o n d i t i o n , we g e t : //X( s ) =2 s +5/( s ( s +4) ) s = %s ; syms t [ A ]= pfss ((2* s +5) /( s *( s +4) ) ) A (1) =1.25/ s F1 = ilaplace ( A (1) ,s , t ) F2 = ilaplace ( A (2) ,s , t ) f = F1 + F2 ; disp (f , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.3 solution of differential equation 16
1 2 3 4 5 6 7 8 9
// C a p t i o n : s o l u t i o n o f d i f f e r e n t i a l e q u a t i o n // e x a m p l e 1 . 6 . 3 // p a g e 10 // a f t e r t a k i n g l a p l a c e t r a n s f o r m and a p p l y i n g g i v e n c o n d i t i o n , we g e t : //X( s ) =1/( s ˆ2+2 s +2) s = %s ; syms t f = ilaplace (1/( s ^2+2* s +2) ,s , t ) ; disp (f , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.4 solution of differential equation 1 2 3 4 5 6 7 8 9 10 11 12 13
// C a p t i o n : s o l u t i o n o f d i f f e r e n t i a l e q u a t i o n // e x a m p l e 1 . 6 . 4 // p a g e 10 // a f t e r t a k i n g l a p l a c e t r a n s f o r m and a p p l y i n g g i v e n c o n d i t i o n , we g e t : //Y( s ) =(6∗ s +6) / ( ( s −1) ∗ ( s +2) ∗ ( s +3) ) s = %s ; syms t [ A ]= pfss ((6* s +6) /(( s -1) *( s +2) *( s +3) ) ) F1 = ilaplace ( A (1) ,s , t ) F2 = ilaplace ( A (2) ,s , t ) F3 = ilaplace ( A (3) ,s , t ) F = F1 + F2 + F3 ; disp (F , ” f ( t )=” ) // r e s u l t
Scilab code Exa 1.6.5 initial value 1 2 3
// C a p t i o n : i n i t i a l v a l u e // e x a m p l e 1 . 6 . 5 // p a g e 11 17
4 5 6 7 8 9 10 11 12 13 14 15 16 17
// I ( s ) =(C∗ s / ( RCs+1) ) ∗E( s ) // g i v e n : E( s ) =100/ s , R=2 megaohm ,C=1 uF // so , I ( s ) =(((1 ∗10ˆ −6) ∗ s ) / ( 2 ∗ s +1) ) ∗ ( 1 0 0 / s ) syms t p = poly ([0 10^ -6] , ’ s ’ , ’ c o e f f ’ ) ; q = poly ([1 2] , ’ s ’ , ’ c o e f f ’ ) ; r = poly ([0 1] , ’ s ’ , ’ c o e f f ’ ) ; F1 = p / q ; F2 =1/ r ; F = F1 * F2 f = ilaplace (F ,s , t ) ; z = limit (f ,t ,0) ; // i n i t i a l v a l u e t h e o r e m z = dbl ( z ) ; disp (z , ” i (0+)=” )
Scilab code Exa 1.6.7 final value 1 2 3 4 5 6 7 8 9 10 11 12
// C a p t i o n : f i n a l v a l u e // e x a m p l e 1 . 6 . 7 // p a g e 12 //X( s ) =100/( s ∗ ( s ˆ2+2∗ s +50) ) p = poly ([100] , ’ s ’ , ’ c o e f f ’ ) ; q = poly ([0 50 2 1] , ’ s ’ , ’ c o e f f ’ ) ; F=p/q; syms s x=s*F; y = limit (x ,s ,0) ; // f i n a l v a l u e t h e o r e m y = dbl ( y ) disp (y , ” x ( i n f )=” ) // r e s u l t
Scilab code Exa 1.6.8 steady state value 1
// C a p t i o n : s t e a d y s t a t e v a l u e 18
2 3 4 5 6 7 8 9 10 11 12
// e x a m p l e 1 . 6 . 7 // p a g e 12 //X( s )=s / ( s ˆ 2 ∗ ( s ˆ2+6∗ s +25) ) p = poly ([0 1] , ’ s ’ , ’ c o e f f ’ ) ; q = poly ([0 0 25 6 1] , ’ s ’ , ’ c o e f f ’ ) ; F=p/q; syms s x=s*F; y = limit (x ,s ,0) ; // f i n a l v a l u e t h e o r e m y = dbl ( y ) disp (y , ” x ( i n f )=” ) // r e s u l t
Scilab code Exa 1.6.9 initial values // C a p t i o n : i n i t i a l v a l u e s // e x a m p l e 1 . 6 . 7 // p a g e 13 //F ( s ) =(4∗ s +1) / ( s ˆ3+2∗ s ) s = %s ; syms t ; F =(4* s +1) /( s ^3+2* s ) f = ilaplace (F ,s , t ) ; y = limit (f ,t ,0) ; // i n i t i a l v a l u e t h e o r e m y = dbl ( y ) ; disp (y , ” f (0+)=” ) // s i n c e F ’ ( s )=sF ( s )− f (0+) where L ( f ’ ( t ) )=F ’ ( s )=F1 F1 =(4* s +1) /( s ^2+2) f1 = ilaplace ( F1 ,s , t ) ; y1 = limit ( f1 ,t ,0) ; // i n i t i a l v a l u e t h e o r e m y1 = dbl ( y1 ) ; disp ( y1 , ” f p r i m e (0+)=” ) // s i n c e F ’ ’ ( s ) =( s ˆ 2 ) ∗F ( s )−s ∗ f (0+)−f ’ ( 0 + ) where L ( f ’ ’ ( t ) )=F ’ ’ ( s )=F2 19 F2 =( s -8) /( s ^2+2) 20 f2 = ilaplace ( F2 ,s , t ) ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
19
21 y2 = limit ( f2 ,t ,0) ; // i n i t i a l v a l u e t h e o r e m 22 y2 = dbl ( y2 ) ; 23 disp ( y2 , ” f d o u b l e p r i m e (0+)=” )
Scilab code Exa 1.6.10 final value 1 2 3 4 5 6 7 8 9 10
// C a p t i o n : f i n a l v a l u e // e x a m p l e 1 . 6 . 1 0 // p a g e 13 syms t s ; F =4/( s ^2+2* s ) x=s*F x = simple ( x ) z = limit (x ,s ,0) ; // f i n a l v a l u e t h e o r e m z = dbl ( z ) ; disp (z , ” f (0+)=” )
20
Chapter 2 TRANSFER FUNCTIONS
Scilab code Exa 2.4.1 pole zero plot 1 2 3 4 5 6 7 8 9 10 11 12 13
// C a p t i o n : p o l e z e r o P l o t // e x a m p l e 2 . 4 . 1 // p a g e 19 // t r a n s f e r f u n c t i o n :G( s ) = ( 1 / 2 ( ( s ˆ2+4) ∗ ( 1 + 2 . 5 ∗ s ) ) / ( ( s ˆ2+2) ∗ ( 1 + 0 . 5 ∗ s ) ) ) s = %s ; G = syslin ( ’ c ’ ,(1/2*(( s ^2+4) *(1+2.5* s ) ) /(( s ^2+2) *(1+0.5* s ) ) ) ) ; disp (G , ”G( s )=” ) ; x = plzr ( G ) xtitle ( ’ p o l e −z e r o c o n f i g u r a t i o n ’ , ’ R e a l p a r t ’ , ’ Img part ’ ); // v a l u e a t s =2 a =2; g =(1/2*(( a ^2+4) *(1+2.5* a ) ) /(( a ^2+2) *(1+0.5* a ) ) ) ; disp (g , ”G( 2 )=” ) ;
21
Figure 2.1: pole zero plot
22
Scilab code Exa 2.4.2 final value 1 // C a p t i o n : f i n a l v a l u e 2 // e x a m p l e 2 . 4 . 2 3 // p a g e 20 4 // r e f e r t o f i g . 2 . 4 . 2 g i v e n on p a g e 20 5 // p o l e s a r e l o c a t e d a t s =0,−2 and −4 6 // z e r o a t s=−3 7 s = %s ; 8 syms K ; 9 g = syslin ( ’ c ’ ,(( s +3) ) /( s *( s +2) *( s +4) ) ) ; // t r a n s f e r
function 10 G = K * g ; // t r a n s f e r f u n c t i o n 11 disp (G , ”G( s )=” ) ; 12 //G( s ) =3.2 a t s =1; 13 // on s o l v i n g we f i n d K=12 14 K =12; 15 G = K * g ; 16 disp (G , ”G( s )=” )
23
Chapter 3 BLOCK DIAGRAMS
Scilab code Exa 3.2.1 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 1 // p a g e 32 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 H1 ; // s h i f t i n g t a k e o f f p o i n t a f t e r b l o c k G2 t o a p o s i t i o n b e f o r e b l o c k G2 a = G2 * H1 ; b = parallel ( G2 , G3 ) ; // s h i f t i n g t a k e o f f p o i n t b e f o r e ( G2+G3 ) t o A f t e r ( G2+G3 ) c=a/b; m =1; d = b /(1+ m * b ) ; e = series ( G1 , d ) ; y =( e /(1+ c * e ) ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) ; 24
check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.2 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 2 // p a g e 34 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 H1 ; // s h i f t i n g t a k e o f f p o i n t b e f o r e b l o c k G1 t o a p o s i t i o n a f t e r b l o c k G1 a = G1 * H1 ; b = parallel ( G1 , G2 ) ; c = G3 /. a y = series (b , c ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
25
Scilab code Exa 3.2.3 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 3 // p a g e 35 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 G4 G5 G6 H1 H2 ; // s h i f t t h e t a k e o f p o i n t p l a c e d b e f o r e G2 t o w a r d s r i g h t s i d e o f b l o c k G2 a = G5 / G2 ; b = parallel ( G3 , G4 ) ; c = series (b , G6 ) ; d = parallel (a , c ) ; e = series ( G1 , G2 ) ; l = series ( H1 , d ) ; g = e /. H2 y = g /(1+ g * l ) y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.4 Transfer Function 1 2 3
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 4 // p a g e 36 26
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 H1 H2 ; // s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G1 t o a f t e r b l o c k G1 a = G3 / G1 ; b = parallel (a , G2 ) ; // s h i f t t h e t a k e o f f p o i n t b e f o r e b l o c k b t o w a r d s r i g h t s i d e o f same b l o c k c =1/ b ; d = series ( H1 , c ) ; e = series ( G1 , b ) ; g = parallel ( H2 , d ) ; y = e /(1+ e * g ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.5 Transfer Function // C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 5 // p a g e 37 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e 5 // e x e c p a r a l l e l . s c e ; 6 // e x e c s e r i e s . s c e ; 7 syms G1 G2 G3 H1 H2 H3 ;
1 2 3 4
27
8 9 10 11 12 13 14 15 16 17 18
// s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G3 t o a f t e r b l o c k G3 a = H3 / G3 ; b = G3 /. H2 ; c = series ( G2 , b ) ; // s h i f t t h e summing p o i n t a f t e r b l o c k G1 t o b e f o r e b l o c k G1 d = a / G1 ; e = G1 /. H1 ; f = series (e , c ) ; y = f /(1+ f * d ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.6 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 6 // p a g e 38 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 H1 ; a = parallel ( G1 , G3 ) ; b = G2 /. H1 ; y = series (a , b ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) ; 28
check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.7 Transfer Function 1 2 3 4 5 6 7 8 9 10
11
12 13 14 15 16 17 18 19
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 7 // p a g e 39 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 H1 H2 ; // s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G2 t o a f t e r b l o c k G2 a = G2 * H1 ; // s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G2 t o a f t e r b l o c k G1 and s h i f t t h e summing p o i n t b e f o r e b l o c k G2 t o b e f o r e b l o c k G2 // i n t e r c h a n g e c o n s e c u t i v e summing p o i n t and s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e H2 t o a f t e r b l o c k H2 b = G2 * H2 ; c = b * H1 ; d = parallel ( G3 , G2 ) ; e =1/. b f = series (d , e ) ; g = G1 /. a h = series (g , f ) ; y = h /(1 - h * c ) ; 29
20 y = simple ( y ) ; 21 disp (y , ”C( s ) /R( s )=” )
check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.8 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 8 // p a g e 41 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 G4 G5 H1 H2 ; // s h i f t t h e summing p o i n t b e f o r e b l o c k G5 t o w a r d s l e f t o f b l o c k G5 a = G2 * G5 ; b = G4 /. H1 ; c = series ( G5 , H2 ) ; d = series (b , G3 ) ; e = d /(1+ d * c ) ; e = simple ( e ) f = parallel ( G1 , a ) ; y = series (f , e ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) ; check Appendix AP 2 for dependency: parallel.sce 30
check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.9 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 9 // p a g e 42 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 G4 G5 H1 H2 H3 ; // s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G3 t o a f t e r b l o c k G3 a = G5 / G3 ; b = G1 /. H1 ; c = series (b , G2 ) ; d = G3 /. H2 ; e = parallel ( G4 , a ) ; e = simple ( e ) ; f = series (c , d ) ; g = series (f , e ) ; g = simple ( g ) ; y = g /(1+ g * H3 ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) ; check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
31
Scilab code Exa 3.2.10 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 1 0 // p a g e 43 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 G4 G5 H1 H2 H3 ; a = parallel ( G3 , G4 ) ; // s h i f t o f f t h e t a k e o f f p o i n t b e f o r e b l o c k ’ a ’ t o a f t e r block ’a ’ b =1/ a ; d =1; c = G2 /(1+ G2 * d ) ; e = parallel ( H1 , b ) ; f = series (c , a ) ; g = series ( H2 , e ) ; h = f /(1+ f * g ) ; h = simple ( h ) ; i = series (h , G1 ) ; y = i /(1+ i * H3 ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
32
Scilab code Exa 3.2.11 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 1 1 // p a g e 45 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 G4 H1 H2 H3 ; a = G4 /. H1 ; // s h i f t t h e summing p o i n t a f t e r b l o c k G3 t o w a r d s l e f t o f b l o c k G3 b = G2 / G3 ; c = series (a , G3 ) ; d = c /(1+ c * H2 ) ; d = simple ( d ) // s h i f t t h e summing p o i n t b e f o r e b l o c k G1 t o w a r d s r i g h t o f b l o c k G1 e = G1 * H3 ; f = d /(1+ d * e ) ; f = simple ( f ) g = parallel ( G1 , b ) ; g = simple ( g ) ; y = series (g , f ) y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) ; check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.12 Transfer Function 33
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
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 1 2 // p a g e 47 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 G4 H1 H2 H3 ; // s h i f t t h e summing p o i n t b e f o r e b l o c k G1 t o w a r d s r i g h t o f b l o c k G1 // s h i f t t h e summing p o i n t a f t e r b l o c k G3 t o w a r d s l e f t o f b l o c k G3 a = G2 / G1 b = H3 / G3 ; c = G1 /. H1 d = G3 /. H2 e = series ( G4 , d ) // s h i f t t h e summing p o i n t a f t e r b l o c k e t o w a r d s l e f t of block e g =1/ e f = series (a , g ) ; f = simple ( f ) h = parallel (f ,1) ; h = simple ( h ) i = e /(1+ e * b ) ; i = simple ( i ) j = series (c , h ) ; y = series (j , i ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) ; check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
34
Scilab code Exa 3.2.13 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 1 3 // p a g e 49 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 G4 H1 H2 ; // s h i f t t h e summing p o i n t a f t e r b l o c k H2 t o w a r d s r i g h t o f b l o c k H2 // s h i f t t h e summing p o i n t a f t e r b l o c k H1 t o w a r d s r i g h t o f b l o c k H2 a = H1 * H2 b = parallel ( G1 , G2 ) c = G4 /. a d = series ( G3 , c ) e = d /(1+ d * H2 ) ; e = simple ( e ) f = series (b , e ) y = f /(1+ f * a ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) ; check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
35
Scilab code Exa 3.2.14 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 1 4 // p a g e 50 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 G3 G4 H1 H2 R D ; a = parallel ( G1 , G2 ) b = G3 /. H2 c = series (a , b ) // i n o r d e r t o d e t e r m i n e C( s ) /R( s ) c o n s i d e r D=0 d = series (c , G4 ) ; y = d /(1+ d * H1 ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” ) // now c o n s i d e r R=0 f o r c a l c u l a t i n g C( s ) /D( s ) e = series (c , H1 ) z = G4 /(1+ G4 * e ) ; z = simple ( z ) ; disp (z , ”C( s ) /D( s )=” ) ; x =( y * R ) +( z * D ) ; x = simple ( x ) ; printf ( ” t o t a l o u t p u t ” ) ; disp (x , ”C( s ) ” ) check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
Scilab code Exa 3.2.15 Transfer Function 36
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
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 3 . 2 . 1 5 // p a g e 52 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e // e x e c p a r a l l e l . s c e ; // e x e c s e r i e s . s c e ; syms G1 G2 H1 H2 H3 D1 D2 R ; a = G2 /. H2 b = a /(1+ a * H3 ) ; b = simple ( b ) // i n o r d e r t o d e t e r m i n e C( s ) /R( s ) c o n s i d e r D1=0 ,D2=0 c = series (b , G1 ) y = c /(1+ c * H1 ) ; y = simple ( y ) disp (y , ”C( s ) /R( s ) ” ) ; // now c o n s i d e r R=0 ,D2=0 f o r c a l c u l a t i n g C( s ) /D1 ( s ) d = series ( G1 , H1 ) ; z = b /(1+ b * d ) ; z = simple ( z ) disp (z , ”D1 ( s ) /R( s ) ” ) ; // now c o n s i d e r R=0 ,D1=0 f o r c a l c u l a t i n g C( s ) /D2 ( s ) e = G1 *( - H1 ) ; f = series (b , e ) ; x = f /(1+ f ) ; x = simple ( x ) ; disp (x , ”D2 ( s ) /R( s ) ” ) ; out =( y * R ) +( z * D1 ) +( x * D2 ) ; out = simple ( out ) ; disp ( out , ”C( s ) ” ) ; check Appendix AP 2 for dependency: parallel.sce check Appendix AP 1 for dependency: series.sce
37
Chapter 4 SIGNAL FLOW GRAPHS
Scilab code Exa 4.3.1 Overall Transmittance 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// C a p t i o n : o v e r a l l t r a n s m i t t a n c e // e x a m p l e 4 . 3 . 1 // p a g e 63 syms G1 G2 H1 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D L1 = - G1 * H1 ; L2 = - G2 * H1 ; P1 = G1 ; P2 = G2 ; D1 =1; D2 =1; D =1 -( L1 + L2 ) ; Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) disp (Y , ”C( s ) /R( s )=” )
38
Scilab code Exa 4.3.2 Overall Transmittance 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// C a p t i o n : o v e r a l l t r a n s m i t t a n c e // e x a m p l e 4 . 3 . 2 // p a g e 64 syms G1 G2 H1 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 ; P2 = G2 ; L1 = - G1 * H1 ; D1 =1; D2 =1; D =1 -( L1 ) ; Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” )
Scilab code Exa 4.4.1 Closed Loop Transfer Function 1 2 3 4 5 6 7 8 9 10 11
// C a p t i o n : c l o s e d l o o p t r a n s f e r f u n c t i o n // e x a m p l e 4 . 4 . 1 // p a g e 64 syms G1 G2 G3 H1 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 * G3 ; P2 = G2 * G3 ; L1 = - G3 * H1 ; D1 =1; D2 =1; 39
12 D =1 -( L1 ) ; 13 Y =( P1 * D1 + P2 * D2 ) / D ; 14 Y = simple ( Y ) 15 disp (Y , ”C( s ) /R( s )=” )
Scilab code Exa 4.4.2 Overall Gain 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// C a p t i o n : o v e r a l l g a i n // e x a m p l e 4 . 4 . 2 // p a g e 65 syms a b c d e f g h // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = a * b * c * d ; P2 = a * g ; L1 = f ; L2 = c * e ; L3 = d * h ; // n o n t o u c h i n g l o o p s a r e L1L2 , L1L3 L1L2 = L1 * L2 ; L1L3 = L1 * L3 ; D1 =1; D2 =1 - L2 ; D =1 -( L1 + L2 + L3 ) +( L1L2 + L1L3 ) ; D = simple ( D ) ; Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) ; disp (Y , ” x5 / x1 ” ) ;
Scilab code Exa 4.4.3 to find various signal flow graph parameter 40
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
// C a p t i o n : to find various signal flow graph parameter // e x a m p l e 4 . 4 . 3 // p a g e 66 syms a b c d e f g h ij // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D // s i x i n d e p e n d e n t p a t h P1 = a * b * d P2 = e * f * h P3 = a * j * h P4 = e * i * d P5 = - e * i * c * j * h P6 = - a * j * g * i * d // 3 INDIVIDUAL LOOPS L1 = - b * c L2 = - f * g L3 = - i * c * j * g //NON TOUCHING LOOPS L1L2 = L1 * L2 //PATH FACTORS D3 =1; D4 =1; D5 =1; D6 =1 D1 =1 - L2 D2 =1 - L1 //GRAPH DETERMINANT D =1 -( L1 + L2 + L3 ) +( L1L2 ) ; D = simple ( D ) disp (D , ” g r a p h d e t e r m i n a n t=” )
Scilab code Exa 4.4.4 Transfer function using mason gain formula 1
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n ’ s gain formula 41
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// e x a m p l e 4 . 4 . 4 // p a g e 67 syms G1 G2 G3 H1 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 * G2 *1; P2 = G1 * G3 ; L1 = G2 *( -1) ; L2 = G3 *( -1) ; L3 = - G1 * G2 * H1 D1 =1; D2 =1; D =1 -( L1 + L2 + L3 ) ; Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” )
Scilab code Exa 4.4.5 Transfer function using mason gain formula 1 2 3 4 5 6 7 8 9 10 11
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n ’ s gain formula // e x a m p l e 4 . 4 . 5 // p a g e 68 syms G1 G2 G3 H1 H2 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 * G2 ; P2 = G1 * G3 ; L1 = - G2 * H2 ; L2 = - G1 * G2 * H1 ; L3 = G1 * G3 *( - H2 ) * G2 *( - H1 ) ; 42
12 13 14 15 16 17 18 19
L3 = simple ( L3 ) D1 =1; D2 =1; D =1 -( L1 + L2 + L3 ) ; D = simple ( D ) Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” )
Scilab code Exa 4.4.6 Transfer function using mason gain formula 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n ’ s gain formula // e x a m p l e 4 . 4 . 6 // p a g e 69 syms G1 G2 G3 G4 H1 H2 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D // t o f i n d C/R c o n s i d e r D=0 P1 = G1 * G3 * G4 ; P2 = G2 * G3 * G4 ; L1 = - G3 * H1 ; L2 = - G1 * G3 * G4 * H2 ; L3 = - G2 * G3 * G4 * H2 ; D1 =1; D2 =1; D =1 -( L1 + L2 + L3 ) ; D = simple ( D ) Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” )
43
Scilab code Exa 4.4.7 Transfer function using mason gain formula 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n ’ s gain formula // e x a m p l e 4 . 4 . 7 // p a g e 70 syms G1 G2 G3 H1 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 * G3 * G4 ; P2 = G1 *( - G2 ) ; L1 = G3 * G4 *( -1) ; L2 = G1 * G3 * H1 *( -1) ; L3 = G1 * G3 * H1 *( -1) ; L4 = G1 *( - G2 ) *( -1) * G3 * H1 *( -1) ; L5 = G1 *( - G2 ) *( -1) * G3 * H1 *( -1) ; L4 = simple ( L4 ) ; L5 = simple ( L5 ) ; D1 =1; D2 =1; D =1 -( L1 + L2 + L3 + L4 + L5 ) ; D = simple ( D ) Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” )
Scilab code Exa 4.4.8 Transfer function using mason gain formula 1
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n ’ s gain formula 44
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// e x a m p l e 4 . 4 . 8 // p a g e 70 syms G1 G2 G3 G4 G5 H1 H2 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 * G2 * G4 ; P2 = G2 * G3 * G5 ; P3 = G3 ; L1 = - G4 * H1 ; L2 = - G2 * G4 * H2 ; L3 = - G2 * G5 * H2 ; D1 =1; D2 =1; D3 =1 - L1 ; D =1 -( L1 + L2 + L3 ) ; D = simple ( D ) Y =( P1 * D1 + P2 * D2 + P3 * D3 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” )
Scilab code Exa 4.4.9 Overall Transfer Function 1 2 3 4 5 6 7 8 9
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n // e x a m p l e 4 . 4 . 9 // p a g e 71 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e exec parallel . sce ; exec series . sce ; syms G1 G2 G3 G4 H5 H1 H2 ; // s h i f t t h e SUMMING p o i n t l o c s t e d a f t e r G3 t o w a r d s l e f t o f b l o c k G3 a = G2 /. H1 ; 45
10 11 12 13 14 15 16 17 18
b = G5 / G3 ; c = parallel (a , b ) ; c = simple ( c ) ; d = G3 /. H2 ; e = series ( G1 , c ) ; f = series (e , d ) ; y = series ( G4 , f ) ; y = simple ( y ) ; disp (y , ”C( s ) /R( s )=” )
Scilab code Exa 4.4.10 Transfer function using mason gain formula 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n ’ s gain formula // e x a m p l e 4 . 4 . 1 0 // p a g e 72 syms G1 G2 G3 G4 G5 H1 H2 ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 * G2 * G3 * G4 ; P2 = G1 * G5 * G4 ; L1 = - G2 * H1 ; L2 = - G3 * H2 ; D1 =1; D2 =1; D =1 -( L1 + L2 ) ; D = simple ( D ) Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” )
46
Chapter 5 MODELLING A CONTROL SYSTEM
Scilab code Exa 5.9.4 Calculate Reference Voltage Vr 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// C a p t i o n : c a l c u l a t e r e f e r e n c e v o l t a g e V r // e x a m p l e 5 . 9 . 4 // p a g e 102 exec series . sce ; A =2 // a m p l i f i e r K =10 // m o t o r f i e l d N =100 // s p e e d tg =0.1 // t a c h o g e n e r a t o r a = series (A , K ) ; b = a /. tg ; disp (b , ”N/ Vr=” ) ; // s i n c e N=100 Vr = N *(1/ b ) ; disp ( Vr , ” r e f e r e n c e v o l t a g e =” ) ; check Appendix AP 1 for dependency: series.sce
47
Scilab code Exa 5.9.5 Calculate Reference Voltage Vr 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17
// C a p t i o n : c a l c u l a t e r e f e r e n c e v o l t a g e V r // e x a m p l e 5 . 9 . 5 // p a g e 102 exec series . sce ; Vt =250 // o u t p u t v o l t a g e Rf =100 // f i e l d w i n d i n g r e s i s t a n c e Kg =500 // g e n e r a t o r c o n s t a n t A =2 // a m p l i f i e r Vf =0.4 // fraction of output voltage compared with reference voltage a =1/ Rf ; b = series (A , a ) ; c = series (b , Kg ) ; d = c /. Vf ; disp (d , ” Vt / Vr=” ) ; // s i n c e Vt=250 Vr = Vt *(1/ d ) ; disp ( Vr , ” r e f e r e n c e v o l t a g e =” ) ; check Appendix AP 1 for dependency: series.sce
Scilab code Exa 5.9.6 Calculate Gain of Amplifier Ka // C a p t i o n : c a l c u l a t e g a i n o f a m p l i f i e r K a // e x a m p l e 5 . 9 . 6 // p a g e 103 // s t e a d y s t a t e e q u a t i o n s : Ei=Vt+ I l ∗Ra and Vt= I l ∗ Rl // where Vt=o u t p u t v o l t a g e , Rl= l o a d r e s i s t a n c e , Ra= a r m a t u r e r e s i s t a n c e , I l =l o a d c u r r e n t , 6 syms Rl Ra Ka Er e ; 7 Ei =450;
1 2 3 4 5
48
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
If =1.5; // f i e l d c u r r e n t Kg = Ei / If ; // g e n e r a t o r e m f c o n s t a n t Vt =400; // from s t e d y s t a t e eq . we g e t : Vt / Ei=Rl / ( Rl+Ra ) a = Rl /( Rl + Ra ) ; a = Vt / Ei ; c =( Kg * a ) ; G =( Ka * c ) ; H =0.1; // t r a n s f e r f u n c t i o n r e l a t i n g e r r o e ’ e ’ and t h e r e f e r e n c e v o l t a g e ’ Er ’ i s e / Er =1/(1+GH) b = e / Er ; b =1/(1+ G * H ) ; e = Vt * H *.02 ; // s i n c e a l l o w a b l e e r r o r i s 2% Er =( Vt * H ) + e ; // s i n c e e / Er =1/(1+G∗H) , on p u t t i n g v a l u e o f e , Er ,G and H and s o l v i n g we g e t Ka =1.89; disp ( Ka , ” g a i n o f a m p l i f i e r K a =” ) ;
Scilab code Exa 5.9.7 Transfer Function of Generator 1 2 3 4 5 6 7 8 9 10 11 12
// C a p t i o n : t r a n s f e r f u n c t i o n o f g e n e r a t o r // e x a m p l e 5 . 9 . 7 // p a g e 105 syms E Vf Kg R L s = %s ; // g e n e r a t o r f i e l d c o n s t a n t K g =d e l t a ( e ) / d e l t a ( I f ) Kg =50/2; L =2; // f i e l d i n d u c t a n c e R =200; // f i e l d r e s i s t a n c e // t r a n s f e r f u n c t i o n i s g i v e n by : E/ Vf=(Kg/R+s ∗L ) a = Kg /( R + s * L ) ; disp (a , ”E( s ) / Vf ( s )=” ) ;
49
Scilab code Exa 5.9.8 Overall Transfer Function of given System 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n o f g i v e n s y s t e m // e x a m p l e 5 . 9 . 8 // p a g e 105 syms Rf Ra Kb Jm Lf La Kg Kt Jl s Rf =1000; // f i e l d r e s i s t a n c e Lf =100; // f i e l d i n d u c t a n c Kg =1000; // g e n e r a t o r f i e l d c o n s t a n t Ra =20; // a r m a t u r e r e s i s t a n c e La =0.1; // a r m a t u r e i n d u c t a n c e Kt =1.2; // m o t o r t o r q u e c o n s t Kb =1.2; // m o t o r b a c k e m f c o n s t Jl =0.00003; // m o m e n t o f i n e r t i a Jm =0.00002; // c o e f f o f v i s c o u s f r i c t i o n a = Kt /( Ra + s * La ) ; b =1/(( Jm + Jl ) * s ) ; c =( a * b ) ; d = c /(1+ c * Kb ) ; e = Kg /( Rf + s * Lf ) ; f =( d * e ) ; f = simple ( f ) disp (f , ” wss ( s ) / Vf ( s )=” ) ;
// s t e a d y s t a t e v a l u e disp ( ” u n d e r s t e a d y s t a t e c o n d i t i o n , on p u t t i n g s =0 i n e x p r e s s i o n f , we g e t : ” ) 25 disp ( ” Vf =1.2∗ wss ” )
Scilab code Exa 5.9.9 Overall Transfer Function of given System 1
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n o f g i v e n s y s t e m 50
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// e x a m p l e 5 . 9 . 9 // p a g e 107 syms Ka Ke Kt J f N1 N2 s = %s ; Ke =10; // e r r o r d e t e c t o r g a i n Ka =100; // a m p l i f i e r t r a n s c o n d u c t a n c e Kt =.0005; // m o t o r t o r q u e c o n s t J =.0000125; // m o m e n t o f i n e r t i a f =.0005; // c o e f f o f v i s c o u s f r i c t i o n g = N1 / N2 ; g =1/20; a =( Ka * Ke ) ; b =( a * Kt ) ; c =1/( J * s ^2+ f * s ) ; d =( c * b ) ; e =( g * d ) ; h = e /(1+ e ) ; disp (h , ”C( s ) /R( s )=” ) ; // r e s u l t
Scilab code Exa 5.9.10 Overall Transfer Function of given System 1 2 3 4 5
6 7 8 9 10 11
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n o f g i v e n s y s t e m // e x a m p l e 5 . 9 . 1 0 // p a g e 108 syms Ra Kt Jm fm Kb // where Ra=a r m a t u r e r e s i s t a n c e ; Kt= m o t o r t o r q u e c o n s t ; Jm=m o m e n t o f i n e r t i a ; fm= c o e f f o f v i s c o u s f r i c t i o n ; Kb= motor back emf const s = %s ; a = Kt /( s * Ra *( s * Jm + fm ) ) ; a = simple ( a ) ; b = s * Kb ; c = a /(1+ a * b ) ; c = simple ( c ) ; 51
12 13 14 15 16 17
disp (c , ”Q( s ) /V( s )=” ) ; // o v e r a l l t r a n s f e r f u n c t i o n Kt =0.183; Kb =0.183; Ra =4.8; Jm =.004; fm =0.0015; a = Kt /( s * Ra *( s * Jm + fm ) ) ; b = s * Kb ; c = a /(1+ a * b ) ; disp (c , ”Q( s ) /V( s )=” ) ; // overall transfer function after substituting v a l u e i n above e q u a t i o n
Scilab code Exa 5.9.11 Overall Transfer Function of given System 1
// C a p t i o n : overall transfer function of positional control system
2 3 4 5
// e x a m p l e 5 . 9 . 1 1 // p a g e 109 syms Ka Ke Kb Kt Jeq feq Ra N1 N2 // where Ka= a m p l i f i e r g a i n ; Ke= e r r o r d e t e c t o r g a i n ; Kb=m o t o r b a c k e m f c o n s t ; Kt=m o t o r t o r q u e c o n s t ; Jeq=m o m e n t o f i n e r t i a ; Ra=a r m a t u r e r e s i s t a n c e ; f e q= c o e f f o f v i s c o u s f r i c t i o n ; s = %s ; Kt =.0001; Ra =0.2; Jeq =.0001; feq =.0005; Ka =10; Ke =2; Kb =0.0001; f =0.1; a =( Ka * Ke ) ; // i n s e r i e s b = Kt /( s * Ra *( Jeq * s + feq ) ) ; c = b /(1+ b * s * Kb ) ; d =( a * c ) ; // i n s e r i e s f =0.1; g =( d * f ) ; // i n s e r i e s h = g /(1+ g ) ; disp (h , ”C( s ) /R( s )=” ) ; // overall transfer function after substituting v a l u e i n above e q u a t i o n
6 7 8 9 10 11 12 13 14 15
52
Scilab code Exa 5.9.12 Overall Transfer Function of given System 1 2 3 4 5
6 7 8 9 10 11 12 13 14 15 16
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n o f g i v e n s y s t e m // e x a m p l e 5 . 9 . 1 2 // p a g e 111 syms Ka Ke Kf Rf Lf Jeq feq N1 N2 // where Ka= a m p l i f i e r g a i n ; Ke= e r r o r d e t e c t o r g a i n ; Kf=m o t o r t o r q u e c o n s t ; Rf= f i e l d r e s i s t a n c e ; L f= f i e l d i n d u c t a n c e Jeq=m o m e n t o f i n e r t i a ; f e q= coeff of viscous friction ; s = %s ; d = N1 / N2 ; Ka =10; Ke =8; Kf =0.05; Rf =5; Lf =0.25; Jeq =0.05; feq =0.075; d =0.1; a =( Ka * Ke ) ; b = Kf /( Rf + s * Lf ) ; c =1/( s *( Jeq * s + feq ) ) ; g =( b * c ) // i n s e r i e s h =( g * a ) // i n s e r i e s i =( h * d ) // i n s e r i e s j = i /(1+ i ) ; disp (j , ”C( s ) /R( s )=” ) ;
Scilab code Exa 5.9.13 Overall Transfer Function of Two Phase ac Motor 1 2 3 4 5
// C a p t i o n : overall transfer function of two phase ac motor // e x a m p l e 5 . 9 . 1 3 // p a g e 113 syms Ka K Ktg Jeq feq N1 N2 m // where Ka= a m p l i f i e r g a i n ; Ktg=t a c h o m e t e r g a i n c o n s t Jeq=m o m e n t o f i n e r t i a ; f e q= 53
6 7 8 9 10 11 12 13 14 15
coeff of viscous friction ; s = %s ; // from t o r q u e c h a r a c t e r s t i c s m and K a r e d e t e r m i n e d Ka =20; K =0.0012; Ktg =0.2; Jeq =0.00015; feq =0.0001; m = -0.0003; a = K /( Jeq * s +( feq - m ) ) ; b = N1 / N2 ; b =0.1; c =( Ka * a ) // i n s e r i e s d =( c * b ) // i n s e r i e s e = d /(1+ Ktg * d ) ; disp (e , ”C( s ) /R( s )=” ) ; // o v e r a l l t r a n s f e r f u n c t i o n
Scilab code Exa 5.9.14 Transfer Function Of Motor 1 2 3 4 5
6 7
8 9 10 11 12 13 14 15
// C a p t i o n : t r a n s f e r f u n c t i o n o f m o t o r // e x a m p l e 5 . 9 . 1 4 // p a g e 114 syms Kt Kb Ra La J // where Ka= a m p l i f i e r g a i n ; Kt=m o t o r t o r q u e c o n s t ; Ra =a r m a t u r e r e s i s t a n c e ; La=a r m a t u r e i n d u c t o r ; J= moment of inertia s = %s ; // s i n c e t h e r e a r e two i n p u t s Va ( s ) and Tl ( s ) . I f Va ( s ) i s h e l d a t f i x e d v a l u e t h e n o n l y e f f e c t o f Tl ( s ) i s c o n s i d e r e d and Va ( s ) i s t a k e n a s Z e r o . a =( Kt * Kb ) /( Ra + s * La ) b =1/ J * s c = b /(1+ b * a ) ; disp ( -c , ”Wm( s ) / Tl ( s )=” ) ; // n e g a t i v e s i g n i n d i c a t e s t h a t an i n c r e a s e i n Tl d e c r e a s e s Wm Kb =9.55; Kt =9.55; Ra =0.75; La =0.005; J =50; a =( Kt * Kb ) /( Ra + s * La ) b =1/( J ) *(1/( s ) ) c = b /(1+ b * a ) ; 54
16
disp ( -c , ”Wm( s ) / Tl ( s )=” ) ; // a f t e r p u t t i n g v a l u e s
55
Chapter 6 TIME RESPONSE ANALYSIS OF CONTROL SYSTEMS
Scilab code Exa 6.10.1 time response for step function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// C a p t i o n : t i m e r e s p o n s e f o r s t e p f u n c t i o n // e x a m p l e 6 . 1 0 . 1 // p a g e 170 // we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n which we a r e g o i n g t o u s e h e r e exec parallel . sce ; exec series . sce ; s = %s ; syms t ; a =4/( s *( s +4) ) b = s +1.2 c = s +0.8 d = a /(1+ a ) e = parallel (b , c ) f = d /. e ; disp (f , ”C( s ) /R( s )=” ) ; // t r a n s f e r f u n c t i o n // s i n c e i n p u t : r ( t ) =2 , s o R( s ) =2/ s ; / / step function of magnitude 2 g = f *(2/ s ) ; 56
18 disp (g , ”C( s )=” ) ; 19 [ A ]= pfss (8/( s *( s +2) *( s +6) ) ) 20 F = ilaplace ((8/( s *( s +2) *( s +6) ) ) ,s , t ) ; 21 disp (F , ”
time response for step function of magnitude 2 , f ( t )=” )
Scilab code Exa 6.10.2 Time Response for unit Impulse and Step function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// C a p t i o n : time response for unit impulse and step function // e x a m p l e 6 . 1 0 . 2 // p a g e 171 //G( s ) =(4∗ s +1) / 4 ∗ ( s ˆ 2 ) ; H( s ) =1; clc ; s = %s ; syms t ; G =(4* s +1) /(4*( s ^2) ) //G( s ) b =1; a = G /.( b ) ; disp (a , ”C( s ) /R( s )=” ) ; // f o r u n i t i m p u l s e r e s p o n s e R( s ) =1 ; s o C( s )=a ; disp ( ” f o r u n i t i m p u l s e r e s p o n s e R( s ) =1 ; s o C( s )=a ; ” ) disp (a , ”C( s )=” ) ; c = ilaplace (a ,s , t ) ; disp (c , ” c ( t )=” ) ; // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s disp ( ’ f o r u n i t s t e p r e s p o n s e R( s ) =1/ s , s o ’ ) ; d = a *(1/ s ) ; disp (d , ”C( s )=” ) ; e = ilaplace (d ,s , t ) ; disp (e , ” c ( t )=” ) ;
57
Scilab code Exa 6.10.3 Time Response for Unit Step Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n // e x a m p l e 6 . 1 0 . 3 // p a g e 172 //G( s ) =2/( s ∗ ( s +3) clc ; s = %s ; syms t ; G =2/( s *( s +3) ) //G( s ) b =1; a = G /.( b ) ; disp (a , ”C( s ) /R( s )=” ) ; disp ( ’ f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ’ ) ; d = a *(1/ s ) ; disp (d , ”C( s )=” ) ; e = ilaplace (d ,s , t ) ; disp (e , ” c ( t )=” ) ;
Scilab code Exa 6.10.4 Time Response for Unit Step Function 1 2 3 4 5 6 7 8 9 10 11
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n // e x a m p l e 6 . 1 0 . 4 // p a g e 172 s = %s ; syms t ; a =( s +4) ; b =1/( s *( s +2) ) ; c =( a * b ) ; // i n s e r i e s d =0.5; e = c /. d f =1; 58
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
g = e /. f ; disp (g , ”C( s ) /R( s )=” ) ; disp ( ’ f o r u n i t s t e p r e s p o n s e R( s ) =1/ s , so ’ ); h = g *(1/ s ) ; disp (h , ”C( s )=” ) ; [ A ]= pfss ( h ) ; A (1) =(1/ s ) F1 = ilaplace ( A (1) ,s , t ) //A( 2 ) can be w r i t t e n a s : A( 2 )=a1+a2 a1 = -1/(4*(6+3.5* s + s ^2) ) ; a2 =( -( s +1.75) /(6+3.5* s + s ^2) ) ; F2 = ilaplace ( a1 ,s , t ) ; F3 = ilaplace ( a2 ,s , t ) ; // now m u l t i p l y i n g by t h e i r c o e f f i c i e n t F1 =(2/3) * F1 ; F2 =(1/6) * F2 ; F3 =(2/3) * F3 ; // a f t e r a d d i n g F1 , F2 and F3 and s i m p l y f y i n g we g e t t i m e r e s p o n s e which i s d e n o t e d by ’ c ( t ) ’ 30 disp ( ’ c ( t ) =((2 −(%eˆ ( − 1 . 7 5 ∗ t ) ∗ ( 2 ∗ c o s ( 1 . 7 1 ∗ t ) −0.29∗ s i n ( 1 . 7 1 ∗ t ) ) ) ) /3 ’ ) ; // t i m e r e s p o n s e
Scilab code Exa 6.10.5 Calculate Wn zeta Wd tp Mp 1 // C a p t i o n : c a l c u l a t e W n , z e t a ,Wd, tp , Mp 2 // e x a m p l e 6 . 1 0 . 5 3 // p a g e 174 4 // g i v e n G( s ) =20/( s +1) ∗ ( s +2) 5 clc ; 6 s = %s ; 7 G = syslin ( ’ c ’ ,[20/(( s +1) *( s +5) ) ]) //G( s ) : t r a n s f e r
f u n c t i o n i n forward path 8 H =1; // backward p a t h t r a n s f e r f u n c t i o n 9 a = G /. H // c l o s e d l o o p t r a n s f e r f u n c t i o n 10 b = denom ( a ) 59
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
c = coeff ( b ) //Wnˆ2= c ( 1 , 1 ) Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y disp ( Wn , ” n a t u r a l f r e q u e n c y ,Wn=” ) // 2∗ z e t a ∗Wn=c ( 1 , 2 ) zeta = c (1 ,2) /(2* Wn ) // damping r a t i o disp ( zeta , ” damping r a t i o , z e t a=” ) Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y disp ( Wd , ” damping r a t i o ,Wd=” ) Tp = %pi / Wd // peak t i m e disp ( Tp , ” peak time , Tp=” ) Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max . overshoot disp ( Mp , ”max o v e r s h o o t , Mp=” ) t =(2* %pi ) /( Wn * sqrt (1 - zeta ^2) ) // p e r i o d o f o s c i l l a t i o n disp (t , ’ t i m e a t which f i r s t o v e r s h o o t o c c u r s= ’ ) disp (t , ” p e r i o d o f o s c i l l a t i o n , t=” ) ts =4/( zeta * Wn ) // s e t t l i n g t i m e disp ( ts , ” s e t t l i n g time , t s=” ) N = Wd /(2* %pi ) * ts // no . o f o s c i l l a t i o n s c o m p l e t e d before reaching steady state disp (N , ” no . o f o s c i l l a t i o n s c o m p l e t e d b e f o r e r e a c h i n g s t e a d y s t a t e , N=” )
Scilab code Exa 6.10.6 Time Response 1 2 3 4 5 6 7 8
// C a p t i o n : t i m e r e s p o n s e // e x a m p l e 6 . 1 0 . 6 // p a g e 174 // Kt=t o r q u e c o n s t a n t , J=moment o f i n e r t i a , f= c o e f f . o f viscous friction clc ; syms Kt J f t s = %s ; Kt =360 , J =10 , f =60 60
9 10 11 12 13
14 15 16 17 18 19 20 21 22 23 24 25 26 27
28 29
b =1/( J * s ^2+ f * s ) ; G =( Kt * b ) // i n s e r i e s H =1; // backward p a t h t r a n s f e r f u n c t i o n cl = G /. H ; // c l o s e d l o o p t r a n s f e r f u n c t i o n d = denom ( cl ) /10; // t a k i n g 10 common from n u m e r a t o r and denominator f o r s i m p l y f y i n g closed loop transfer function f = numer ( cl ) /10; CL = f / d ; // closed loop transfer function after simplifying printf ( ” o v e r a l l t r a n s f e r f u n c t i o n= \n ” ) ; disp ( CL , ”C( s ) /R( s )=” ) ; // g i v e n R( s ) =( 50 ∗ ( %pi / 1 8 0 ) ) ∗ ( 1 / s ) ; R =(50*( %pi /180) ) *(1/ s ) ; C = R * CL ; e = coeff ( d ) //Wnˆ2= e ( 1 , 1 ) Wn = sqrt ( e (1 ,1) ) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=c ( 1 , 2 ) zeta = e (1 ,2) /(2* Wn ) // damping r a t i o // c ( t ) : t i m e r e s p o n s e e x p r e s s i o n c =(5* %pi /18) *(1 -( exp ( - zeta * Wn * t ) * sin ( Wn * sqrt (1 - zeta ^2) * t + atan ( sqrt (1 - zeta ^2) / zeta ) ) ) / sqrt (1 - zeta ^2) ) ; c = float ( c ) disp (c , ” c ( t )=” )
Scilab code Exa 6.10.7 determine factor by which K should be reduced 1 2 3 4 5
// c a p t i o n : determine factor by which K should be reduced // e x a m p l e 6 . 1 0 . 7 // p a g e 175 syms T K //K=f o r w a r d p a t h g a i n , T=t i m e c o n s t a n t s = %s ; 61
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
G = K /( s *( s * T +1) ) ; G = simple ( G ) ; printf ( ” t h e f o r w a r d p a t h t r a n s f e r f u n c t i o n : \n ” ) ; disp (G , ”G( s )=” ) ; H =1; // backward p a t h t r a n s f e r f u n c t i o n CL = G /. H ; CL = simple ( CL ) ; printf ( ” t h e o v e r l a l l t r a n s f e r f u n c t i o n : \n ” ) ; disp ( CL , ”C( s ) /R( s )=” ) ; printf ( ” t h e c h a r a c t e r s t i c e q u a t i o n i s : \ n ” ) ; disp ( ” s ˆ2+ s /T+K/T=0” ) ; // from c h a r . eq . we g e t Wnˆ2=K/T and 2∗ z e t a ∗Wn=1/T , so Wn = sqrt ( K / T ) ; // n a t u r a l f r e q u e n c y zeta =(1/2) * sqrt (1/ K * T ) // l e t K1 be f o r w a r d p a t h g a i n when Mp1=60% and z e t a 1 be c o r r e s p o n d i n g damping f a c t o r syms K1 K2 zeta1 zeta2 Mp1 =( exp ( -( zeta1 * %pi ) / sqrt (1 - zeta1 ^2) ) ) *100 //max . overshoot // on s o l v i n g we g e t : zeta1 =0.158 // s i m i l a r l y l e t K2 be f o r w a r d p a t h g a i n when Mp2=20% and z e t a 2 be c o r r e s p o n d i n g damping f a c t o r , which gives zeta2 =0.447 // a s s u m i n g t i m e c o n s t . T t o be c o n s t . we g e t k =( K1 / K2 ) ; k =( zeta1 / zeta2 ) ^2; disp (k , ”K1/K2=” ) ;
Scilab code Exa 6.10.8 Determine Steady State Speed and Error 1 2
// c a p t i o n : d e t e r m i n e s t e a d y s t a t e s p e e d a n d e r r o r // e x a m p l e 6 . 1 0 . 8 62
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
// p a g e 176 //Tm=t o r q u e c o n s t a n t , J=moment o f i n e r t i a , f= c o e f f . o f v i s c o u s f r i c t i o n , E=e r r o r d e t e c t o r g a i n syms Tm J f t E s Tm =75; J =10; f =5; E =1; a =( Tm * E ) ; b =1/( J * s + f ) ; c =( a * b ) ; H =1; // backward p a t h t r a n s f e r f u n c t i o n CL = c /. H ; printf ( ” t h e o v e r l a l l t r a n s f e r f u n c t i o n : \n ” ) ; disp ( CL , ”Wo( s ) /Wr( s )=” ) ; // s i n c e Wr( s ) =(2∗ %pi ) ∗ ( 1 / s ) q = bfloat ((2* %pi ) ,2) Wr = q *(1/ s ) Wo = CL * Wr ; wo = ilaplace ( Wo ,s , t ) printf ( ” e x p r e s s i o n r e l a t i n g l o a d s p e e d a n d t i m e : \ n ” ) ; disp ( wo , ”wo ( t )=” ) ; a = Wo * s Woss = limit (a ,s ,0) ; // s t e a d y s t a t e s p e e d Woss = dbl ( Woss ) ; disp ( Woss , ” s t e a d y s t a t e s p e e d=” ) ; We = Wr *(10* s +5) /(10* s +80) ; Wess = limit ( s * We ,s ,0) ; // s t e a d y s t a t e e r r o r Wess = dbl ( Wess ) ; disp ( Wess , ” s t e a d y s t a t e e r r o r=” ) ;
Scilab code Exa 6.10.9 determine J f K 1 2 3 4
// c a p t i o n : d e t e r m i n e J , f , K // e x a m p l e 6 . 1 0 . 9 // p a g e 178 // J=moment o f i n e r t i a , f=C , K=f o r w a r d p a t h g a i n ,Wn= 63
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
n a t u r a l f r e q u e n c y , z e t a=damping r a t i o syms J f K s zeta Wn CL =1/( J * s ^2+ f * s + K ) ; printf ( ” g i v e n : t r a n s f e r f u n c t i o n i s : \ n ” ) ; disp ( CL , ” t h e t a ( s ) /T( s )=” ) ; T =10*(1/ s ) ; theta = T * CL ; theta_ss = limit ( s * theta ,s ,0) // s t e a d y s t a t e v a l u e printf ( ” g i v e n : t h e t a s s =0.5\ n s o K= 1 0 / 0 . 5 ” ) ; theta_ss =0.5; K =10/ theta_ss ; disp (K , ” f o r w a r d p a t h g a i n , K=” ) ; Mp =0.06; //max . peak o v e r s h o o t ( g i v e n )−−−−−−−−(1) Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) //−−−−−−−−−(2) // from eq . ( 1 ) and ( 2 ) , we g e t zeta =0.66; tp = %pi /( Wn *( sqrt (1 - zeta ^2) ) ) ; //−−−−−−−(3) tp =1 // ( g i v e n ) Wn = %pi /( tp * sqrt (1 - zeta ^2) ) ; // a l s o Wn=s q r t (K/ J ) ; J = K / Wn ^2; // a l s o 2∗ z e t a ∗Wn=f / J f = J *2* zeta * Wn ; disp (J , ”moment o f i n e r t i a , J=” ) ; disp (f , ”moment o f i n e r t i a , f=” ) ;
Scilab code Exa 6.10.10 Determine Transfer Function Wn zeta // c a p t i o n : d e t e r m i n e t r a n s f e r f u n c t i o n ,Wn, z e t a // e x a m p l e 6 . 1 0 . 1 0 // p a g e 179 // J=moment o f i n e r t i a , f=C , Ke=e r r o r d e t e c t o r g a i n ,Wn= n a t u r a l f r e q u e n c y , z e t a=damping r a t i o ,Km=t o r q u e constant 5 syms J f s
1 2 3 4
64
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 34 35 36 37 38 39 40 41 42
Ke =5.73; Km =0.045; n = sym ( ’ N1/N2 ’ ) n = subs (n , ’ N1/N2 ’ ,1/10) ; J =0.25* float ( n ^2) ; // r e f e r r e d t o motor s i d e f =1* float ( n ^2) ; // r e f e r r e d t o motor s i d e // from t h e b l o c k d i a g r a m g i v e n i n f i g 6 . 1 0 . 6 on p a g e 179 , a =( Ke * Km ) b =1/( J * s ^2+ f * s ) c =( b * float ( a ) ) G =( n * c ) ; G = simple ( G ) H =1; d =(1+ G * H ) ; d = simple ( d ) ; CL = G / d ; CL = simple ( CL ) disp ( CL , ”C( s ) /R( s )=” ) ; e = poly ([328800 127516 31879] , ’ s ’ , ’ c o e f f ’ ) printf ( ” t h e c h a r a c t e r s t i c s eq . i s : \ n ” ) ; disp ( e ) ; f = coeff ( e ) Wn = sqrt (( f (1 ,1) / f (1 ,3) ) ) // n a t u r a l f r e q u e n c y zeta =(( f (1 ,2) / f (1 ,3) ) /(2* Wn ) ) // damping r a t i o // p a r t ( b ) syms Td g =1+ s * Td h =( g * G ) i =1+ h * H i = simple ( i ) ; CL2 =( h / i ) CL2 = simple ( CL2 ) ; disp ( CL2 , ”C( s ) /R( s )=” ) ; poly (0 , ’ s ’ ) ; l = s ^2+(10.32* Td +4) * s +10.32; printf ( ” on s i m p l y f y i n g t h e c h a r a c t e r s t i c s eq . i s : ” ) ; disp ( float ( l ) ) ; 65
43 Wn1 = sqrt (10.32) // n a t u r a l f r e q u e n c y 44 // 2∗ z e t a 1 ∗Wn1= 1 0 . 3 2 ∗Td+4 45 zeta1 =1; // a s damping i s c r i t i c a l 46 Td =(2* zeta1 * Wn1 -4) /10.32; 47 disp ( Td , ” t i m e c o n s t . o f a d v a n c e d p h a s e c i r c u i t , Td=” )
;
Scilab code Exa 6.10.11 Determine Characterstics eq and Steady State Error 1
// c a p t i o n : determine characterstics eq and steady state error
2 3 4
// e x a m p l e 6 . 1 0 . 1 1 // p a g e 181 // J=moment o f i n e r t i a , f=C , K= c o n t r o l l e r g a i n ,Wn= n a t u r a l f r e q u e n c y , z e t a=damping r a t i o syms f J K Kt s = %s ; A = sym ((1/( J * s ^2+ f * s ) ) ) ; J =250; K =8*10^4; B = eval ( A ) a =( K * B ) ; H1 = s * Kt ; b =(1+ a * H1 ) ; b = simple ( b ) ; CL1 = a / b ; CL1 = simple ( CL1 ) ; H =1; c =1+ CL1 * H ; c = simple ( c ) ; CL = CL1 / c CL = simple ( CL ) ; disp ( CL , ”C( s ) /R( s )=” ) ;
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
66
Wn = sqrt (80000/250) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=(80000∗ Kt+f ) / 2 5 0 zeta =1; // f o r c r i t i c a l damping d =2* zeta * Wn ; v =[320 d 1]; CH = poly (v , ’ s ’ , ’ c o e f f ’ ) ; r = float (5*2* %pi /60) ; // s t e a d y s t a t e e r r o r f o r u n i t ramp i n p u t i s : E s s= ( 2 ∗ z e t a /Wn) 31 Ess =(2* zeta / Wn ) * r ; 32 disp ( Ess , ” s t e a d y s t a t e e r r o r =” ) ;
23 24 25 26 27 28 29 30
Scilab code Exa 6.10.12 determine WnWd zeta and steady state error 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// c a p t i o n : determine Wn ,Wd, zeta and steady state error // e x a m p l e 6 . 1 0 . 1 2 // p a g e 182 clc ; s = %s ; G = sym ( ’ 2 5 / ( s ∗ ( s +5) ) ’ ) ; G = simple ( G ) ; H =1; CL = G /. H ; CL = simple ( CL ) ; disp ( CL , ”C( s ) /R( s )=” ) ; printf ( ” t h e c h a r . eq i s : ” ) disp ( ” s ˆ2+5∗ s +25” ) Wn = sqrt (25) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=5 zeta =5/(2* Wn ) ; // damping r a t i o d = zeta * Wn ; // d a m p i n g f a c t o r z = sqrt (1 - zeta ^2) ; Wd = Wn * z ; // d a m p e d f r e q u e n c y o f o s c i l l a t i o n Mp = exp (( - zeta * %pi ) / z ) *100; // % max . p e a k o v e r s h o o t 67
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
// s t e a d y s t a t e e r r o r f o r u n i t ramp i n p u t i s : E s s= ( 2 ∗ z e t a /Wn) Ess =(2* zeta / Wn ) ; // s t e a d y s t a t e e r r o r disp ( ” p a r t ( a ) : ” ) disp ( Wn , ” n a t u r a l f r e q u e n c y ,Wn=” ) ; disp ( zeta , ” damping r a t i o , z e t a=” ) ; disp ( Wd , ” d a m p e d f r e q u e n c y o f o s c i l l a t i o n ,Wd=” ) ; disp ( Mp , ”% max . p e a k o v e r s h o o t , Mp=” ) ; disp ( Ess , ” s t e a d y s t a t e e r r o r , E s s=” ) ; // i f damping r a t i o i s i n c r e a s e d from 0 . 5 t o 0 . 7 5 by i n c o r p o r a t i n g tachometer feedback zeta =0.75; H1 = sym ( ’ s ∗Kt ’ ) // t a c h o m e t e r f e e d b a c k CL1 = G /(1+ G * H1 ) ; CL1 = simple ( CL1 ) ; CL2 = CL1 /(1+ H * CL1 ) ; CL2 = simple ( CL2 ) ; disp ( CL2 , ”C( s ) /R( s )=” ) ; Wn = sqrt (25) ; // 2∗ z e t a ∗Wn=25∗Kt +5; Kt =(2* zeta * Wn -5) /25; // t a c h o m e t e r g a i n Mp1 = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; // % peak overshoot disp ( ” A f t e r a p p l y i n g t a c h o m e t e r f e e d b a c k : ” ) disp ( Kt , ” t a c h o m e t e r g a i n , Kt=” ) ; disp ( Mp1 , ” % p e a k o v e r s h o o t , Mp1=” ) ;
Scilab code Exa 6.10.13 determine K ts tp and Mp 1 // c a p t i o n : d e t e r m i n e K , t s , tp , Mp 2 // e x a m p l e 6 . 1 0 . 1 3 3 // p a g e 184 4 clc ; 5 syms K ; 6 s = %s ;
68
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
G = sym ( ’K/ ( s ∗ ( s +6) ) ’ ) ; H =0.2; CL = G /(1+ G * H ) ; CL = simple ( CL ) ; Wn = sqrt ( K /5) zeta =0.7 // ( g i v e n ) damping r a t i o // 2∗ z e t a ∗Wn=6 Wn =6/(2* zeta ) ; K = Wn ^2*5; ts =4/( zeta * Wn ) ; // s e t t l i n g t i m e Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; // % peak overshoot tp = %pi /( Wn * sqrt (1 - zeta ^2) ) ; // p e a k t i m e disp ( Wn , ” n a t u r a l f r e q u e n c y ,Wn=” ) ; disp ( Mp , ”% max . p e a k o v e r s h o o t , Mp=” ) ; disp ( ts , ” s e t t l i n g t i m e , t s=” ) ; disp ( tp , ” p e a k t i m e , t p=” ) ;
Scilab code Exa 6.10.14 determine Mp Ess and steady state value 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// c a p t i o n : determine Mp , E s s a n d s t e a d y s t a t e v a l u e // e x a m p l e 6 . 1 0 . 1 4 // p a g e 185 // t h e r e a r e two i n p u t s : R( s ) i s r e f e r e n c e i n p u t and Tl ( s ) i s l o a d t o r q u e clc ; s = %s ; A = sym ( ’ 1 / ( 0 . 1 5 ∗ s ˆ 2 + 0 . 9 ∗ s ) ’ ) ; K =6; // w h i l e c o n s i d e r i n g R( s ) , we t a k e Tl ( s ) =0 G =( A * K ) ; // i n s e r i e s H =1; CL = G /(1+ G * H ) ; CL = simple ( CL ) ; disp ( CL , ”C( s ) /R( s )=” ) ; 69
15 Wn = sqrt (40) ; // n a t u r a l f r e q u e n c y 16 // 2∗ z e t a ∗Wn=6 17 zeta =6/(2* Wn ) ; // damping r a t i o 18 Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; // 19 20 21 22 23 24 25 26 27 28 29 30 31
% peak overshoot // s t e a d y s t a t e e r r o r f o r u n i t ramp i n p u t i s : E s s= ( 2 ∗ z e t a /Wn) Ess =(2* zeta / Wn ) ; // s t e a d y s t a t e e r r o r disp ( Mp , ” % p e a k o v e r s h o o t=” ) ; disp ( Ess , ” s t e a d y s t a t e e r r o r=” ) ; printf ( ”Now c o n s i d e r i n g e f f e c t o f Tl ( s ) , put R( s ) =0\n ”); H =6; CL1 = A /(1+ A * H ) ; CL1 = simple ( CL1 ) ; disp ( CL1 , ”C( s ) /−Tl ( s )=” ) ; //−ve s i g n i n d i c a t e s o u t p u t p o s i t i o n l a g s behind the input Tl =1/ s ; // g i v e n C = - Tl * CL1 ; Css = limit ( s *C ,s ,0) ; disp ( Css , ” s t e a d y s t a t e v a l u e o f o u t p u t=” ) ;
Scilab code Exa 6.10.16 determine Wn zeta and M 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : determine Wn , z e t a a n d M p // e x a m p l e 6 . 1 0 . 1 6 // p a g e 187 s = %s ; num =1; den = sym ( ’ s ∗ ( 1 + 0 . 5 ∗ s ) ∗ ( 1 + 0 . 2 ∗ s ) ’ ) ; c = num / den ; c = simple ( c ) ; disp (c , ”C( s ) /E( s )=” ) ; G=c; H =1; 70
12 13 14 15 16 17 18 19 20 21 22
CL = G /(1+ G * H ) ; CL = simple ( CL ) ; disp ( CL , ”C( s ) /R( s )=” ) ; A = pfss ((10/( s ^3+7* s ^2+10* s +10) ) ) ; d = denom ( A (1) ) ; b = coeff ( denom ( A (1) ) ) printf ( ” f o r o s c i l l a t o r y r o o t s : ” ) Wn = sqrt ( b (1 ,1) ) ; // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn= 1 . 5 ; zeta =1.5/(2* Wn ) ; // damping r a t i o Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; // % peak overshoot 23 disp ( Wn , ” n a t u r a l f r e q u e n c y=” ) ; 24 disp ( zeta , ” damping r a t i o =” ) ; 25 disp ( Mp , ” % p e a k o v e r s h o o t=” ) ;
Scilab code Exa 6.10.17 determine Kp Kv and Ka 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// c a p t i o n : d e t e r m i n e K p K v K a // e x a m p l e 6 . 1 0 . 1 7 // p a g e 188 s = %s ; syms t ; num = sym ( ’ 2 ∗ ( s ˆ2+3∗ s +20) ’ ) ; den = sym ( ’ s ∗ ( s +2) ∗ ( s ˆ2+4∗ s +10) ’ ) ; GH = num / den ; GH = simple ( GH ) ; disp ( GH , ”G( s )H( s )=” ) ; input1 =5; Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r coefficient Ess =5*(1/(1+ Kp ) ) ; // s t e a d y s t a t e e r r o r e =(1/( %inf +1) ) ; e =0; Ess = e ; 71
17 disp ( Kp , ” s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t =” ) ; 18 disp ( Ess , ” s t e a d y s t a t e e r r o r=” ) ; 19 input2 =4* t ; 20 Kv = limit ( s * GH ,s ,0) ; // s t a t i c v e l o c i t y e r r o r 21 22 23 24 25 26 27 28 29
coefficient Ess =(1/ Kv ) *4; // s t e a d y s t a t e e r r o r disp ( Kv , ” s t a t i c 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 ( Ess , ” s t e a d y s t a t e e r r o r=” ) ; input3 =(4* t ^2) /2; Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r coefficient Ess =(1/ Ka ) *4; // s t e a d y s t a t e e r r o r disp ( Ka , ” s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t =” ) ; disp ( ” s t e a d y s t a t e e r r o r=” ) ; disp ( ” i n f i n i t y ” )
Scilab code Exa 6.10.18 determine Kp Kv and Ka 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// c a p t i o n : d e t e r m i n e K p K v K a // e x a m p l e 6 . 1 0 . 1 7 // p a g e 188 s = %s ; syms t K zeta Wn ; num = K ; den = sym ( ’ s ∗ ( s ˆ2+2∗ z e t a ∗Wn∗ s+Wnˆ 2 ) ’ ) ; G = num / den ; G = simple ( G ) ; disp (G , ”G( s )=” ) ; Kp = limit (G ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r coefficient disp ( Kp , ” s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t , Kp=” ) ; Kv = limit ( s *G ,s ,0) ; // s t a t i c v e l o c i t y e r r o r coefficient disp ( Kv , ” s t a t i c 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=” ) ; Ka = limit ( s ^2* G ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r 72
16 17 18 19 20 21 22 23 24 25 26 27 28
coefficient disp ( Ka , ” s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t , Ka=” ) ; printf ( ” f o r ( i i ) : ” ) ; num = sym ( ’ 1 0 0 ∗ ( s +2) ∗ ( s +40) ’ ) ; den = sym ( ’ s ˆ 3 ∗ ( s ˆ2+4∗ s +200) ’ ) ; GH = num / den ; GH = simple ( GH ) ; disp ( GH , ”G( s )H( s )=” ) ; Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r coefficient disp ( Kp , ” s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t , Kp=” ) ; Kv = limit ( s * GH ,s ,0) ; // s t a t i c v e l o c i t y e r r o r coefficient disp ( Kv , ” s t a t i c 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=” ) ; Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r coefficient disp ( Ka , ” s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t , Ka=” ) ;
Scilab code Exa 6.10.19 determine steady state error 1 2 3 4 5 6 7 8 9 10 11 12 13
// c a p t i o n : d e t e r m i n e s t e a d y s t a t e e r r o r // e x a m p l e 6 . 1 0 . 1 9 // p a g e 189 s = %s ; syms K bta alpha G num = sym ( ’K∗ s+b t a ’ ) ; den = sym ( ’ s ˆ2+ a l p h a ∗ s+b t a ’ ) ; CL = num / den ; disp ( CL , ”C( s ) /R( s )=” ) ; //−−−−(1) H =1; // a l s o cl = G /(1+ G * H ) ; disp ( cl , ” a l s o , C( s ) /R( s )=” ) ; //−−−−−−(2) 73
14 15 16 17 18 19 20 21 22 23 24
// from eq . ( 1 ) and ( 2 ) , we g e t G = num /( s ^2+ s *( alpha - K ) ) ; disp (G , ”G( s )=” ) ; B =1/(1+ G ) ; B = simple ( B ) ; disp (B , ”E( s ) /R( s )=” ) ; R =1/ s ^2; E=B*R; E = simple ( E ) ; Ess = limit ( s *E ,s ,0) ; disp ( Ess , ” s t e a d y s t a t e e r r o r=” ) ;
Scilab code Exa 6.10.20 determine steady state error and error coefficient 1
// c a p t i o n : determine steady state error and error coefficient
2 // e x a m p l e 6 . 1 0 . 2 0 3 // p a g e 189 4 s = %s ; 5 syms t a0 a1 a2 ; 6 r = a0 + a1 * t +( a2 /2) * t ^2; 7 // s i n c e f o r ’ r ’ o n l y u p t o 2 nd o r d e r 8 9 10 11 12 13 14 15 16 17 18
derivative is non z e r o , s o o n l y c o e f f . C0 C1 C2 e x i s t num =20; den = sym ( ’ ( s ∗ ( s +2) ) ’ ) ; G = num / den ; disp (G , ”G( s )=” ) ; A =1/(1+ G ) ; A = simple ( A ) ; disp (A , ”E( s ) /R( s )=” ) ; C0 = limit (A ,s ,0) ; B = sym ( ’ ( ( 2 0 ) / ( s ˆ2+2∗ s +20) ) ’ ) ; // on s i m p l y f y i n g A=1−B d = diff ( -B , s ) ; C1 = limit (d ,s ,0) ; 74
19 20 21 22 23 24 25 26 27
d1 = diff ( -B ,s ,2) ; C2 = limit ( d1 ,s ,0) ; r1 = diff (r , t ) ; r2 = diff (r ,t ,2) ; e =( C0 * r ) +( C1 * r1 ) +( C2 * r2 ) /2; disp ( C0 , ”C0=” ) ; disp ( float ( C1 ) ,”C1=” ) ; disp ( float ( C2 ) ,”C2=” ) ; disp ( float ( e ) ,” s t e a d y s t a t e e r r o r , e=” ) ;
Scilab code Exa 6.10.21 determine steady state error and error coefficient 1
// c a p t i o n : determine steady state error and error coefficient
2 // e x a m p l e 6 . 1 0 . 2 1 3 // p a g e 191 4 s = %s ; 5 syms t ; 6 r =2+3* t +2* t ^3; 7 // s i n c e f o r ’ r ’ o n l y u p t o 2 nd o r d e r 8 9 10 11 12 13 14 15 16 17 18 19 20
derivative is non z e r o , s o o n l y c o e f f . C0 C1 C2 e x i s t G = sym ( ’ 1 / ( s ∗ ( s +2) ) ’ ) ; A =1/(1+ G ) ; A = simple ( A ) ; disp (A , ”E( s ) /R( s )=” ) ; C0 = limit (A ,s ,0) ; B = sym ( ’ ( ( 1 ) / ( s ˆ2+2∗ s +1) ) ’ ) ; // on s i m p l y f y i n g A=1−B d = diff ( -B , s ) ; C1 = limit (d ,s ,0) ; d1 = diff ( -B ,s ,2) ; C2 = limit ( d1 ,s ,0) ; r1 = diff (r , t ) ; r2 = diff (r ,t ,2) ; d2 = diff ( -B ,s ,3) 75
21 C3 = limit ( d2 ,s ,0) 22 e =( C0 * r ) +( C1 * r1 ) +( C2 * r2 ) /2; 23 disp ( float ( e ) ,” s t e a d y s t a t e e r r o r , e=” ) ; 24 disp ( C0 , ”C0=” ) ; 25 disp ( float ( C1 ) ,”C1=” ) ; 26 disp ( float ( C2 ) ,”C2=” ) ; 27 disp ( float ( C3 ) ,”C3=” )
Scilab code Exa 6.10.22 determine voltage Er and change in terminalvoltage 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// c a p t i o n : d e t e r m i n e r e f e r e n c e v o l t a g e , Er and %change in terminal voltage // e x a m p l e 6 . 1 0 . 2 2 // p a g e 191 clc ; syms G H s = %s ; A = G /. H ; disp (A , ”E0/ Er=” ) ; G =200; // g a i n H =0.1; B = eval ( A ) ; disp (B , ”E0/ Er=” ) ; E0 =250; Er =(1/ B ) * E0 ; disp ( ” f o r c l o s e d l o o p s y s t e m : ” ) ; disp ( float ( Er ) ,” r e f e r e n c e v o l t a g e , Er=” ) ; disp ( ” f o r o p e n l o o p s y s t e m : ” ) ; disp ( float ( E0 / G ) ,” Er=E0/G=” ) ; disp ( ” p a r t ( b ) ” ) disp ( ” f o r c l o s e d l o o p s y s t e m : ” ) disp ( ” a s t h e f o r w a r d p a t h g a i n i s r e d u c e d by 10%, t h e new v a l u e o f g a i n ,G i s 180 ” ) 76
G =180 // g a i n pcG =10 // p e r c e n t a g e c h a n g e i n G S =1/(1+ G * H ) disp (S , ” s e n s i t i v i t y , S=” ) ; disp ( ” s i n c e S =1/19 , ( given ) ”) pcM = S * pcG // p e r c e n t a g e c h a n g e i n o v e r a l l g a i n ,M pcEo = pcM disp ( pcM , ” p e r c e n t a g e c h a n g e i n o v e r a l l g a i n ,M=” ) disp ( pcEo , ” p e r c e n t a g e c h a n g e i n t e r m i n a l v o l t a g e , Eo= ”) 32 disp ( ” f o r open l o o p s y s t e m : ” ) 33 pcEo =(25/250) *100 34 disp ( pcEo , ” p e r c e n t a g e c h a n g e i n t e r m i n a l v o l t a g e , Eo= ”) 23 24 25 26 27 28 29 30 31
Scilab code Exa 6.10.23 determine sensitivity wrt K and H 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// c a p t i o n : d e t e r m i n e s e n s i t i v i t y w . r . t K a n d H // e x a m p l e 6 . 1 0 . 2 3 // p a g e 192 syms Wn zeta K H ; s = %s ; A = sym ( ’Wnˆ 2 / ( s ˆ2+2∗ z e t a ∗Wn∗ s ) ’ ) ; B =( A * K ) ; CL = B /(1+ B * H ) ; CL = simple ( CL ) ; disp ( CL , ” o v e r a l l t r a n s f e r f u n c t i o n :M( s )=” ) ; disp ( ” s e n s i t i v i t y w . r . t K : ” ) ; a = diff ( CL , K ) ; b = K / CL ; b = simple ( b ) ; Sk = a * b ; Sk = simple ( Sk ) ; disp ( Sk , ” s e n s i t i v i t y w . r . t K , Sk=” ) ; disp ( ” s e n s i t i v i t y w . r . t H : ” ) ; 77
19 20 21 22 23 24
c = diff ( CL , H ) ; d = H / CL ; d = simple ( d ) ; Sh = c * d ; Sh = simple ( Sh ) ; disp ( Sh , ” s e n s i t i v i t y w . r . t H , Sh=” ) ;
78
Chapter 7 STABILITY ANALYSIS OF CONTROL SYSTEMS
Scilab code Exa 1.0 root locus 1 // c a p t i o n : r o o t l o c u s 2 // e x a m p l e 1 3 // p a g e 291 4 s = %s ; 5 g = s /( s +1) ; 6 G = syslin ( ’ c ’ ,g ) 7 evans (g ,200)
Scilab code Exa 2.0 root locus 1 2
// c a p t i o n : r o o t l o c u s // e x a m p l e 2 79
Figure 7.1: root locus
80
Figure 7.2: root locus
81
Figure 7.3: root locus 3 // p a g e 291 4 s = %s ; 5 g =1/( s *( s +4) ) ; 6 G = syslin ( ’ c ’ ,g ) 7 evans (g ,200)
Scilab code Exa 3.0 root locus 1 2 3
// c a p t i o n : r o o t l o c u s // e x a m p l e 3 // p a g e 292 82
4 s = %s ; 5 g =1/( s *( s +1) *( s +3) ) ; 6 G = syslin ( ’ c ’ ,g ) 7 evans (g ,200)
Scilab code Exa 7.5.1 stability using Routh hurwitz criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 7 . 5 . 1 // p a g e 202 clc ; s = %s ; A = s ^3+4.5* s ^2+3.5* s +1.5; b = coeff ( A ) n = length ( b ) B = routh_t ( A ) disp (B , ” r o u t h t a b l e : ” ) ; c =0; for ( i =1: n ) if ( B (i ,1) <0) c = c +1; end end if (c >=1) disp ( ” s y s t e m i s u n s t a b l e ” ) else ( ” s y s t e m i s s t a b l e ” ) end
Scilab code Exa 7.5.2 stability using Routh hurwitz criterion 1 2 3
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 7 . 5 . 2 // p a g e 202 83
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
s = %s ; A = s ^3+4*10^2* s ^2+5*10^4* s +2*10^6; b = coeff ( A ) n = length ( b ) B = routh_t ( A ) disp (B , ” r o u t h t a b l e : ” ) ; c =0; for ( i =1: n ) if ( B (i ,1) <0) c = c +1; end end if (c >=1) printf ( ” \n s y s t e m i s u n s t a b l e ” ) else ( ” s y s t e m i s s t a b l e ” ) end
Scilab code Exa 7.5.3 stability using Routh hurwitz criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 7 . 5 . 3 // p a g e 203 s = %s ; A = s ^5+4*1.5* s ^4+4* s ^3+4* s ^2+5* s +10; C =2* s +5; CL = A / C ; disp ( CL , ”C( s ) /R( s )=” ) ; disp ( ’ =0 ’ ,A , ” c h a r a c t e r i s t i c s eq i s : ” ) b = coeff ( A ) n = length ( b ) B = routh_t ( A ) disp (B , ” r o u t h t a b l e : ” ) ; c =0; r =1; for ( i =1: n ) 84
17 if ( B (i ,1) <0) 18 c = c +1; 19 if ( i == n & B (n ,1) <0) 20 r=r; 21 else 22 r = r +1; 23 end 24 end 25 end 26 if (c >=1) 27 printf ( ” s y s t e m i s u n s t a b l e \n ” ) ; 28 else ( ” s y s t e m i s s t a b l e ” ) ; 29 end 30 mprintf ( ’ no . o f r o o t s w i t h p o s i t i v e
r e a l p a r t s=%d ’ ,r
);
Scilab code Exa 7.5.4 stability using Routh hurwitz criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 7 . 5 . 4 // p a g e 203 ieee (2) s = %s ; A = s ^5+ s ^4+2* s ^3+2* s ^2+11* s +10; b = coeff ( A ) ; n = length ( b ) ; B = routh_t ( A ) ; K=B; c =0; syms eps ; x = limit ( eps , eps ,0) ; y = limit ((( -1+2* eps ) / eps ) ,eps ,0) ; z = limit ((( -1+2* eps -10* eps ^2) /( -1+2* eps ) ) ,eps ,0) ; // a f t e r p u t t i n g t h e l i m i t we g e t : K (3 ,1) =0; 85
18 K (4 ,1) = - %inf ; 19 K (5 ,1) =1; 20 disp (K , ” r o u t h t a b l e : ” ) 21 printf ( ” There a r e two s i g n c h a n g e s o f
f i r s t column ,
h e n c e t h e s y s t e m i s u n s t a b l e \n ” )
Scilab code Exa 7.5.5 stability using Routh hurwitz criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 7 . 5 . 5 // p a g e 204 s = %s ; A = s ^6+ s ^5+5* s ^4+3* s ^3+2* s ^2 -4* s -8; b = coeff ( A ) n = length ( b ) routh =[ b ([7 ,5 ,3 ,1]) ; b ([6 ,4 ,2]) ,0]; c =[ routh (1 ,1) , routh (1 ,3) ; routh (2 ,1) , routh (2 ,3) ] d =[ routh (1 ,1) , routh (1 ,4) ; routh (2 ,1) , routh (2 ,4) ] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) ,- det ( c ) / routh (2 ,1) ,- det ( d ) / routh (2 ,1) ,0]; routh1 = routh ; e =[ routh (2 ,1) , routh (2 ,2) ; routh (3 ,1) , routh (3 ,2) ] f =[ routh (2 ,1) , routh (2 ,3) ; routh (3 ,1) , routh (3 ,3) ] routh =[ routh ; - det ( e ) / routh (3 ,1) ,- det ( f ) / routh (3 ,1) ,0 ,0]; disp ( ” s i n c e a l l e l e m e n t s o f f o u r t h row a r e z e r o , s o we make a u x i l i a r y e q u a t i o n ” ) A = sym ( ’ 2∗ s ˆ4+6∗ s ˆ2−8 ’ ) B = diff (A , s ) routh =[ routh1 ;8 ,12 ,0 ,0] g =[ routh (3 ,1) , routh (3 ,3) ; routh (4 ,1) , routh (4 ,3) ] routh =[ routh ; - det ( routh (3:4 ,1:2) ) / routh (4 ,1) ,- det ( g ) / routh (4 ,1) ,0 ,0]; routh =[ routh ; - det ( routh (4:5 ,1:2) ) / routh (5 ,1) ,0 ,0 ,0]; 86
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
routh =[ routh ; - det ( routh (5:6 ,1:2) ) / routh (6 ,1) ,0 ,0 ,0] disp ( routh , ” r o u t h t a b l e : ” ) c =0; r =1; for ( i =1: n ) if ( routh (i ,1) <0) c = c +1; if ( i == n & routh (n ,1) <0) r=r; else r = r +1; end end end if (c >=1) printf ( ” s y s t e m i s u n s t a b l e \n ” ) else ( ” s y s t e m i s s t a b l e ” ) end mprintf ( ’ no . o f r o o t s w i t h p o s i t i v e r e a l p a r t s=%d ’ ,r );
Scilab code Exa 7.5.6 stability using Routh hurwitz criterion 1 2 3 4 5 6 7 8 9 10 11 12
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 7 . 5 . 6 // p a g e 206 s = %s ; syms T num = exp ( - s * T ) ; den = s *( s +2) ; G = num / den ; H =1; a =(1+ G * H ) ; CL = G / a ; CL = simple ( CL ) ; 87
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
CH = s ^2+2* s + exp ( - s * T ) ; // exp (− s ∗T)=1−sT+(sT ) ˆ 2 / 2 + . . . . CH = s ^2+(2 - T ) * s +1; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; b =[ c0 c1 c2 ] n =3; routh =[ b ([3 ,1]) ; b ([2]) ,0]; routh =[ routh ; simple ( - det ( routh ) / routh (2 ,1) ) ,0] disp ( routh , ” r o u t h=” ) ; disp ( ” f o r g i v e n s y s t e m t o be s t a b l e : ” ) ; disp ( ”2−T>0” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”T<2” ) ;
Scilab code Exa 7.5.7.a stability using Routh hurwitz criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 7 . 5 . 7 . ( a ) // p a g e 207 s = %s ; syms T K P = s *( s *( s +10) + T ) ; CH = sym ( ’ s ˆ3+10∗ s ˆ2+T∗ s+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] 88
17 t = routh (2:3 ,1:2) 18 routh =[ routh ; - det ( t ) / t (2 ,1) ,0] 19 disp ( routh , ” r o u t h=” ) 20 disp ( ” f o r g i v e n s y s t e m t o be s t a b l e : ” ) ; 21 disp ( ” ( ( 1 0 ∗ T−K) / 1 0 ) >0 and K>0” ) ; 22 disp ( ” which g i v e s : ” ) ; 23 disp ( ”0
Scilab code Exa 7.5.7.b value of K of characterstics equation 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
// c a p t i o n : v a l u e o f K o f c h a r a c t e r s t i c s e q // e x a m p l e 7 . 5 . 7 . ( b ) // p a g e 207 s = %s ; syms K s1 ; CH = s ^3+10* s ^2+18* s + K s = s1 -1; CH = eval ( CH ) ; CH = simple ( CH ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) ; c0 = coeffs ( CH , ’ s 1 ’ ,0) ; c1 = coeffs ( CH , ’ s 1 ’ ,1) ; c2 = coeffs ( CH , ’ s 1 ’ ,2) ; c3 = coeffs ( CH , ’ s 1 ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be s t a b l e : ” ) ; disp ( ” (( −(K−16) ) / 7 ) >0 and K−9>0” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”9
Scilab code Exa 7.5.8 value of K in terms of T1 and T2 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
// c a p t i o n : v a l u e o f K i n t e r m s o f T 1 a n d T 2 // e x a m p l e 7 . 5 . 8 // p a g e 207 s = %s ; syms K T1 T2 ; m = s *( s * T1 +1) *( s * T2 +1) G=K/m; CH =1+ G ; disp ( ” on s i m p l y f y i n g CH” ) CH = m + K ; CH = simple ( CH ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) ; c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be s t a b l e : ” ) ; disp ( ”K>0 and ( −(K∗T1∗T2−T2−T1 ) / ( T2+T1 ) ) >0” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”0
90
Figure 7.4: stability using Nyquist criterion
91
Scilab code Exa 7.17.1 stability using Nyquist criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 7 . 1 7 . 1 // p a g e 236 clf ; s = %s ; s1 = - s ; g =50/(( s +1) *( s +2) ) ; g1 =50/(( s1 +1) *( s1 +2) ) ; GH = syslin ( ’ c ’ ,g ) GH1 = syslin ( ’ c ’ , g1 ) nyquist ( GH ) ; nyquist ( GH1 ) ; mtlb_axis ([ -5 30 -20 20]) ; xtitle ( ’ N y q u i s t p l o t o f 5 0 / ( ( s +1) ∗ ( s +2) ) ’ ) figure ; show_margins ( GH , ’ n y q u i s t ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s n o t e n c i r c l e d by N y q u i s t p l o t , s o N=0 and P=0( g i v e n ) ” ) N =0; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) p l o t P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s s t a b l e . ”)
Scilab code Exa 7.17.2.i stability using Nyquist criterion 92
Figure 7.5: stability using Nyquist criterion
93
Figure 7.6: stability using Nyquist criterion
94
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
19 20 21 22 23
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 7 . 1 7 . 2 // p a g e 237 clf () ; s = %s ; s1 = - s ; disp ( ” f o r K=1.25 ” ) g =(1.25*( s +1) ) /(( s +0.5) *( s -2) ) ; g1 =(1.25*( s1 +1) ) /(( s1 +0.5) *( s1 -2) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; mtlb_axis ([ -1.5 0.2 -0.3 0.3]) ; xtitle ( ’ N y q u i s t p l o t o f ( 1 0 ∗ ( s −1) ) / ( ( s +2) ∗ ( s +3) ) ; ’ ) figure ; show_margins ( GH , ’ n y q u i s t ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s encircled c l o c k w i s e by N y q u i s t p l o t , s o N=−1 and P=1( g i v e n ) ”) N = -1; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) plot anticlockwise P =1; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=2 , t h e r e a r e two r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s u n s t a b l e . ”)
95
Figure 7.7: stability using Nyquist criterion
96
Figure 7.8: stability using Nyquist criterion
97
Scilab code Exa 7.17.2.ii stability using Nyquist criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 7 . 1 7 . 2 i i // p a g e 237 disp ( ” f o r K=2.5 ” ) g =(2.5*( s +1) ) /(( s +0.5) *( s -2) ) ; g1 =(2.5*( s1 +1) ) /(( s1 +0.5) *( s1 -2) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; mtlb_axis ([ -3 0.5 -0.6 0.6]) ; xtitle ( ’ N y q u i s t p l o t o f ( 2 . 5 ∗ ( s +1) ) / ( ( s + 0 . 5 ) ∗ ( s −2) ) ’ ) figure ; show_margins ( GH , ’ n y q u i s t ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s encircled a n t i c l o c k w i s e by N y q u i s t p l o t , s o N=1 and P=1( given ) ”) N =1; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) p l o t anticlockwise P =1; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s s t a b l e . ”)
98
Figure 7.9: stability using Nyquist criterion
99
Figure 7.10: stability using Nyquist criterion
100
Scilab code Exa 7.17.3 stability using Nyquist criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18 19 20 21 22
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 7 . 1 7 . 3 // p a g e 238 clf () ; s = %s ; s1 = - s ; g =( s +0.25) /( s ^2*( s +0.5) *( s +1) ) ; g1 =( s1 +0.25) /( s1 ^2*( s1 +0.5) *( s1 +1) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; mtlb_axis ([ -2000 500 -30 30]) ; xtitle ( ’ N y q u i s t p l o t o f ( s + 0 . 2 5 ) / ( s ˆ 2 ∗ ( s + 0 . 5 ) ∗ ( s +1) ) ’) figure ; show_margins ( GH , ’ n y q u i s t ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s encircled c l o c k w i s e by N y q u i s t p l o t , s o N=−1 and P=1( g i v e n ) ”) N = -1; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) plot anticlockwise P =1; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=2 , t h e r e a r e two r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s u n s t a b l e . ”)
101
Figure 7.11: stability using Nyquist criterion
102
Figure 7.12: Phase Margin
103
Scilab code Exa 7.17.5 Phase Margin // c a p t i o n : p h a s e m a r g i n // e x a m p l e 7 . 1 7 . 5 // p a g e 241 clf () ; s = %s ; s1 = - s ; disp ( ” f o r K=3” ) g =(2.5*3) /( s *(0.4* s +1) *(0.2* s +1) ) ; g1 =(2.5*3) /( s1 *(0.4* s1 +1) *(0.2* s1 +1) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; mtlb_axis ([ -5 1 -500 500]) ; xtitle ( ’ N y q u i s t p l o t o f ( 2 . 5 ∗ 3 ) / ( s ∗ ( 0 . 4 ∗ s +1) ∗ ( 0 . 2 ∗ s +1) ) ’ ) 16 pm = p_margin ( GH ) 17 disp ( pm , ” p h a s e m a r g i n=” )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Scilab code Exa 7.17.7 stability using Nyquist criterion 1 2 3 4 5 6 7
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 7 . 1 7 . 7 // p a g e 244 clf () ; s = %s ; s1 = - s ; g =(2.2/( s *( s +1) *( s ^2+2* s +2) ) ) 104
Figure 7.13: stability using Nyquist criterion
105
8 g1 =(2.2/( s1 *( s1 +1) *( s1 ^2+2* s1 +2) ) ) 9 GH = syslin ( ’ c ’ ,g ) ; 10 GH1 = syslin ( ’ c ’ , g1 ) ; 11 nyquist ( GH ) ; 12 nyquist ( GH1 ) ; 13 mtlb_axis ([ -2.5 0.2 -75 75]) ; 14 disp ( ” a s t h e n y q u i s t p l o t p a s s e s t h r o u g h t h e p o i n t
−1+%i ∗ 0 , s o s y s t e m i s m a r g i n a l l y s t a b l e and output r e p r e s e n t s s u s t a i n e d o s c i l l a t i o n s . ”)
Scilab code Exa 7.17.9 gain margin and phase margin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// c a p t i o n : g a i n m a r g i n a n d p h a s e m a r g i n // e x a m p l e 7 . 1 7 . 9 // p a g e 245 s = %s ; syms w ; s1 = - s ; gh =(32/( s *( s + sqrt (6) ) ^3) ) ; g = sym ((32/( s *( s + sqrt (6) ) ^3) ) ) ; s = %i * w ; a = eval ( g ) ; w = sqrt (2) ; b = float ( eval ( abs ( a ) ) ) ; disp (b , ” a t w=s q r t ( 2 ) , |G( jw )H( jw ) |= ” ) ; GH = syslin ( ’ c ’ , gh ) ; gm = g_margin ( GH ) ; pm = p_margin ( GH ) ; disp ( gm , ” Gain m a r g i n=” ) ; disp ( pm , ” Phase m a r g i n=” ) ; disp ( ” s i n c e gm=0 and pm=0 , s o s y s t e m i s m a r g i n a l l y s t a b l e ”)
106
Figure 7.14: gain phase plot
107
Scilab code Exa 7.17.18 gain phase plot 1 // c a p t i o n : g a i n p h a s e p l o t 2 // e x a m p l e 7 . 1 7 . 1 8 3 // p a g e 256 4 k =1; 5 s = %s ; 6 G = syslin ( ’ c ’ ,k /( s *(0.5* s +1) *(0.25* s +1) ) ) ; 7 // f r e q r a n g e t o p l o t 8 fmin =0.1; 9 fmax =7; 10 black (G , fmin , fmax ) 11 xgrid 12 xtitle ( ’ Gain p h a s e p l o t ’ ) 13 disp ( ” f o r GM=8 db , K=2.23 ” ) 14 disp ( ” f o r PM=20 deg . , K=2.69 ” )
Scilab code Exa 7.19.1 stability using bode plot 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : s t a b i l i t y u s i n g b o d e p l o t // e x a m p l e 7 . 1 9 . 1 // p a g e 280 s = %s ; g =50/(( s +1) *( s +2) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.01; fmax =100; bode (G , fmin , fmax ) show_margins ( G ) gm = g_margin ( G ) 108
Figure 7.15: stability using bode plot
109
Figure 7.16: gain margin and phase margin 12 pm = p_margin ( G ) 13 disp ( gm , ” g a i n m a r g i n=” ) ; 14 disp ( pm , ” p h a s e m a r g i n=” ) ; 15 disp ( ” s i n c e g a i n and p h a s e m a r g i n a r e b o t h p o s i t i v e
so system i s s t a b l e ”)
Scilab code Exa 7.19.2 gain margin and phase margin 1 2 3
// c a p t i o n : g a i n m a r g i n a n d p h a s e m a r g i n // e x a m p l e 7 . 1 9 . 2 // p a g e 282 110
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
s = %s ; g =((2*( s +0.25) ) /( s ^2*( s +1) *( s +0.5) ) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.1; fmax =100; bode (G , fmin , fmax ) [ gm , freqGM ]= g_margin ( G ) ; [ pm , freqPM ]= p_margin ( G ) ; show_margins ( G ) ; disp ( gm , ” g a i n m a r g i n=” ) ; disp (( freqGM *2* %pi ) ,” g a i n m a r g i n f r e q=” ) ; disp ( pm , ” p h a s e m a r g i n=” ) ; disp (( freqPM *2* %pi ) ,” p h a s e m a r g i n f r e q=” ) ; show_margins ( G ) ; disp ( ” s i n c e g a i n and p h a s e m a r g i n a r e b o t h n e g a t i v e so system i s u n s t a b l e ”)
Scilab code Exa 7.19.3 stability using bode plot 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// c a p t i o n : s t a b i l i t y u s i n g b o d e p l o t // e x a m p l e 7 . 1 9 . 3 // p a g e 283 s = %s ; g =(48*( s +10) ) /( s *( s +20) *( s ^2+2.4* s +16) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.01; fmax =100; bode (G , fmin , fmax ) show_margins ( G ) gm = g_margin ( G ) pm = p_margin ( G ) disp ( gm , ” g a i n m a r g i n=” ) ; disp ( pm , ” p h a s e m a r g i n=” ) ; 111
Figure 7.17: stability using bode plot
112
Figure 7.18: root locus description 15
disp ( ” s i n c e g a i n and p h a s e m a r g i n a r e b o t h p o s i t i v e so system i s s t a b l e ”)
Scilab code Exa 7.24.1 root locus description 1 // c a p t i o n : r o o t l o c u s d e s c r i p t i o n 2 // e x a m p l e 7 . 2 4 . 1 3 // p a g e 295 4 clc ; 5 s = %s ; 6 syms K
113
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
G = K /( s *( s +4) ) ; disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +4) ) + K CH = sym ( ’ ( s ∗ ( s +4) )+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) eq =( s *( s +4) ) p = roots ( eq ) disp (p , ” open l o o p p o l e s a r e : ” ) K = sym ( ’ −( s ∗ ( s +4) ) ’ ) d = diff (K , s ) e =2* s +4 P =2; Z =0; disp ( ” s i n c e −2 l i e s on r o o t l o c u s s o breakaway p o i n t i s −2” ) for ( k =0:1) A =((2* k +1) *180) /( P - Z ) ; disp (A , ” a s y m p t o t e a r e a t a n g l e : ” ) end x =((0 -4) -0) /( P - Z ) // ( s u m o f P − s u m o f Z ) / ( P−Z ) disp (x , ” a s y m p t o t e s i n t e r s e c t a t ” ) disp ( ” s i n c e |G( s ) ∗H( s ) |=1 ” ) disp ( ” which g i v e s K=8” ) k =8 g = k /( s *( s +4) ) G = syslin ( ’ c ’ ,g ) evans (g ,200) xgrid (2)
Scilab code Exa 7.24.2 root locus description 1 2
// c a p t i o n : r o o t l o c u s d e s c r i p t i o n // e x a m p l e 7 . 2 4 . 2 114
Figure 7.19: root locus description
115
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 33 34 35 36 37 38
// p a g e 296 s = %s ; syms K ; GH = K /( s *( s +1) *( s +3) ) zeta =0.5 // from g i v e n d a t a disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +1) *( s +3) ) + K CH = sym ( ’ ( s ∗ ( s +1) ∗ ( s +3) )+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0] K = sym ( ’ −( s ˆ3+4∗ s ˆ2+3∗ s ) ’ ) d = diff (K , s ) e = -3* s ^2 -8* s -3 r1 = roots ( e ) disp ( r1 , ” r o o t s=” ) disp ( ” −0.45 i s b r e a k away p o i n t s i n c e i t l i e s on root l o c u s ”) disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” (12 −K) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=12 , f o r m a r g i a n l s t a b i l i t y ” ) ; K =12; k =12 a =4* s ^2+ k // i n t e r s e c t i o n o f r o o t l o c u s w i t h i m a g i n a r y plane r = roots ( a ) g = k /( s *( s +1) *( s +3) ) 116
39 G = syslin ( ’ c ’ ,g ) 40 evans (g ,8) 41 xgrid (2) 42 disp ( ” t h e l i n e t h e t a=a c o s ( z e t a ) =60 i n t e r s e c t s 43 44 45 46 47 48 49 50 51
root l o c u s a t s a =( −0.35+ i 0 . 6 ) ” ) disp ( ” t h e v a l u e o f K a t s=s a i s f i n d t o be 1 . 6 6 ” ) disp ( ” t h e v a l u e o f K a t s=−4” ) disp ( ”K=12” ) disp ( ” a t K=1.66 ” ) k =1.66 H =1 G = k /( s *( s +1) *( s +3) ) CL = G /(1+ G * H ) disp ( CL , ”C( s ) /R( s )=” )
Scilab code Exa 7.24.3 root locus description 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// c a p t i o n : r o o t l o c u s d e s c r i p t i o n // e x a m p l e 7 . 2 4 . 3 // p a g e 299 clc ; s = %s ; syms K G = K /( s *( s +6) *( s ^2+4* s +13) ) ; disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +6) *( s ^2+4* s +13) ) + K CH = sym ( ’ ( s ∗ ( s +6) ∗ ( s ˆ2+4∗ s +13) )+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) eq =( s *( s +6) *( s ^2+4* s +13) ) p = roots ( eq ) disp (p , ” open l o o p p o l e s a r e : ” ) phi1 =180 -( atan (3/2) *180/ %pi ) phi2 = atan (3/4) *180/ %pi 117
Figure 7.20: root locus description
118
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
phi3 =90 phi_p2 =180 -( phi1 + phi2 + phi3 ) phi_p3 = - phi_p2 disp ( phi_p2 , ” a n g l e o f d e p a r t u r e f o r −2+3 i =” ) disp ( phi_p3 , ” a n g l e o f d e p a r t u r e f o r −2−3 i=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; c4 = coeffs ( CH , ’ s ’ ,4) ; b =[ c0 c1 c2 c3 c4 ] routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh (1 ,3) ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0 ,0] routh =[ routh ;K ,0 ,0] K = sym ( ’ −( s ∗ ( s +6) ∗ ( s ˆ2+4∗ s +13) ) ’ ) d = diff (K , s ) e = -(4* s ^3+30* s ^2+74* s +78) f=-e; r = roots ( f ) ; disp (r , ” r=” ) disp ( ” s i n c e −4.2 l i e s on r o o t l o c u s , s o t h e breakaway p o i n t i s −4.2 ” ) disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” ( 7 8 − 0 . 3 4 ∗K) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K= 2 2 9 . 4 ” ) ; K =229.4; k =229.4; a =29.2* s ^2+229.4 // i n t e r s e c t i o n o f r o o t l o c u s w i t h s plane r1 = roots ( a ) g = k /( s *( s +6) *( s ^2+4* s +13) ) ; 119
Figure 7.21: root locus 52 g = syslin ( ’ c ’ ,g ) 53 evans (g ,200) 54 xgrid (2) 55 disp ( r1 , ” t h e p o i n t o f
i n te r s e ct i o n of root locus w i t h i m a g i n a r y a x i s =” )
Scilab code Exa 7.24.4 root locus 1 2 3
// c a p t i o n : r o o t l o c u s // e x a m p l e 7 . 2 4 . 4 // p a g e 301 120
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 34 35 36 37 38 39
clc ; s = %s ; syms K ; GH = K /( s *( s +4) *( s ^2+4* s +13) ) disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +4) *( s ^2+4* s +13) ) + K CH = sym ( ’ ( s ∗ ( s +4) ∗ ( s ˆ2+4∗ s +13) )+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; c4 = coeffs ( CH , ’ s ’ ,4) ; b =[ c0 c1 c2 c3 c4 ] routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh (1 ,3) ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0 ,0] routh =[ routh ;K ,0 ,0] K = sym ( ’ ( s ∗ ( s +4) ∗ ( s ˆ2+4∗ s +13) ) ’ ) d = diff (K , s ) e =( -4* s ^3+24* s ^2+58* s +52) r = roots ( e ) disp ( ” s i n c e −2 l i e s on r o o t l o c u s s o c o m p l e x breakaway p o i n t i s −2+ i 1 . 5 8 and −2− i 1 . 5 8 ” ) disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” ((20 −4K) / 5 ) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=5” ) ; K =5; k =5 a =5* s ^2+5 // i n t e r s e c t i o n o f r o o t l o c u s w i t h s p l a n e r = roots ( a ) g = k /( s *( s +2) *( s ^2+2* s +2) ) 121
40 G = syslin ( ’ c ’ ,g ) 41 evans (g ,200) 42 xgrid (2) 43 eq =( s *( s +4) *( s ^2+4* s +13) ) 44 p = roots ( eq ) 45 disp (p , ” open l o o p p o l e s a r e : ” ) 46 phi1 =180 -( atan (3/2) *180/ %pi ) 47 phi2 = atan (3/2) *180/ %pi 48 phi3 =90 49 phi_p2 =180 -( phi1 + phi2 + phi3 ) 50 phi_p3 = - phi_p2 51 disp ( phi_p2 , ” a n g l e o f d e p a r t u r e 52 disp ( phi_p3 , ” a n g l e o f d e p a r t u r e
f o r −2+3 i =” ) f o r −2−3 i=” )
Scilab code Exa 7.24.6 root locus 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// c a p t i o n : r o o t l o c u s // e x a m p l e 7 . 2 4 . 6 // p a g e 304 clc ; s = %s ; syms K ; clf () ; g =( K *( s +1) /( s ^2+0.4* s +0.4) ) ; eq =( s ^2+0.4* s +0.4) p = roots ( eq ) disp (p , ” open l o o p p o l e s a r e : ” ) ; P =2; Z =1; k =0 A =((2* k +1) *180) /( P - Z ) ; disp (A , ” a s y m p t o t e a r e a t a n g l e : ” ) CH =( s ^2+0.4* s +0.4) + K *( s +1) 122
Figure 7.22: root locus
123
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
CH = sym ( ’ ( s ˆ 2 + 0 . 4 ∗ s + 0 . 4 )+K∗ ( s +1) ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) K = sym ( ’ −( s ˆ 2 + 0 . 4 ∗ s + 0 . 4 ) / ( s +1) ’ ) d = diff (K , s ) e = s *( s +2) disp ( ” b r e a k away p o i n t s=−2 a s i t l i e s on r o o t l o c u s ”) disp ( ” s i n c e |G( s ) ∗H( s ) |=1 ” ) disp ( ” which g i v e s K=3.6 ” ) k =3.6 g =( k *( s +1) ) /( s ^2+0.4* s +0.4) ; G = syslin ( ’ c ’ ,g ) evans (g ,200) xgrid (1) v =[ -20 1 -2 2] mtlb_axis ( v ) ; disp ( ” p o l e s s =(−0.2+ j 0 . 6 and −0.2− j 0 . 6 ) a r e e q u i d i s t a n t from t h e z e r o s =−1, h e n c e r o o t l o c u s p l o t i s a r c o f t h e c i r c l e w i t h c e n t r e s=−1 and r a d i u s 1 . ”)
Scilab code Exa 7.24.7 root locus 1 // c a p t i o n : r o o t l o c u s 2 // e x a m p l e 7 . 2 4 . 7 3 // p a g e 306 4 s = %s ; 5 syms K ; 6 GH = K /( s *( s +2) *( s +4) ) 7 // s i n c e Mp=40%, s o .4= exp (( − z e t a ∗ %pi ) / ( s q r t (1− z e t a
ˆ2) ) 8 zeta =0.3 9 // from g i v e n d a t a 124
Figure 7.23: root locus
125
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +2) *( s +4) ) + K K = sym ( ’ −( s ˆ3+6∗ s ˆ2+8∗ s ) ’ ) d = diff (K , s ) e = -3* s ^2 -12* s -8 r1 = roots ( e ) disp ( r1 , ” r o o t s=” ) disp ( ” −0.842 i s b r e a k away p o i n t s i n c i t l i e s on root l o c u s ”) CH = sym ( ’ s ˆ3+6∗ s ˆ2+8∗ s+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” (48 −K) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=48” ) ; K =48; k =48 a =6* s ^2+48 // i n t e r s e c t i o n o f r o o t l o c u s w i t h imaginary plane r = roots ( a ) g = k /( s *( s +2) *( s +4) ) G = syslin ( ’ c ’ ,g ) evans (g ,8) xgrid (2) disp ( ” t h e l i n e t h e t a=a c o s ( z e t a ) =72.5 i n t e r s e c t s r o o t l o c u s a t s a =(−0.5+ i 1 . 6 5 ) ” ) disp ( ” t h e v a l u e o f K a t s=s a i s f i n d t o be 1 4 . 8 7 f o r 126
Figure 7.24: root locus
45 46 47 48 49 50
Mp=40%” ) K =14.87 ts =4/0.5 // t s =4/( z e t a ∗wn ) Kv = limit ( s * GH ,s ,0) Kv = eval ( Kv ) Kv = float ( Kv ) disp ( Kv , ”Kv=” ) ;
Scilab code Exa 7.24.8 root locus 1
// c a p t i o n : r o o t l o c u s 127
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 33 34 35 36 37
// e x a m p l e 7 . 2 4 . 8 // p a g e 308 clc ; s = %s ; syms K ; GH = K /( s *( s +1) *( s +3) ) zeta =0.5 // from g i v e n d a t a disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +1) *( s +3) ) + K CH = sym ( ’ ( s ∗ ( s +1) ∗ ( s +3) )+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0] K = sym ( ’ −( s ˆ3+4∗ s ˆ2+3∗ s ) ’ ) d = diff (K , s ) e = -3* s ^2 -8* s -3 r1 = roots ( e ) disp ( r1 , ” r o o t s=” ) disp ( ” −0.45 i s b r e a k away p o i n t s i n c e i t l i e s on root l o c u s ”) disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” (12 −K) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=12 , f o r m a r g i a n l s t a b i l i t y ” ) ; K =12; k =12 a =4* s ^2+ k // i n t e r s e c t i o n o f r o o t l o c u s w i t h i m a g i n a r y plane 128
38 r = roots ( a ) 39 disp (r , ” i n t e r s e c t i o n 40 41 42 43 44 45 46 47 48 49 50 51
point o f root l o c u s with i m a g i n a r y a x i s=” ) g = k /( s *( s +1) *( s +3) ) G = syslin ( ’ c ’ ,g ) evans (g ,8) xgrid (2) disp ( ” f o r K=6” ) k =6; GH = k /( s *( s +1) *( s +3) ) gm = K / k //gm=K( m a r g i n a l s t a b i l i t y ) /K( d e s i r e d ) disp ( gm , ” g a i n m a r g i n=” ) disp ( ” t h e p o i n t where K=6 i s s =1.2 ” ) pm =180+( -90 -( atan (1.2/1) *180/ %pi ) -( atan (1.2/3) *180/ %pi ) ) disp ( pm , ” p h a s e m a r g i n=” )
Scilab code Exa 7.24.9 root locus 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// c a p t i o n : r o o t l o c u s // e x a m p l e 7 . 2 4 . 9 // p a g e 308 clc ; s = %s ; syms K clf () ; g =( K *( s ^2+4) /( s *( s +1) ) ) ; Z =2 P =2 disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +1) ) + K *( s ^2+4) CH = sym ( ’ ( s ∗ ( s +1) )+K∗ ( s ˆ2+4) ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) 129
Figure 7.25: root locus
130
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
eq =( s *( s +1) ) p = roots ( eq ) disp (p , ” open l o o p p o l e s a r e : ” ) K = sym ( ’ −( s ∗ ( s +1) ) / ( s ˆ2+4) ’ ) d = diff (K , s ) e =2* s ^2 -8* s -8 r = roots ( e ) ; disp (r , ” r=” ) disp ( ” s i n c e −0.82 l i e s on r o o t l o c u s , s o t h e breakaway p o i n t i s −0.82 ” ) disp ( ” by p u t t i n g s = −0.82 i n |G( s ) ∗H( s ) | = 1 , t h e v a l u e o f K a t s = −0.82 i s K=0.2 ” ) k =0.2 g =( k *( s ^2+4) /( s *( s +1) ) ) ; G = syslin ( ’ c ’ ,g ) evans (g ,200) xgrid (2) disp ( ” p a r t ( b ) ” ) disp ( ” by p u t t i n g s =−0.69+ i 0 . 9 i n =0.464 ”)
|G( s ) ∗H( s ) | = 1 , K
Scilab code Exa 7.24.10 Overall Transfer Function and Root Locus // C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n a n d r o o t l o c u s // e x a m p l e 7 . 2 4 . 1 0 // p a g e 314 syms Ka Ke Kf Rf Lf eq N1 N2 N3 N4 N5 // where Ka= a m p l i f i e r g a i n ; Ke= e r r o r d e t e c t o r g a i n ; Kf=m o t o r t o r q u e c o n s t ; Rf= f i e l d r e s i s t a n c e ; L f= f i e l d i n d u c t a n c e Jeq=m o m e n t o f i n e r t i a ; f e q= coeff of viscous friction ; 6 s = %s ;
1 2 3 4 5
131
Figure 7.26: Overall Transfer Function and Root Locus
132
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
d = N1 / N2 ; e = N4 / N3 ; f = N4 / N5 ; n = N3 / N5 Ke =0.05; Kf =2; Rf =10; Lf =2; Jeq =0.5*10^ -4; feq =10^ -4; d =0.1; e =5; f =0.5; n =0.2; a =(1* Ke ) ; // i n s e r i e s b = Kf /( Rf + s * Lf ) ; c =1/( s *( Jeq * s + feq ) ) ; g= (b*c) // i n s e r i e s h= (g*a) // i n s e r i e s j = ( h *0.02) // i n s e r i e s k = j /(1+ j *0.5) ; a1 =1/20; cl = a1 * k disp ( cl , ”C( s ) /R( s )=” ) ; clf () ; G = syslin ( ’ c ’ , cl ) evans (G ,200) xgrid (2)
Scilab code Exa 7.24.11 root locus 1 2 3 4 5 6 7 8 9 10
// c a p t i o n : r o o t l o c u s // e x a m p l e 7 . 2 4 . 1 1 // p a g e 308 clc ; s = %s ; syms K clf () ; g = K *( s +0.1) /( s *( s -0.2) *( s ^2+ s +0.6) ) ; Z =2 P =2 133
Figure 7.27: root locus
134
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s -0.2) *( s ^2+ s +0.6) ) + K *( s +0.1) CH = sym ( ’ ( s ∗ ( s − 0 . 2 ) ∗ ( s ˆ2+ s + 0 . 6 ) )+K∗ ( s + 0 . 1 ) ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) eq =( s *( s -0.2) *( s ^2+ s +0.6) ) p = roots ( eq ) disp (p , ” open l o o p p o l e s a r e : ” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; c4 = coeffs ( CH , ’ s ’ ,4) ; b =[ c0 c1 c2 c3 c4 ] routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh (1 ,3) ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0 ,0] routh =[ routh ;K ,0 ,0] K = sym ( ’ −( s ∗ ( s − 0 . 2 ) ∗ ( s ˆ2+ s + 0 . 6 ) ) / ( s + 0 . 1 ) ’ ) d = diff (K , s ) e =3* s ^4+2* s ^3+0.64* s ^2+0.08* s -0.12 r = roots ( e ) ; disp (r , ” r=” ) disp ( ” s i n c e −0.37 and 0 . 0 8 l i e s on r o o t l o c u s , s o t h e breakaway p o i n t i s −0.37 and 0 . 0 8 ” ) disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” ( 6 2 5 ∗Kˆ2 −310∗K+33) / ( 6 2 5 ∗K−275)=0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K= 0 . 1 4 8 and 0 . 3 5 2 ” ) ; K1 =0.148; K2 =0.352 a =((11 -25* K1 ) /20) * s ^2+ K1 /10 // i n t e r s e c t i o n o f r o o t l o c u s w i t h jw a x i s r1 = roots ( a ) 135
46 b =((11 -25* K2 ) /20) * s ^2+ K2 /10 // i n t e r s e c t i o n 47 48 49 50 51 52 53 54
of root
l o c u s w i t h jw a x i s r2 = roots ( b ) disp ( r1 , r2 , ” r o o t l o c u s c r o s s e s i m a g i n a r y a x i s a t : ” ) g =( s +0.1) /( s *( s -0.2) *( s ^2+ s +0.6) ) ; G = syslin ( ’ c ’ ,g ) evans (G ,200) xgrid (2) v =[ -1 0.7 -2 2]; mtlb_axis ( v )
136
Chapter 8 COMPENSATION OF CONTROL SYSTEMS
Scilab code Exa 8.6.1 design suitable compensator 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// c a p t i o n : d e s i g n s u i t a b l e c o m p e n s a t o r // e x a m p l e 8 . 6 . 1 // p a g e 339 s = %s ; clf () ; syms K ; g =( K /( s *(1+0.2* s ) ) ) ; Kv = limit ( s *g ,s ,0) ; // s t a t i c v e l o c i t y e r r o r coefficient // s i n c e Kv=10 K =10; g =(10/( s *(1+0.2* s ) ) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.01; fmax =100; bode (G , fmin , fmax ) show_margins ( G ) xtitle ( ” u n c o m p e n s a t e d s y s t e m ” ) [ gm , freqGM ]= g_margin ( G ) ; 137
19 [ pm , freqPM ]= p_margin ( G ) ; 20 disp ( gm , ” g a i n m a r g i n=” ) ; 21 disp (( freqGM *2* %pi ) ,” g a i n m a r g i n f r e q=” ) ; 22 disp ( pm , ” p h a s e m a r g i n=” ) ; 23 disp (( freqPM *2* %pi ) ,”
24 25
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
p h a s e m a r g i n f r e q o r g a i n c r o s s o v e r f r e q u e n c y =” ) ; disp ( ” s i n c e P .M i s l e s s t h a n d e s i r e d v a l u e s o we need phase l e a d network ”) disp ( ” s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t w=5.5 r a d / s e c and p o l e a t w=13.8 r a d / s e c and applying gain to account a t t e n u a t i n f a c t o r . ”) gc =(1+0.18* s ) /(1+0.072* s ) Gc = syslin ( ’ c ’ , gc ) disp ( Gc , ” t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r=” ) ; G1 = G * Gc disp ( G1 , ” o v e r a l l t r a n s f e r f u n c t i o n=” ) ; fmin =0.01; fmax =100; figure () ; bode ( G1 , fmin , fmax ) ; show_margins ( G1 ) xtitle ( ” c o m p e n s a t e d s y s t e m ” ) [ gm , freqGM ]= g_margin ( G1 ) ; [ pm , freqPM ]= p_margin ( G1 ) ; disp ( pm , ” p h a s e m a r g i n o f c o m p e n s a t e d s y s t e m=” ) ; disp (( freqPM *2* %pi ) ,” g a i n c r o s s o v e r f r e q u e n c y =” ) ;
Scilab code Exa 8.6.2 design phase lead compensator 1
// c a p t i o n : d e s i g n p h a s e l e a d c o m p e n s a t o r 138
Figure 8.1: design suitable compensator
139
Figure 8.2: design suitable compensator
140
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 33
// e x a m p l e 8 . 6 . 2 // p a g e 340 clc ; s = %s ; clf () ; syms K ; g =( K /( s ^2*(1+0.05* s ) ) ) ; Ka = limit ( s ^2* g ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r coefficient // s i n c e Ka=100 K =100; g =(100/( s ^2*(1+0.05* s ) ) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.01; fmax =100; bode (G , fmin , fmax ) show_margins ( G ) xtitle ( ” u n c o m p e n s a t e d s y s t e m ” ) [ gm , freqGM ]= g_margin ( G ) ; [ pm , freqPM ]= p_margin ( G ) ; disp ( gm , ” g a i n m a r g i n=” ) ; disp (( freqGM *2* %pi ) ,” g a i n m a r g i n f r e q=” ) ; disp ( pm , ” p h a s e m a r g i n=” ) ; disp (( freqPM *2* %pi ) ,” p h a s e m a r g i n f r e q o r g a i n c r o s s o v e r f r e q u e n c y =” ) ; disp ( ” s i n c e P .M i s n e g a a t i v e s o s y s t e m i s u n s t a b l e ” ) disp ( ” s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t w=5 r a d / s e c and p o l e a t w=54 r a d / s e c and a p p l y i n g gain to account a t t e n u a t i n f a c t o r . ”) gc =(1+0.2* s ) /(1+0.0186* s ) Gc = syslin ( ’ c ’ , gc ) disp ( Gc , ” t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r=” ) ; G1 = G * Gc disp ( G1 , ” o v e r a l l t r a n s f e r f u n c t i o n=” ) ; fmin =0.01; fmax =100; 141
Figure 8.3: design phase lead compensator 34 figure () ; 35 bode ( G1 , fmin , fmax ) 36 show_margins ( G1 ) 37 xtitle ( ” c o m p e n s a t e d s y s t e m ” ) 38 [ gm , freqGM ]= g_margin ( G1 ) ; 39 [ pm , freqPM ]= p_margin ( G1 ) ; 40 disp ( pm , ” p h a s e m a r g i n o f c o m p e n s a t e d s y s t e m=” ) ; 41 disp (( freqPM *2* %pi ) ,” g a i n c r o s s o v e r f r e q u e n c y =” ) ;
142
Figure 8.4: design phase lead compensator
143
Scilab code Exa 8.6.3 design suitable compensator 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
// c a p t i o n : d e s i g n s u i t a b l e c o m p e n s a t o r // e x a m p l e 8 . 6 . 3 // p a g e 344 clc ; s = %s ; clf () ; syms K ; g =( K /( s *(1+0.5* s ) *(1+0.2* s ) ) ) ; Kv =1/0.125 // s t a t i c 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= d e s i r e d output v e l o c i t y / steady s t a t e e r r o r ) // s i n c e Kv=8 , a s s y s t e m i s t y p e 1 , s o K=Kv ; K =8; g =(8/( s *(1+0.5* s ) *(1+0.2* s ) ) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.01; fmax =100; bode (G , fmin , fmax ) show_margins ( G ) xtitle ( ” u n c o m p e n s a t e d s y s t e m ” ) [ gm , freqGM ]= g_margin ( G ) ; [ pm , freqPM ]= p_margin ( G ) ; disp ( gm , ” g a i n m a r g i n=” ) ; disp (( freqGM *2* %pi ) ,” g a i n m a r g i n f r e q o r p h a s e c r o s s o v e r f r e q u e n c y==” ); disp ( pm , ” p h a s e m a r g i n=” ) ; disp (( freqPM *2* %pi ) ,” p h a s e m a r g i n f r e q o r g a i n c r o s s o v e r f r e q u e n c y =” ) ; disp ( ” s i n c e g a i n c r o s s o v e r f r e q and p h a s e c r o s s o v e r f r e q a r e v e r y c l o s e t o e a c h o t h e r . So , s y s t e m i s m a r g i n a l l y s t a b l e ”); disp ( ” s o we n e e d p h a s e l a g n e t w o r k ” ) disp ( ” s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t w=0.18 r a d / s e c and p o l e a t w=0.04 r a d / s e c and applying gain to account a t t e n u a t i n f a c t o r . ”) 144
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
gc =(1+5.55* s ) /(1+24.7* s ) Gc = syslin ( ’ c ’ , gc ) disp ( Gc , ” t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r=” ) ; G1 = G * Gc disp ( G1 , ” o v e r a l l t r a n s f e r f u n c t i o n=” ) ; fmin =0.01; fmax =100; figure () ; bode ( G1 , fmin , fmax ) show_margins ( G1 ) xtitle ( ” c o m p e n s a t e d s y s t e m ” ) [ gm , freqGM ]= g_margin ( G1 ) ; [ pm , freqPM ]= p_margin ( G1 ) ; disp ( gm , ” g a i n m a r g i n=” ) ; disp (( freqGM *2* %pi ) ,” g a i n m a r g i n f r e q o r p h a s e c r o s s o v e r f r e q u e n c y==” ); 43 disp ( pm , ” p h a s e m a r g i n o f c o m p e n s a t e d s y s t e m=” ) ; 44 disp (( freqPM *2* %pi ) ,” g a i n c r o s s o v e r f r e q u e n c y =” ) ;
145
Figure 8.5: design suitable compensator
146
Figure 8.6: design suitable compensator
147
Chapter 9 INTRODUCTION TO STATE SPACE ANALYSIS OF CONTROL SYSTEMS
Scilab code Exa 9.8.1 Check for Contrallability of System // c a p t i o n : c h e c k f o r c o n t r a l l a b i l i t y o f s y s t e m // e x a m p l e 9 . 8 . 1 // p a g e 381 A =[1 1;0 -1] B =[1;0] P = cont_mat (A , B ) ; disp (P , ” C o n t r o l l a b i l i t y M a t r i x=” ) ; d = determ ( P ) if d ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n c o n t r o l l a b l e ”); 11 else 12 printf ( ” s y s t e m i s c o n t r o l l a b l e ” ) ; 13 end ;
1 2 3 4 5 6 7 8 9 10
148
Scilab code Exa 9.8.2 Check for Contrallability of System // c a p t i o n : c h e c k f o r c o n t r a l l a b i l i t y o f s y s t e m // e x a m p l e 9 . 8 . 2 // p a g e 381 A =[ -2 0;0 -1] B =[1;1] P = cont_mat (A , B ) ; disp (P , ” C o n t r o l l a b i l i t y M a t r i x=” ) ; d = determ ( P ) if d ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n c o n t r o l l a b l e ”); 11 else 12 printf ( ” s y s t e m i s c o n t r o l l a b l e ” ) ; 13 end ;
1 2 3 4 5 6 7 8 9 10
Scilab code Exa 9.9.1.a Check for Observability of System // c a p t i o n : c h e c k f o r o b s e r v a b i l i t y o f s y s t e m // e x a m p l e 9 . 9 . 1 a // p a g e 383 A =[0 1; -2 -3] B =[0;1] C =[1 1] P = obsv_mat (A , C ) ; disp (P , ” O b s e r v a b i l i t y M a t r i x=” ) ; d = determ ( P ) if d ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n o b s e r v a b l e ”); 12 else 13 printf ( ” s y s t e m i s o b s e r v a b l e ” ) ; 14 end ; 1 2 3 4 5 6 7 8 9 10 11
149
Scilab code Exa 9.9.1.b Check for Observability of System // c a p t i o n : c h e c k f o r o b s e r v a b i l i t y o f s y s t e m // e x a m p l e 9 . 9 . 1 b // p a g e 383 A =[ -2 1;0 1] B =[1;1] C =[1 1] P = obsv_mat (A , C ) ; disp (P , ” O b s e r v a b i l i t y M a t r i x=” ) ; d = determ ( P ) if d ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n o b s e r v a b l e ”); 12 else 13 printf ( ” s y s t e m i s o b s e r v a b l e ” ) ; 14 end ; 1 2 3 4 5 6 7 8 9 10 11
Scilab code Exa 9.10.4.a Obtain State Matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 9 . 1 0 . 4 a // p a g e 387 s = %s ; g =1/(( s +1) *( s +3) ) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
150
Scilab code Exa 9.10.4.b Obtain State Matrix 1 2 3 4 5 6 7 8 9 10 11 12
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 9 . 1 0 . 4 b // p a g e 387 clc ; s = %s ; g =(2* s +1) /( s ^2+2) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 9.10.5 Obtain State Matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 9 . 1 0 . 5 // p a g e 388 s = %s ; g =( s +3) /( s ^2+3* s +4) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
151
Scilab code Exa 9.10.6 Obtain State Matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 9 . 1 0 . 6 // p a g e 389 s = %s ; g =( s ^2+3* s +2) /( s ^3+9* s ^2+26* s +24) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 9.10.7 Obtain State Matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 9 . 1 0 . 7 // p a g e 390 s = %s ; g =( s +3) /(( s +1) *( s +2) ) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 9.10.9 Obtain State Matrix 1 2 3
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 9 . 1 0 . 9 // p a g e 392 152
4 5 6 7 8 9 10 11
s = %s ; g =(10*( s +3) ) /(( s +4) *( s +2) ^2) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 9.10.10 Obtain State Matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 9 . 1 0 . 1 0 // p a g e 393 s = %s ; g =( s ^2+6* s +8) /(( s +3) *( s ^2+2* s +5) ) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 9.10.11 Obtain Time Response 1 2 3 4 5 6 7 8
// c a p t i o n : o b t a i n t i m e r e s p o n s e // e x a m p l e 9 . 1 0 . 1 1 // p a g e 394 s = %s ; syms t A =[0 1; -2 0] B =[1 -1] x0 =[1 1] ’ 153
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f s I −A r = inv ( p ) // i n v e r s e o f s I −A // f o r c a l c u l a t i n g s t a t e t r a n s i s t i o n m a t r i x ip =[0 0;0 0] i =1; j =1; for i =1:2 for j =1:2 ip (i , j ) = ilaplace ( r (i , j ) ,s , t ) ; j = j +1; end i = i +1; end disp ( ip , ” s t a t e t r a n s i s t i o n m a t r i x , i p ( t )=” ) ; x = ip * x0 y = x (1 ,1) -x (2 ,1) y = simple ( y ) // o u t p u t disp (y , ” t i m e r e s p o n s e o f t h e system , y ( t )=” ) ;
Scilab code Exa 9.10.12.i Obtain Zero Input Response 1 2 3 4 5 6 7 8 9 10 11 12 13
// c a p t i o n : o b t a i n z e r o i n p u t r e s p o n s e // e x a m p l e 9 . 1 0 . 1 2 ( i ) // p a g e 395 s = %s ; syms t A =[0 1; -2 -1] B =[0 1] ’ x0 =[1 0] ’ [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f s I −A r = inv ( p ) // i n v e r s e o f s I −A // f o r c a l c u l a t i n g s t a t e t r a n s i s t i o n m a t r i x 154
14 15 16 17 18 19 20 21 22 23 24 25
ip =[0 0;0 0] i =1; j =1; for i =1:2 for j =1:2 ip (i , j ) = ilaplace ( r (i , j ) ,s , t ) ; j = j +1; end i = i +1; end disp ( ip , ” s t a t e t r a n s i s t i o n m a t r i x , i p ( t )=” ) ; x = ip * x0 disp (x , ” z e r o i n p u t r e s p o n s e o f t h e system , x ( t )=” ) ;
Scilab code Exa 9.10.12.ii Obtain Zero State Response 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// c a p t i o n : o b t a i n z e r o s t a t e r e s p o n s e // e x a m p l e 9 . 1 0 . 1 2 ( i i ) // p a g e 395 s = %s ; syms t A =[0 1; -2 -1] B =[0 1] ’ x0 =[1 0] ’ [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f s I −A r = inv ( p ) // i n v e r s e o f s I −A m = r * B *(1/ s ) ; // f o r c a l c u l a t i n g z e r o s t a t e r e s p o n s e x =[0;0] x (1 ,1) = ilaplace ( m (1 ,1) ,s , t ) ; x (2 ,1) = ilaplace ( m (2 ,1) ,s , t ) ; disp (x , ” z e r o i n p u t r e s p o n s e o f t h e system , x ( t )=” ) ;
155
Scilab code Exa 9.10.13 Obtain Time Response 1 2 3 4 5 6 7 8 9 10 11 12 13
// c a p t i o n : o b t a i n t i m e r e s p o n s e // e x a m p l e 9 . 1 0 . 1 3 // p a g e 397 syms t ; A =[0 1; -2 0] x0 =[1 1] ’ [ r c ]= size ( A ) ; // s i z e o f m a t r i x A // s i n c e exp ( At )=I+A∗ t +(A∗ t ) ˆ2/2+(A∗ t ) ˆ 3 / 3 + . . . I = eye (r , c ) p = I + A * t +( A * t ) ^2/2+( A * t ) ^3/3 x = p * x0 ; disp ( x (1 ,1) ,” t i m e r e s p o n s e o f t h e system , x1 ( t )=” ) ; disp ( x (2 ,1) ,” t i m e r e s p o n s e o f t h e system , x2 ( t )=” ) ;
Scilab code Exa 9.10.14 Obtain Time Response using Diagonalization Process 1
2 3 4 5 6 7 8 9 10 11
// c a p t i o n : obtain time response using diagonalization process // e x a m p l e 9 . 1 0 . 1 4 // p a g e 398 syms m11 m22 m21 m12 t ; s = %s ; poly (0 , ” l ” ) ; A =[1 4; -2 -5] B =[0;1] C =[1;0] ’ x0 =[1 0] ’ [ r c ]= size ( A ) ; // s i z e o f m a t r i x A 156
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
I = eye (r , c ) ; p = l *I - A ; // l ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f l I −A // r o o t s o f q a r e −1 and −3 l1 = -1; l2 = -3; // f o r d e t e r m i n i n g modal m a t r i x x1 =[ m11 ; m21 ] q1 =( l1 *I - A ) * x1 // on s o l v i n g we f i n d m11=1 , m21=−0.5 m11 =1; m21 = -0.5 x2 =[ m12 ; m22 ] q2 =( l2 *I - A ) * x1 // on s o l v i n g we f i n d m12=1 , m22=−1 m12 =1; m22 = -1 M =[ m11 m12 ; m21 m22 ] M1 = inv ( M ) ; k1 = M1 * A * M ; z0 = M1 * x0 ; k2 = M1 * B Z = inv ( s *I - k1 ) * z0 +( inv ( s *I - k1 ) * k2 ) *(1/ s ) ; X=M*Z x =[0;0] x (1 ,1) = ilaplace ( X (1 ,1) ,s , t ) ; x (2 ,1) = ilaplace ( X (2 ,1) ,s , t ) ; y=C*x disp (y , ” o u t p u t e q u a t i o n i s , y ( t )=” )
Scilab code Exa 9.10.15 Obtain Time Response using Diagonalization Process 1
// c a p t i o n : obtain time response using diagonalization process
157
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
// e x a m p l e 9 . 1 0 . 1 5 // p a g e 403 syms t ; s = %s ; poly (0 , ” l ” ) ; A =[0 1; -6 -5] B =[0;1] C =[6 1] x0 =[1 0] ’ [ r c ]= size ( A ) ; // s i z e o f m a t r i x A I = eye (r , c ) ; p = l *I - A ; // l ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f l I −A // r o o t s o f q a r e −1 and −3 l1 = -2; l2 = -3; // f o r d e t e r m i n i n g vandermonde ’ s m a t r i x P =[1 1; l1 l2 ]; P1 = inv ( P ) ; k1 = P1 * A * P ; z0 = P1 * x0 ; k2 = P1 * B Z = inv ( s *I - k1 ) * z0 +( inv ( s *I - k1 ) * k2 ) *(1/ s ) ; X=P*Z X (2 ,1) = -5/( s ^2+5* s +6) x =[0;0] x (1 ,1) = ilaplace ( X (1 ,1) ,s , t ) ; x (2 ,1) = ilaplace ( X (2 ,1) ,s , t ) ; y=C*x y = simple ( y ) disp (y , ” o u t p u t e q u a t i o n i s , y ( t )=” )
Scilab code Exa 9.10.16 Determine Transfer Matrix 1
// c a p t i o n : d e t e r m i n e t r a n s f e r m a t r i x 158
2 3 4 5 6 7 8 9 10 11 12 13
// e x a m p l e 9 . 1 0 . 1 6 // p a g e 406 clc ; s = %s A =[1 -2;4 -5] B =[2;1] C =[1 1] [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x r = inv ( p ) // i n v e r s e o f s I −A G = C * r * B // t r a n s f e r m a t r i x disp (G , ” t r a n s f e r m a t r i x=” )
Scilab code Exa 9.10.17 Determine Transfer Matrix 1 2 3 4 5 6 7 8 9 10 11 12 13
// c a p t i o n : d e t e r m i n e t r a n s f e r m a t r i x // e x a m p l e 9 . 1 0 . 1 7 // p a g e 407 s = %s A =[ -3 1;0 -1] B =[1;1] C =[1 1] D =0; [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x r = inv ( p ) // i n v e r s e o f s I −A G = C * r * B // t r a n s f e r m a t r i x disp (G , ” t r a n s f e r m a t r i x=” )
Scilab code Exa 9.10.18 Determine Transfer Matrix 1 2
// c a p t i o n : d e t e r m i n e t r a n s f e r m a t r i x // e x a m p l e 9 . 1 0 . 1 7 159
3 4 5 6 7 8 9 10 11 12 13
// p a g e 407 s = %s A =[0 3; -2 -5] B =[1 1;1 1] C =[2 1;1 0] D =0; [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x r = inv ( p ) // i n v e r s e o f s I −A G = C * r * B // t r a n s f e r m a t r i x disp (G , ” t r a n s f e r m a t r i x=” )
Scilab code Exa 9.10.20 Check for Contrallability of System 1 2 3 4 5 6 7 8
9 10 11 12 13 14
// c a p t i o n : c h e c k f o r c o n t r a l l a b i l i t y o f s y s t e m // e x a m p l e 9 . 1 0 . 2 0 // p a g e 410 A =[0 1 0;0 0 1;0 -2 -3] B =[0 1;0 0;1 1] P = cont_mat (A , B ) ; disp (P , ” C o n t r o l l a b i l i t y M a t r i x=” ) ; S =[ P (1) P (4) P (7) ; P (2) P (5) P (8) ; P (3) P (6) P (9) ]; // c o l l e c t i n g c o l u m n s from P t o form a s q u a r e m a t r i x (3∗3) d = det ( S ) ; if d ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n c o n t r o l l a b l e ”); else printf ( ” s y s t e m i s c o n t r o l l a b l e ” ) ; end ;
Scilab code Exa 9.10.21 Check for Contrallability and Observability 160
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// c a p t i o n : check for contrallability and observability of system // e x a m p l e 9 . 1 0 . 2 1 // p a g e 411 A =[0 1 0;0 0 1; -6 -11 -6] B =[1 0 1] ’ C =[10 5 1] P = cont_mat (A , B ) ; disp (P , ” C o n t r o l l a b i l i t y M a t r i x=” ) ; d = det ( P ) if d ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n c o n t r o l l a b l e ”); else printf ( ” s y s t e m i s c o n t r o l l a b l e ” ) ; end ; P1 = obsv_mat (A , C ) ; disp ( P1 , ” O b s e r v a b i l i t y M a t r i x=” ) ; d1 = det ( P1 ) if d1 ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n o b s e r v a b l e ”); else printf ( ” s y s t e m i s o b s e r v a b l e ” ) ; end ;
Scilab code Exa 9.10.22 Check for Contrallability and Observability 1
// c a p t i o n : check for contrallability and observability of system
2 // e x a m p l e 9 . 1 0 . 2 1 3 // p a g e 411 4 s = %s ;
161
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
g =(10*( s +3) ) /(( s +4) *( s +2) ^2) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”Y( s ) /U( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) A = SS (2) B = SS (3) C = SS (4) P = cont_mat (A , B ) ; P = round ( P ) disp (P , ” C o n t r o l l a b i l i t y M a t r i x=” ) ; d = det ( P ) if d ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n c o n t r o l l a b l e ”); else printf ( ” s y s t e m i s c o n t r o l l a b l e ” ) ; end ; P1 = obsv_mat (A , C ) ; P1 = round ( P1 ) ; disp ( P1 , ” O b s e r v a b i l i t y M a t r i x=” ) ; d1 = det ( P1 ) if d1 ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n o b s e r v a b l e ”); else printf ( ” s y s t e m i s o b s e r v a b l e ” ) ; end
162
Chapter 11 SOLUTION OF PROBLEMS USING COMPUTER
Scilab code Exa 11.1 pole zero Plot 1 2 3 4 5 6 7 8 9
// C a p t i o n : p o l e z e r o p l o t // e x a m p l e 11 1 // p a g e 468 // t r a n s f e r f u n c t i o n :G( s ) = ( ( 8 ∗ ( s +3) ∗ ( s +4) ) / ( s ∗ ( s +2) ∗ ( s ˆ2+2∗ s +2) ) ) s = %s ; G = syslin ( ’ c ’ ,((8*( s +3) *( s +4) ) /( s *( s +2) *( s ^2+2* s +2) ) ) ); disp (G , ”G( s )=” ) ; x = plzr ( G ) xgrid (2)
Scilab code Exa 11.2 transfer function
163
Figure 11.1: pole zero Plot
164
1 2 3 4 5 6 7 8 9 10 11 12 13
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 11 2 // p a g e 469 syms G1 G2 G3 H1 ; s = %s ; G1 =4/( s *( s +4) ) ; G2 = s +1.2; G3 = s +0.8; H1 =1; H2 =( G2 + G3 ) ; a = G1 /. H1 ; y = a /(1+ a * H2 ) disp (y , ”C( s ) /R( s )=” )
Scilab code Exa 11.3 transfer function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 11 3 // p a g e 470 syms G1 G2 G3 H1 ; s = %s ; G1 =4; G2 = s G3 =1/( s *( s +2) ) ; H1 =0.5; H2 =1; a =( G1 + G2 ) ; b =( a * G3 ) ; c = b /. H1 ; y = c /(1+ c * H2 ) disp (y , ”C( s ) /R( s )=” )
Scilab code Exa 11.4 determine Wn zeta and Mp 165
// c a p t i o n : determine Wn , z e t a a n d M p // e x a m p l e 11 4 // p a g e 471 s = %s ; num =1; den = sym ( ’ s ∗ ( 1 + 0 . 5 ∗ s ) ∗ ( 1 + 0 . 2 ∗ s ) ’ ) ; c = num / den ; c = simple ( c ) ; disp (c , ”C( s ) /E( s )=” ) ; G=c; H =1; CL = G /(1+ G * H ) ; CL = simple ( CL ) ; disp ( CL , ”C( s ) /R( s )=” ) ; A = pfss ((10/( s ^3+7* s ^2+10* s +10) ) ) ; d = denom ( A (1) ) ; b = coeff ( denom ( A (1) ) ) printf ( ” f o r o s c i l l a t o r y r o o t s : ” ) Wn = sqrt ( b (1 ,1) ) ; // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn= 1 . 5 ; zeta =1.5/(2* Wn ) ; // damping r a t i o Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; // % peak overshoot 23 disp ( Wn , ” n a t u r a l f r e q u e n c y ,Wn=” ) ; 24 disp ( zeta , ” damping r a t i o , z e t a=” ) ; 25 disp ( Mp , ” % p e a k o v e r s h o o t , Mp=” ) ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Scilab code Exa 11.5 time response for unit step function 1 // C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n 2 // e x a m p l e 11 6 3 // p a g e 474 4 s = %s ; 5 syms t ; 6 G =( s +2) /( s *( s +1) )
166
7 8 9 10 11 12 13 14 15 16 17 18 19
H =1; CL = G /. H disp ( CL , ”C( s ) /R( s )=” ) y = ilaplace ( CL ,s , t ) ; disp (y , ” c ( t )=” ) ; b = denom ( CL ) c = coeff ( b ) //Wnˆ2= c ( 1 , 1 ) Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=c ( 1 , 2 ) zeta = c (1 ,2) /(2* Wn ) // damping r a t i o Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y tr =( %pi - atan ( sqrt (1 - zeta ^2) / zeta ) ) /( Wn * sqrt (1 - zeta ^2) ) 20 Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max . overshoot 21 disp ( tr , ” r i s e t i m e=” ) ; 22 disp ( Mp , ”max . peak o v e r s h o o t=” ) ;
Scilab code Exa 11.7 time response for unit step function 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n // e x a m p l e 11 7 // p a g e 475 s = %s ; syms t ; CL =( s +2) /( s ^2+2* s +2) disp ( CL , ”C( s ) /R( s )=” ) y = ilaplace ( CL ,s , t ) ; disp (y , ” c ( t )=” ) ; b = denom ( CL ) c = coeff ( b ) //Wnˆ2= c ( 1 , 1 ) Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=c ( 1 , 2 ) 167
15 zeta = c (1 ,2) /(2* Wn ) // damping r a t i o 16 Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y 17 Tp = %pi / Wd // peak t i m e 18 Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max .
overshoot 19 disp ( Tp , ” peak t i m e=” ) ; 20 disp ( Mp , ”max . peak o v e r s h o o t=” )
Scilab code Exa 11.8 time response for unit step function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n // e x a m p l e 11 8 // p a g e 476 s = %s ; syms t ; G =(20) /(( s +1) *( s +5) ) H =1; CL = G /. H disp ( CL , ”C( s ) /R( s )=” ) y = ilaplace ( CL ,s , t ) ; disp (y , ” c ( t )=” ) ; b = denom ( CL ) c = coeff ( b ) //Wnˆ2= c ( 1 , 1 ) Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=c ( 1 , 2 ) zeta = c (1 ,2) /(2* Wn ) // damping r a t i o Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max . overshoot Tp = %pi / Wd // peak t i m e t =(2* %pi ) /( Wn * sqrt (1 - zeta ^2) ) // p e r i o d o f o s c i l l a t i o n ts =4/( zeta * Wn ) // s e t t l i n g t i m e N = Wd /(2* %pi ) * ts // no . o f o s c i l l a t i o n s c o m p l e t e d before reaching steady state 168
disp ( Tp , ” peak t i m e=” ) ; disp ( Mp , ”max . peak o v e r s h o o t=” ) ; disp (t , ” p e r i o d o f o s c i l l a t i o n ” ) ; disp (N , ” no . o f o s c i l l a t i o n s c o m p l e t e d b e f o r e r e a c h i n g s t e a d y s t a t e=” ) ; 28 disp ( ts , ” s e t t l i n g t i m e=” ) 24 25 26 27
Scilab code Exa 11.9 time response for unit step function // C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n // e x a m p l e 11 9 // p a g e 476 s = %s ; syms t ; CL =(4* s +4) /( s ^2+2* s +5) disp ( CL , ”C( s ) /R( s )=” ) y = ilaplace ( CL ,s , t ) ; disp (y , ” c ( t )=” ) ; b = denom ( CL ) c = coeff ( b ) //Wnˆ2= c ( 1 , 1 ) Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=c ( 1 , 2 ) zeta = c (1 ,2) /(2* Wn ) // damping r a t i o Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max . overshoot 18 Tp = %pi / Wd // peak t i m e 19 disp ( Tp , ” peak t i m e=” ) ; 20 disp ( Mp , ”max . peak o v e r s h o o t=” ) ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Scilab code Exa 11.10.a calculate tr Tp Mp 169
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// C a p t i o n : c a l c u l a t e t r , Tp , Mp // e x a m p l e 11 1 0 a // p a g e 478 s = %s ; G =16/( s ^2+1.6* s ) H =1; CL = G /. H disp ( CL , ”C( s ) /R( s )=” ) ; b = denom ( CL ) c = coeff ( b ) //Wnˆ2= c ( 1 , 1 ) Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=c ( 1 , 2 ) zeta = c (1 ,2) /(2* Wn ) // damping r a t i o Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max . overshoot tr =( %pi - atan ( sqrt (1 - zeta ^2) / zeta ) ) /( Wn * sqrt (1 - zeta ^2) ) // r i s e t i m e Tp = %pi / Wd // peak t i m e disp ( Tp , ” peak t i m e=” ) ; disp ( Mp , ”max . peak o v e r s h o o t=” ) disp ( tr , ” r i s e t i m e=” )
Scilab code Exa 11.10.b calculate Td tr Tp Mp 1 2 3 4 5 6 7 8 9
// C a p t i o n : c a l c u l a t e T d , t r , Tp , Mp // e x a m p l e 11 1 0 b // p a g e 478 s = %s ; syms Td G =16/( s ^2+1.6* s ) G1 =1+ s * Td H =1; a = G * G1 170
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
CL = a /. H CL = simple ( CL ) disp ( CL , ”C( s ) /R( s )=” ) ; zeta =0.8 // g i v e n // s i n c e z e t a =0.8 s o 2∗ z e t a ∗Wn=1.6+16∗Td Wn = sqrt (16) // s o on s o l v i n g Td =0.3 // s o t r a n s f e r f u n c t i o n t a k e s t h e form : CL1 =(16+4.8* s ) /( s ^2+6.4* s +6) disp ( CL1 , ”C( s ) /R( s )=” ) ; Wn1 = sqrt (16) // 2∗ z e t a 1 ∗Wn1=6.4 zeta1 =6.4/(2* Wn1 ) // damping r a t i o Wd = Wn1 * sqrt (1 - zeta1 ^2) // damped f r e q u e n c y Mp =( exp ( -( zeta1 * %pi ) / sqrt (1 - zeta1 ^2) ) ) *100 //max . overshoot tr =( %pi - atan ( sqrt (1 - zeta1 ^2) / zeta1 ) ) /( Wn1 * sqrt (1 zeta1 ^2) ) // r i s e t i m e Tp = %pi / Wd // peak t i m e disp ( Tp , ” peak t i m e=” ) ; disp ( Mp , ”max . peak o v e r s h o o t=” ) disp ( tr , ” r i s e t i m e=” )
Scilab code Exa 11.11 expression for unit step response 1 2 3 4 5 6 7 8 9
// C a p t i o n : e x p r e s s i o n f o r u n i t s t e p r e s p o n s e // e x a m p l e 11 1 1 // p a g e 481 syms G1 G2 G3 H1 t ; s = %s ; G1 = s +1; G2 =1/( s +2) ; H2 =1/( s *( s +1) ) ; H1 =1/( s +2) ; 171
10 11 12 13 14 15 16 17
a = G1 /(1+ G1 * H1 ) ; b = a /(1+ a * H2 ) y = b * G2 ; disp (y , ”C( s ) /R( s )=” ) // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ; C = y *(1/ s ) c = ilaplace (C ,s , t ) disp (c , ” e x p r e s s i o n f o r u n i t s t e p r e s p o n s e i s =” )
Scilab code Exa 11.12 unit step and impulse response 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// C a p t i o n : u n i t s t e p a n d i m p u l s e r e s p o n s e // e x a m p l e 11 1 2 // p a g e 482 s = %s ; syms t ; G =(4* s +1) /(4* s ^2) H =1; CL = G /. H disp ( CL , ”C( s ) /R( s )=” ) y = ilaplace ( CL ,s , t ) ; disp (y , ” u n i t i m p u l s e r e s p o n s e , c ( t )=” ) ; // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ; C = CL *(1/ s ) c = ilaplace (C ,s , t ) disp (c , ” e x p r e s s i o n f o r u n i t s t e p r e s p o n s e i s =” )
Scilab code Exa 11.13 determine transfer function 1 2 3 4
// C a p t i o n : d e t e r m i n e t r a n s f e r f u n c t i o n // e x a m p l e 11 1 3 // p a g e 483 syms t ; 172
5 f = exp ( - t ) *(1 - cos (2* t ) ) 6 F = laplace (f ,t , s ) ; 7 disp (F , ”F ( s )=” )
Scilab code Exa 11.14 determine Wn Wd Tp zeta and steady state error 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
// c a p t i o n : determine Wn ,Wd, Tp , zeta and steady state error // e x a m p l e 11 1 4 // p a g e 484 s = %s ; syms t ; G =20/(( s +5) *( s +1) ) H =1; CL = G /. H disp ( CL , ”C( s ) /R( s )=” ) b = denom ( CL ) disp (0 ,b , ”=” ,” t h e c h a r . eq i s : ” ,) Wn = sqrt (25) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=6 zeta =6/(2* Wn ) ; // damping r a t i o d = zeta * Wn ; // d a m p i n g f a c t o r z = sqrt (1 - zeta ^2) ; Wd = Wn * z ; // d a m p e d f r e q u e n c y o f o s c i l l a t i o n Mp = exp (( - zeta * %pi ) / z ) *100; // % max . p e a k o v e r s h o o t Tp = %pi / Wd // peak t i m e tfirst =(2* %pi ) / Wd // t i m e f o r f i r s t u n d e r s h o o t period =(2* %pi ) / Wd // p e r i o d o f o s c i l l a t i o n ts =4/( zeta * Wn ) // s e t t l i n g t i m e N =( Wd /(2* %pi ) ) * ts // no . o f o s c i l l a t i o n s c o m p l e t e d before reaching steady state disp ( Wn , ” n a t u r a l f r e q u e n c y=” ) ; disp ( zeta , ” damping r a t i o =” ) ; disp ( Wd , ” damped f r e q u e n c y o f o s c i l l a t i o n =” ) ; disp ( Tp , ” peak t i m e=” ) ; 173
28 29 30 31
disp ( Mp , ”% max . peak o v e r s h o o t=” ) ; disp ( tfirst , ” t i m e f o r f i r s t u n d e r s h o o t=” ) ; disp ( period , ” p e r i o d o f o s c i l l a t i o n =” ) ; disp (N , ” no . o f o s c i l l a t i o n s c o m p l e t e d b e f o r e r e a c h i n g s t e a d y s t a t e=” ) ;
Scilab code Exa 11.15 determine Wn Wd zeta and steady state error 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
// c a p t i o n : determine Wn ,Wd, zeta and steady state error // e x a m p l e 11 1 5 // p a g e 484 s = %s ; G = sym ( ’ 2 5 / ( s ∗ ( s +5) ) ’ ) ; G = simple ( G ) ; H =1; CL = G /. H ; CL = simple ( CL ) ; disp ( CL , ”C( s ) /R( s )=” ) ; printf ( ” t h e c h a r . eq i s : ” ) disp ( ” s ˆ2+5∗ s +25” ) Wn = sqrt (25) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=5 zeta =5/(2* Wn ) ; // damping r a t i o d = zeta * Wn ; // d a m p i n g f a c t o r z = sqrt (1 - zeta ^2) ; Wd = Wn * z ; // d a m p e d f r e q u e n c y o f o s c i l l a t i o n Mp = exp (( - zeta * %pi ) / z ) *100; // % max . p e a k o v e r s h o o t // s t e a d y s t a t e e r r o r f o r u n i t ramp i n p u t i s : E s s= ( 2 ∗ z e t a /Wn) Ess =(2* zeta / Wn ) ; // s t e a d y s t a t e e r r o r disp ( ” p a r t ( a ) : ” ) disp ( Wn , ” n a t u r a l f r e q u e n c y=” ) ; disp ( zeta , ” damping r a t i o =” ) ; disp ( Wd , ” d a m p e d f r e q u e n c y o f o s c i l l a t i o n=” ) ; 174
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
disp ( Mp , ”% max . p e a k o v e r s h o o t=” ) ; disp ( Ess , ” s t e a d y s t a t e e r r o r=” ) ; // i f damping r a t i o i s i n c r e a s e d from 0 . 5 t o 0 . 7 5 by i n c o r p o r a t i n g tachometer feedback zeta =0.75; H1 = sym ( ’ s ∗Kt ’ ) // t a c h o m e t e r f e e d b a c k CL1 = G /(1+ G * H1 ) ; CL1 = simple ( CL1 ) ; CL2 = CL1 /(1+ H * CL1 ) ; CL2 = simple ( CL2 ) ; disp ( CL2 , ”C( s ) /R( s )=” ) ; Wn = sqrt (25) ; // 2∗ z e t a ∗Wn=25∗Kt +5; Kt =(2* zeta * Wn -5) /25; // t a c h o m e t e r g a i n Mp1 = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; // % peak overshoot disp ( ” A f t e r a p p l y i n g t a c h o m e t e r f e e d b a c k : ” ) disp ( Kt , ” t a c h o m e t e r g a i n=” ) ; disp ( Mp1 , ” % p e a k o v e r s h o o t=” ) ;
Scilab code Exa 11.16 determine Kp Kv Ka // c a p t i o n : d e t e r m i n e K p K v K a // e x a m p l e 11 1 6 // p a g e 485 s = %s ; syms t ; num =10 den = sym ( ’ s ˆ2+6∗ s +10 ’ ) ; GH = num / den ; GH = simple ( GH ) ; disp ( GH , ”G( s )H( s )=” ) ; Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r coefficient 12 disp ( Kp , ” s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t =” ) ;
1 2 3 4 5 6 7 8 9 10 11
175
13 Kv = limit ( s * GH ,s ,0) ; // s t a t i c
velocity error
coefficient 14 disp ( Kv , ” s t a t i c v e l o c i t y e r r o r c o e f f i c i e n t =” ) ; 15 Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r
coefficient 16 disp ( Ka , ” s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t =” ) ;
Scilab code Exa 11.17 determine Kp Kv Ka 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// c a p t i o n : d e t e r m i n e K p K v K a // e x a m p l e 11 1 6 // p a g e 485 s = %s ; syms t ; num = sym ( ’ 1 0 0 ∗ ( s +2) ∗ ( s +40) ’ ) ; den = sym ( ’ ( s ˆ 3 ∗ ( s ˆ2+4∗ s +200) ) ’ ) ; GH = num / den ; GH = simple ( GH ) ; disp ( GH , ”G( s )H( s )=” ) ; Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r coefficient disp ( Kp , ” s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t =” ) ; Kv = limit ( s * GH ,s ,0) ; // s t a t i c v e l o c i t y e r r o r coefficient disp ( Kv , ” s t a t i c 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 = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r coefficient disp ( Ka , ” s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t =” ) ;
Scilab code Exa 11.18 determine Kp Kv Ka 1 2
// c a p t i o n : d e t e r m i n e K p K v K a // e x a m p l e 11 1 8 176
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
// p a g e 488 s = %s ; syms t ; num = sym ( ’ 2 ∗ ( s ˆ2+3∗ s +20) ’ ) ; den = sym ( ’ s ∗ ( s +2) ∗ ( s ˆ2+4∗ s +10) ’ ) ; GH = num / den ; GH = simple ( GH ) ; disp ( GH , ”G( s )H( s )=” ) ; input1 =5; Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r coefficient Ess =5*(1/(1+ Kp ) ) ; // s t e a d y s t a t e e r r o r e =(1/( %inf +1) ) ; e =0; Ess = e ; disp ( Kp , ” s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t =” ) ; disp ( Ess , ” s t e a d y s t a t e e r r o r=” ) ; input2 =4* t ; Kv = limit ( s * GH ,s ,0) ; // s t a t i c v e l o c i t y e r r o r coefficient Ess =(1/ Kv ) *4; // s t e a d y s t a t e e r r o r disp ( Kv , ” s t a t i c 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 ( Ess , ” s t e a d y s t a t e e r r o r=” ) ; input3 =(4* t ^2) /2; Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r coefficient Ess =(1/ Ka ) *4; // s t e a d y s t a t e e r r o r disp ( Ka , ” s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t =” ) ; disp ( ” s t e a d y s t a t e e r r o r=” ) ; disp ( ” i n f i n i t y ” )
Scilab code Exa 11.19 determine transfer function 1 2
// C a p t i o n : d e t e r m i n e t r a n s f e r f u n c t i o n // e x a m p l e 11 1 9 177
3 // p a g e 489 4 syms t ; 5 s = %s ; 6 c =0.5+(1.25* exp ( - t ) ) -(1.75* exp ( -12* t ) ) ; 7 C = laplace (c ,t , s ) ; 8 disp (C , ”C( s )=” )
Scilab code Exa 11.21.a roots of characterstics equation 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// C a p t i o n : r o o t s o f c h a r a c t e r s t i c s e q u a t i o n // e x a m p l e 11 2 1 a // p a g e 491 s = %s ; num =210 den = sym ( ’ s ∗ ( s +2) ∗ ( s ˆ2+12∗ s +6) ’ ) ; G = num / den ; G = simple ( G ) ; H =1; n1 = poly ([210] , ’ s ’ ,” c o e f f ” ) ; d1 = poly ([210 192 390 44 1] , ’ s ’ ,” c o e f f ” ) ; CL = syslin ( ’ c ’ ,n1 , d1 ) disp ( CL , ”C( s ) /R( s )=” ) b = denom ( CL ) disp (0 , ”=” ,b , ” t h e c h a r . eq i s : ” ,) r = roots ( b ) ; disp (r , ” r o o t s o f c h a r . eq . a r e=” ) ;
Scilab code Exa 11.21.b bode plot 1 2
// C a p t i o n : b o d e p l o t // e x a m p l e 11 2 1 b 178
Figure 11.2: bode plot
179
3 4 5 6 7 8 9 10 11 12 13 14 15 16
// p a g e 491 s = %s ; num =210 den =( s *( s +2) *( s ^2+12* s +6) ) ; g = num / den ; G = syslin ( ’ c ’ ,g ) fmin =0.01; fmax =100; bode (G , fmin , fmax ) show_margins ( G ) gm = g_margin ( G ) pm = p_margin ( G ) disp ( gm , ” g a i n m a r g i n=” ) ; disp ( pm , ” p h a s e m a r g i n=” ) ;
Scilab code Exa 11.22 gain margin and phase margin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// c a p t i o n : g a i n m a r g i n a n d p h a s e m a r g i n // e x a m p l e 11 2 2 // p a g e 493 s = %s ; g =((2*( s +0.25) ) /( s ^2*( s +1) *( s +0.5) ) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.1; fmax =100; bode (G , fmin , fmax ) [ gm , freqGM ]= g_margin ( G ) ; [ pm , freqPM ]= p_margin ( G ) ; show_margins ( G ) ; disp ( gm , ” g a i n m a r g i n=” ) ; disp (( freqGM *2* %pi ) ,” g a i n m a r g i n f r e q=” ) ; disp ( pm , ” p h a s e m a r g i n=” ) ; disp (( freqPM *2* %pi ) ,” p h a s e m a r g i n f r e q=” ) ; 180
Figure 11.3: gain margin and phase margin
181
Figure 11.4: stability using Nyquist criterion 17 18
show_margins ( G ) ; disp ( ” s i n c e g a i n and p h a s e m a r g i n a r e b o t h n e g a t i v e so system i s u n s t a b l e ”)
Scilab code Exa 11.24 stability using Nyquist criterion 1 // c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n 2 // e x a m p l e 11 2 4 3 // p a g e 496 4 clf ; 5 s = %s ;
182
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
s1 = - s ; g =50/(( s +1) *( s +2) ) ; g1 =50/(( s1 +1) *( s1 +2) ) ; GH = syslin ( ’ c ’ ,g ) GH1 = syslin ( ’ c ’ , g1 ) nyquist ( GH ) ; nyquist ( GH1 ) ; mtlb_axis ([ -5 30 -20 20]) ; xtitle ( ’ N y q u i s t p l o t o f 5 0 / ( ( s +1) ∗ ( s +2) ) ’ ) figure ; show_margins ( GH , ’ n y q u i s t ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s n o t e n c i r c l e d by N y q u i s t p l o t , s o N=0 and P=0( g i v e n ) ” ) N =0; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) p l o t P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s s t a b l e . ”)
Scilab code Exa 11.25 stability using Nyquist criterion 1 2 3 4 5 6 7 8
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 11 2 5 // p a g e 497 clf () ; s = %s ; s1 = - s ; g =(2.2/( s *( s +1) *( s ^2+2* s +2) ) ) g1 =(2.2/( s1 *( s1 +1) *( s1 ^2+2* s1 +2) ) ) 183
Figure 11.5: stability using Nyquist criterion
184
Figure 11.6: stability using Nyquist criterion 9 GH = syslin ( ’ c ’ ,g ) ; 10 GH1 = syslin ( ’ c ’ , g1 ) ; 11 nyquist ( GH ) ; 12 nyquist ( GH1 ) ; 13 mtlb_axis ([ -2.5 0.2 -75 75]) ; 14 disp ( ” a s t h e n y q u i s t p l o t p a s s e s t h r o u g h t h e p o i n t
−1+%i ∗ 0 , s o s y s t e m i s m a r g i n a l l y s t a b l e and output r e p r e s e n t s s u s t a i n e d o s c i l l a t i o n s . ”)
Scilab code Exa 11.26.i stability using Nyquist criterion
185
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 11 2 6 i // p a g e 497 clf () ; s = %s ; s1 = - s ; disp ( ” f o r K=10” ) g =(10*( s -1) ) /(( s +2) *( s +3) ) ; g1 =(10*( s1 -1) ) /(( s1 +2) *( s1 +3) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; mtlb_axis ([ -2 2 -2.5 2.5]) ; xtitle ( ’ N y q u i s t p l o t o f ( 1 0 ∗ ( s −1) ) / ( ( s +2) ∗ ( s +3) ) ; ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s encircled c l o c k w i s e by N y q u i s t p l o t , s o N=−1 and P=1( g i v e n ) ”) N = -1; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) plot anticlockwise P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=1 , t h e r e i s one r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s u n s t a b l e . ”)
Scilab code Exa 11.26.ii stability using Nyquist criterion 1 2
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 11 2 6 i i 186
Figure 11.7: stability using Nyquist criterion
187
3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21
// p a g e 497 clf () ; s = %s ; s1 = - s ; disp ( ” f o r K=4” ) g =(4*( s -1) ) /(( s +2) *( s +3) ) ; g1 =(4*( s1 -1) ) /(( s1 +2) *( s1 +3) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; mtlb_axis ([ -1 1 -1 1]) ; xtitle ( ’ N y q u i s t p l o t o f ( 2 . 5 ∗ ( s +1) ) / ( ( s + 0 . 5 ) ∗ ( s −2) ) ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s encircled a n t i c l o c k w i s e by N y q u i s t p l o t , s o N=1 and P=1( given ) ”) N =0; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) p l o t anticlockwise P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s s t a b l e . ”)
Scilab code Exa 11.27 root locus 1 2 3
// c a p t i o n : r o o t l o c u s // e x a m p l e 11 2 7 // p a g e 499 188
Figure 11.8: root locus
189
Figure 11.9: root locus 4 5 6 7 8 9
s = %s ; clf () ; g =(( s ^2+4) /( s *( s +1) ) ) ; G = syslin ( ’ c ’ ,g ) evans (g ,200) xgrid (2)
Scilab code Exa 11.28 root locus 1 2
// c a p t i o n : r o o t l o c u s // e x a m p l e 11 2 8 190
Figure 11.10: root locus 3 4 5 6 7 8 9
// p a g e 501 s = %s ; clf () ; g =1/( s *( s +2) *( s ^2+2* s +2) ) ; G = syslin ( ’ c ’ ,g ) evans (g ,200) xgrid (2)
Scilab code Exa 11.29 root locus 1
// c a p t i o n : r o o t l o c u s 191
Figure 11.11: root locus 2 // e x a m p l e 11 2 9 3 // p a g e 502 4 s = %s ; 5 g =1/( s *( s +1) *( s +3) ) ; 6 G = syslin ( ’ c ’ ,g ) 7 evans (g ,200) 8 xgrid (2)
Scilab code Exa 11.30 root locus 1
// c a p t i o n : r o o t l o c u s 192
2 // e x a m p l e 11 3 0 3 // p a g e 503 4 s = %s ; 5 g =1/( s *( s +4) *( s ^2+4* s +13) ) ; 6 G = syslin ( ’ c ’ ,g ) 7 evans (g ,200) 8 xgrid (2)
Scilab code Exa 11.31 design lead compensator 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// c a p t i o n : d e s i g n l e a d c o m p e n s a t o r // e x a m p l e 11 3 1 // p a g e 339 s = %s ; clf () ; syms K ; g =( K /( s *(1+0.2* s ) ) ) ; Kv = limit ( s *g ,s ,0) ; // s t a t i c v e l o c i t y e r r o r coefficient // s i n c e Kv=10 K =10; g =(10/( s *(1+0.2* s ) ) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.01; fmax =100; bode (G , fmin , fmax ) show_margins ( G ) [ gm , freqGM ]= g_margin ( G ) ; [ pm , freqPM ]= p_margin ( G ) ; disp ( gm , ” g a i n m a r g i n=” ) ; disp (( freqGM *2* %pi ) ,” g a i n m a r g i n f r e q=” ) ; disp ( pm , ” p h a s e m a r g i n=” ) ; disp (( freqPM *2* %pi ) ,” p h a s e m a r g i n f r e q o r g a i n c r o s s o v e r f r e q u e n c y =” ) ; 193
23 24
25 26 27 28 29 30 31 32 33 34 35 36 37 38
disp ( ” s i n c e P .M i s l e s s t h a n d e s i r e d v a l u e s o we need phase l e a d network ”) disp ( ” s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t w=5.5 r a d / s e c and p o l e a t w=13.8 r a d / s e c and applying gain to account a t t e n u a t i n f a c t o r . ”) gc =(1+0.18* s ) /(1+0.072* s ) Gc = syslin ( ’ c ’ , gc ) disp ( Gc , ” t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r=” ) ; G1 = G * Gc disp ( G1 , ” o v e r a l l t r a n s f e r f u n c t i o n=” ) ; fmin =0.01; fmax =100; figure () ; bode ( G1 , fmin , fmax ) ; show_margins ( G1 ) [ gm , freqGM ]= g_margin ( G1 ) ; [ pm , freqPM ]= p_margin ( G1 ) ; disp ( pm , ” p h a s e m a r g i n o f c o m p e n s a t e d s y s t e m=” ) ; disp (( freqPM *2* %pi ) ,” g a i n c r o s s o v e r f r e q u e n c y =” ) ;
Scilab code Exa 11.32 nicholas chart 1 2 3 4 5 6 7
// c a p t i o n : n i c h o l a s c h a r t // e x a m p l e 11 3 2 // p a g e 507 s = %s ; num =20; den =( s *( s +2) *( s +5) ) g = num / den 194
Figure 11.12: design lead compensator
195
Figure 11.13: design lead compensator
196
Figure 11.14: nicholas chart
197
8 G = syslin ( ’ c ’ ,g ) 9 fmin =0.01 10 fmax =100 11 black (G , fmin , fmax ) 12 xgrid (2)
Scilab code Exa 11.33 obtain state matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 11 3 3 // p a g e 509 s = %s ; g =( s +2) /(( s +1) *( s +3) ) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 11.34 obtain state matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 11 3 4 // p a g e 509 s = %s ; g =( s ^2+ s +2) /( s ^3+9* s ^2+26* s +24) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” ) 198
Scilab code Exa 11.35 obtain state matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 11 3 5 // p a g e 510 s = %s ; g =1/( s ^2+2* s +5) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 11.36 state transition matrix 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// c a p t i o n : s t a t e t r a n s i t i o n m a t r i x // e x a m p l e 11 3 6 // p a g e 511 s = %s ; syms t A =[1 4; -2 -5] [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f s I −A r = inv ( p ) // i n v e r s e o f s I −A // f o r c a l c u l a t i n g s t a t e t r a n s i s t i o n m a t r i x ip =[0 0;0 0] i =1; j =1; for i =1:2 for j =1:2 199
16 ip (i , j ) = ilaplace ( r (i , j ) ,s , t ) ; 17 j = j +1; 18 end 19 i = i +1; 20 end 21 disp ( ip , ” s t a t e t r a n s i s t i o n m a t r i x , i p ( t )=” ) ;
Scilab code Exa 11.37 check for contrallability of system // c a p t i o n : c h e c k f o r c o n t r a l l a b i l i t y o f s y s t e m // e x a m p l e 11 3 7 // p a g e 512 A =[1 1;0 -1] B =[1;0] P = cont_mat (A , B ) ; disp (P , ” C o n t r o l l a b i l i t y M a t r i x=” ) ; d = determ ( P ) if d ==0 printf ( ” m a t r i x i s s i n g u l a r , s o s y s t e m i s u n c o n t r o l l a b l e ”); 11 else 12 printf ( ” s y s t e m i s c o n t r o l l a b l e ” ) ; 13 end ; 1 2 3 4 5 6 7 8 9 10
Scilab code Exa 11.38 determine transfer function 1 2 3 4 5 6 7
// c a p t i o n : d e t e r m i n e t r a n s f e r f u n c t i o n // e x a m p l e 11 3 8 // p a g e 513 s = %s A =[ -5 1; -6 0] B =[1;2] C =[2 1] 200
8 9 10 11 12 13
D =0; [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x r = inv ( p ) // i n v e r s e o f s I −A G = C * r * B + D // t r a n s f e r m a t r i x disp (G , ” t r a n s f e r m a t r i x=” )
Scilab code Exa 11.39 determine transfer matrix 1 2 3 4 5 6 7 8 9 10 11 12 13
// c a p t i o n : d e t e r m i n e t r a n s f e r m a t r i x // e x a m p l e 11 3 9 // p a g e 513 s = %s A =[0 1; -6 -5] B =[0;1] C =[2 1] D =0; [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x r = inv ( p ) // i n v e r s e o f s I −A G = C * r * B + D // t r a n s f e r m a t r i x disp (G , ” t r a n s f e r m a t r i x=” )
201
Chapter 12 CLASSIFIED SOLVED EXAMPLES
Scilab code Exa 12.1 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 1 2 . 1 // p a g e 515 // we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w graph approach syms G H ; // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 =1* G *1 P2 =1; L1 = - G ; L2 = - G * H ; L3 = G * H ; D1 =1; D2 =1; D =1 -( L1 + L2 + L3 ) ; D = simple ( D ) 202
17 Y =( P1 * D1 + P2 * D2 ) / D ; 18 Y = simple ( Y ) ; 19 disp (Y , ”C( s ) /R( s )=” ) ;
Scilab code Exa 12.2 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 1 2 . 2 // p a g e 516 // we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w graph approach syms G1 G2 G3 G4 // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 ; P2 = G2 ; P3 = - G1 * G2 * G3 ; P4 = G1 * G2 * G4 ; L1 = - G1 * G2 * G3 * G4 ; D1 =1; D2 =1; D3 =1; D4 =1; D =1 -( L1 ) ; Y =( P1 * D1 + P2 * D2 + P3 * D3 + P4 * D4 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” ) ;
Scilab code Exa 12.3 Transfer Function 1
// C a p t i o n : t r a n s f e r f u n c t i o n 203
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// e x a m p l e 1 2 . 3 // p a g e 517 // we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w graph approach syms G1 G2 G3 G4 H2 H1 H3 // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G2 * G4 ; P2 = G2 * G3 * G4 ; P3 = G1 * G3 * G4 ; L1 = - G4 * H1 ; L2 = - G3 * G4 * H1 * H2 ; L3 = - G1 * G3 * G4 * H1 * H2 * H3 D1 =1; D2 =1; D3 =1; D =1 -( L1 + L2 + L3 ) ; Y =( P1 * D1 + P2 * D2 + P3 * D3 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” ) ;
Scilab code Exa 12.4 Transfer Function // C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 1 2 . 4 // p a g e 518 // we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w graph approach 5 syms G1 G2 6 // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on 7 // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D 1 2 3 4
204
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
P1 = G1 ; P2 = G2 ; P3 = G1 * G2 ; P4 = G1 * G2 ; L1 = - G1 ; L2 = - G2 ; L3 = G1 * G2 ; L4 = - G1 * G2 ; L5 = - G1 * G2 ; D1 =1; D2 =1; D3 =1; D4 =1; D =1 -( L1 + L2 + L3 + L4 + L5 ) ; Y =( P1 * D1 + P2 * D2 + P3 * D3 + P4 * D4 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” ) ;
Scilab code Exa 12.5 Transfer Function 1 2 3 4 5 6 7 8 9 10 11 12
// C a p t i o n : t r a n s f e r f u n c t i o n // e x a m p l e 1 2 . 5 // p a g e 518 // we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w graph approach syms G1 G2 G3 G4 G5 H1 H2 // f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p by L1 , L2 and s o on // p a t h f a c t o r by D1 , D2 and s o on and g r a p h d e t e r m i n a n t by D P1 = G1 * G4 * G5 ; P2 = G1 * G2 * G3 * G5 ; L1 = - G3 * G5 ; L2 = - G3 * G5 * H2 ; L3 = - G1 * G4 * G5 * H1 ; 205
13 14 15 16 17 18 19
L4 = - G1 * G2 * G3 * G5 * H1 ; D1 =1; D2 =1; D =1 -( L1 + L2 + L3 + L4 ) ; Y =( P1 * D1 + P2 * D2 ) / D ; Y = simple ( Y ) ; disp (Y , ”C( s ) /R( s )=” ) ;
Scilab code Exa 12.7 Determine Peak Time and Peak Overshoot 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
// C a p t i o n : d e t e r m i n e p e a k t i m e a n d p e a k o v e r s h o o t // e x a m p l e 1 2 . 7 // p a g e 520 s = %s ; syms t ; G = sym ( ’ ( s +2) / ( s ∗ ( s +1) ) ’ ) //G( s ) H =1; CL = G /(1+ G * H ) ; disp ( CL , ”C( s ) /R( s )=” ) ; // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ; d = CL *(1/ s ) ; a=s*d; disp (d , ”C( s )=” ) ; c = ilaplace (d ,s , t ) ; disp (c , ” c ( t )=” ) ; // f o r peak t i m e we g e t t p =3∗%pi /4 tp =3* %pi /4 Cmax =1 -( exp ( - tp ) * cos ( tp ) ) ; Css = limit (a ,s ,0) ; disp ( Css , ” Css=” ) ; Mp =(( Cmax - Css ) / Css ) *100 Mp = float ( Mp ) disp ( Mp , ” p e a k o v e r s h o o t=” )
206
Scilab code Exa 12.8 Time Response and Peak Overshoot 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// C a p t i o n : t i m e r e s p o n s e a n d p e a k o v e r s h o o t // e x a m p l e 1 2 . 8 // p a g e 521 s = %s ; syms t ; num = sym ( ’ 8 ∗ ( s +1) ’ ) ; den = sym ( ’ ( s ˆ2+2∗ s +2) ’ ) ; CL = num / den ; disp ( CL , ”C( s ) /R( s )=” ) ; // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ; d = CL *(1/ s ) ; disp (d , ”C( s )=” ) ; c = ilaplace (d ,s , t ) ; disp (c , ” c ( t )=” ) ; // f o r peak t i m e we g e t t p=%pi /2 t = %pi /2 a=s*d; a = simple ( a ) Cmax =4*(1+1.414* exp ( - t ) * sin (t -( %pi /4) ) ) Css = limit (a ,s ,0) ; disp ( Css , ” Css=” ) ; Mp =(( Cmax - Css ) / Css ) *100 Mp = float ( Mp ) disp ( Mp , ” p e a k o v e r s h o o t=” )
Scilab code Exa 12.9 Determine Peak Overshoot 1 2 3
// C a p t i o n : d e t e r m i n e p e a k o v e r s h o o t // e x a m p l e 1 2 . 9 // p a g e 523 207
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
s = %s ; syms t K ; CL = sym ( ’ ( s +1) / ( s ˆ2+2∗ s +5) ’ ) ; CL = K * CL ; disp ( CL , ”C( s ) /R( s )=” ) // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ; d = CL *(1/ s ) Css = limit ( s *d ,s ,0) disp ( Css , ” Css=” ) ; // s i n c e Css =0.8 ( g i v e n ) K =0.8*5; CL = eval ( CL ) ; disp ( CL , ”C( s ) /R( s )=” ) ; // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ; d = CL *(1/ s ) disp (d , ”C( s )=” ) ; c = ilaplace (d ,s , t ) ; disp (c , ” c ( t )=” ) ; // f o r peak t i m e we g e t t p = 0 . 7 8 5 t =0.785 a=s*d; a = simple ( a ) Cmax =(4/5) *(1 - exp ( - t ) * cos (2* %pi /4) + exp ( - t ) *2* sin (2* %pi /4) ) Css = limit (a ,s ,0) disp ( Css , ” Css=” ) ; Mp =(( Cmax - Css ) / Css ) *100 Mp = float ( Mp ) disp ( Mp , ” p e a k o v e r s h o o t=” )
Scilab code Exa 12.10 Determine Unit Step Response 1 2 3
// C a p t i o n : d e t e r m i n e u n i t s t e p r e s p o n s e // e x a m p l e 1 2 . 1 0 // p a g e 524 208
4 5 6 7 8 9 10 11 12
s = %s ; syms t ; CL = sym ( ’ 1 / ( ( s +1) ∗ ( s ˆ2+1) ) ’ ) disp ( CL , ”C( s ) /R( s )=” ) ; // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ; d = CL *(1/ s ) ; a=s*d; c = ilaplace (d ,s , t ) ; disp (c , ” c ( t )=” ) ;
Scilab code Exa 12.11 Determine Unit Step and Unit Impulse Response 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// C a p t i o n : determine unit step and unit impulse response // e x a m p l e 1 2 . 1 1 // p a g e 524 s = %s ; syms t ; G = sym ( ’ 8 / ( s +1) ’ ) ; H = sym ( ’ ( 1 / 2 ∗ s ) ’ ) ; CL = G /(1+ G * H ) ; disp ( CL , ”C( s ) /R( s )=” ) ; // f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ; d = CL *(1/ s ) ; disp (d , ”C( s )=” ) ; c = ilaplace (d ,s , t ) ; disp (c , ” u n i t s t e p r e s p o n s e , c ( t )=” ) ; // f o r u n i t i m p u l s e r e s p o n s e R( s ) =1; e = CL *(1) ; disp (e , ”C( s )=” ) ; ct = ilaplace (e ,s , t ) ; disp ( ct , ” u n i t i m p u l s e r e s p o n s e , c ( t )=” ) ;
209
Scilab code Exa 12.12 Determine Wn Wd zeta and steady state error 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
// c a p t i o n : determine Wn ,Wd, zeta and steady state error // e x a m p l e 12 1 2 // p a g e 526 s = %s ; G = sym ( ’ 2 0 / ( s ∗ ( s ˆ2+6∗ s +6) ) ’ ) ; H =0.25; CL = G /(1+ G * H ) ; CL = simple ( CL ) ; disp ( CL , ”C( s ) /R( s )=” ) ; printf ( ” t h e c h a r . eq i s : ” ) disp ( ” s ˆ2+ s +1=0” ) Wn = sqrt (1) // n a t u r a l f r e q u e n c y // 2∗ z e t a ∗Wn=1 zeta =1/(2* Wn ) ; // damping r a t i o d = zeta * Wn ; // d a m p i n g f a c t o r z = sqrt (1 - zeta ^2) ; Wd = Wn * z ; // d a m p e d f r e q u e n c y o f o s c i l l a t i o n Mp = exp (( - zeta * %pi ) / z ) *100; // % max . p e a k o v e r s h o o t ts =4/( zeta * Wn ) ; // s e t t l i n g t i m e tp = %pi /( Wn * sqrt (1 - zeta ^2) ) ; // p e a k t i m e tu =2* %pi /( Wn * sqrt (1 - zeta ^2) ) ; // f i r s t u n d e r s h o o t ti = tu - tp ; // t i m e i n t e r v a l b e t w e e n max . and min . values disp ( Wn , ” n a t u r a l f r e q u e n c y=” ) ; disp ( zeta , ” damping r a t i o =” ) ; disp ( Wd , ” d a m p e d f r e q u e n c y o f o s c i l l a t i o n=” ) ; disp ( Mp , ”% max . p e a k o v e r s h o o t=” ) ; disp ( ts , ” s e t t l i n g t i m e =” ) ; disp ( tp , ” p e a k t i m e=” ) ; disp ( ti , ” t i m e i n t e r v a l b e t w e e n m a x a n d m i n v a l u e s=” ) ;
210
Scilab code Exa 12.13 Determine Wn Wd zeta and steady state error 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// c a p t i o n : determine Wn ,Wd, zeta and steady state error // e x a m p l e 12 1 3 // p a g e 527 syms Kp K Kd T s = %s ; // e x e c s e r i e s . s c e ; // e x e c p a r a l l e l . s c e ; a =( Kp + s * Kd ) * K b =1/( s *( s * T +1) ) G = series (a , b ) H =1; er =1/(1+ G * H ) disp ( er , ”E( s ) /R( s )=” ) ; R =1/ s ^2 E = R * er ess = limit ( s *E ,s ,0) disp ( ess , ” s t e a d y s t a t e e r r o r , e s s=” )
Scilab code Exa 12.15 Stability Using Routh Hurwitz Criterion 1 2 3 4 5 6 7 8 9 10 11 12
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 1 2 . 1 5 // p a g e 529 s = %s ; syms K G = sym ( ’K/ ( s ∗ ( s ˆ2+ s +1) ∗ ( s +5) ’ ) ; H =1; CH =( s *( s ^2+ s +1) *( s +5) + K ) disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; 211
13 14 15 16 17 18 19 20 21 22 23 24 25
c3 = coeffs ( CH , ’ s ’ ,3) ; c4 = coeffs ( CH , ’ s ’ ,4) ; b =[ c0 c1 c2 c3 c4 ] routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] routh =[ routh ; - det ( routh (1:2 ,1:2) / routh (2 ,1) ) ,K ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0 ,0] routh =[ routh ;K ,0 ,0] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be s t a b l e : ” ) ; disp ( ” ( ( 5 . 1 ∗ 5 − 6 ∗K) / 5 . 1 ) >0 and K>0” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”0
Scilab code Exa 12.16 Stability Using Routh Hurwitz Criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 1 2 . 1 6 // p a g e 530 s = %s ; syms K CH = s ^4+2* s ^3+10* s ^2+( K -10) * s + K disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; c4 = coeffs ( CH , ’ s ’ ,4) ; b =[ c0 c1 c2 c3 c4 ] routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] routh =[ routh ; - det ( routh (1:2 ,1:2) / routh (2 ,1) ) ,K ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0 ,0] 212
// r o u t h =[ r o u t h ; K, 0 , 0 ] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be s t a b l e , f o l l o w i n g c o n d i t i o n s h o u l d be s a t i s f i e d ” ) ; 23 disp ( ”K<30 ,K<22.9 and K> 1 3 . 1 ,K>0” ) 24 disp ( ” which g i v e s , ” ) 25 disp ( ” 13.1
Scilab code Exa 12.17 Stability Using Routh Hurwitz Criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 1 2 . 1 7 // p a g e 530 s = %s ; syms K G = sym ( ’K/ ( ( s ˆ3+3∗ s +2) ∗ ( s ˆ2+6∗ s +24) ) ’ ) ; H =1; CH =(( s ^3+3* s +2) *( s ^2+6* s +24) + K ) disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; c4 = coeffs ( CH , ’ s ’ ,4) ; b =[ c0 c1 c2 c3 c4 ] routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh (1 ,3) ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0 ,0] // r o u t h =[ r o u t h ; K, 0 , 0 ] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be s t a b l e , f o l l o w i n g 213
c o n d i t i o n s h o u l d be s a t i s f i e d ” ) ; 25 disp ( ” 7 8 . 8 4 − 0 . 2 5 9K>0” ) 26 disp ( ” which g i v e s l i m i t i n g v a l u e o f K” ) 27 disp ( ”K< 2 8 8 . 9 ” ) ;
Scilab code Exa 12.18 Stability Using Routh Hurwitz Criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
23
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 1 2 . 1 8 // p a g e 531 s = %s ; A = s ^5+ s ^4+4* s ^3+4* s ^2+ s +1; b = coeff ( A ) n = length ( b ) routh =[ b ([6 4 2]) ; b ([5 3 1]) ] routh1 = routh ; c =[ routh (1 ,1) , routh (1 ,3) ; routh (2 ,1) , routh (2 ,3) ] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) ,- det ( c ) / routh (2 ,1) ,0] disp ( ” s i n c e a l l e l e m e n t s o f t h i r d row a r e z e r o , s o we make a u x i l i a r y e q u a t i o n ” ) A = sym ( ’ s ˆ4+4∗ s ˆ2+1 ’ ) // a u x i l i a r y e q u a t i o n B = diff (A , s ) routh =[ routh1 ;4 ,8 ,0] d =[ routh (2 ,1) , routh (2 ,3) ; routh (3 ,1) , routh (3 ,3) ] routh =[ routh ; - det ( routh (2:3 ,1:2) ) / routh (3 ,1) ,- det ( d ) / routh (3 ,1) ,0] routh2 = routh routh =[ routh ; - det ( routh (3:4 ,1:2) ) / routh (4 ,1) ,0 ,0] routh =[ routh ; - det ( routh (4:5 ,1:2) ) / routh (5 ,1) ,0 ,0]; disp ( routh , ” r o u t h=” ) disp ( ” s t a b i l i t y i s examined a s b e l o w . s i n c e r o o t s o f a u x i l i a r y eq a r e a l s o r o o t s o f c h a r a c t e r s t i c s eq ” ) A = s ^4+4* s ^2+1 214
24 b = roots ( A ) 25 disp ( ” s i n c e t h e e q u a t i o n h a s non r e p e a t i n g
s plane imaginary a x i s . hence system unstable ” )
r o o t s on
are
Scilab code Exa 12.19 Stability Using Routh Hurwitz Criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// c a p t i o n : s t a b i l i t y u s i n g R o u t h − h u r w i t z c r i t e r i o n // e x a m p l e 1 2 . 1 9 // p a g e 531 s = %s ; A = s ^5+ s ^4+4* s ^3+4* s ^2+4* s +4; b = coeff ( A ) n = length ( b ) routh =[ b ([6 ,4 ,2]) ; b ([5 3 1]) ] routh1 = routh ; c =[ routh (1 ,1) , routh (1 ,3) ; routh (2 ,1) , routh (2 ,3) ] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) ,- det ( c ) / routh (2 ,1) ,0] disp ( ” s i n c e a l l e l e m e n t s o f t h i r d row a r e z e r o , s o we make a u x i l i a r y e q u a t i o n ” ) A = sym ( ’ s ˆ4+4∗ s ˆ2+4 ’ ) // a u x i l i a r y e q u a t i o n B = diff (A , s ) routh =[ routh1 ;4 ,8 ,0] d =[ routh (2 ,1) , routh (2 ,3) ; routh (3 ,1) , routh (3 ,3) ] routh =[ routh ; - det ( routh (2:3 ,1:2) ) / routh (3 ,1) ,- det ( d ) / routh (3 ,1) ,0] routh2 = routh routh =[ routh ; - det ( routh (3:4 ,1:2) ) / routh (4 ,1) ,0 ,0] disp ( ” s i n c e a l l e l e m e n t s o f f i f t h row a r e z e r o , s o we make a u x i l i a r y e q u a t i o n ” ) A = sym ( ’ 2∗ s ˆ2+4 ’ ) // a u x i l i a r y e q u a t i o n B = diff (A , s ) routh =[ routh2 ;4 ,0 ,0] routh =[ routh ; - det ( routh (4:5 ,1:2) ) / routh (5 ,1) ,0 ,0]; 215
disp ( routh , ” r o u t h=” ) disp ( ” s t a b i l i t y i s examined a s b e l o w . s i n c e r o o t s o f a u x i l i a r y eq a r e a l s o r o o t s o f c h a r a c t e r s t i c s eq ” ) 27 A = s ^4+4* s ^2+4 28 b = roots ( A ) 29 disp ( ” s i n c e t h e e q u a t i o n h a s m u l t i p l e r o o t s on s plane imaginary a x i s . hence system are u n s t a b l e ” ) 25 26
Scilab code Exa 12.21 Determine Frequency of Oscillations 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
// c a p t i o n : d e t e r m i n e f r e q u e n c y o f o s c i l l a t i o n s // e x a m p l e 1 2 . 2 1 // p a g e 533 s = %s ; syms K G = sym ( ’K∗ ( s ∗ ( 2 ∗ s +1) ) / ( s ˆ3+3∗ s +20) ’ ) ; H =1; CH =(( s ^3+3* s +20) + K *( s *(2* s +1) ) ) disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] routh =[ b ([4 ,2]) ; b ([3 ,1]) ] routh =[ routh ; - det ( routh (1:2 ,1:2) / routh (2 ,1) ) ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0] disp ( routh , ” r o u t h=” ) disp ( ” f o r s u s t a i n e d o s c i l l a t i o n s : ” ) ; disp ( ” 2∗Kˆ2+6∗K−20=0” ) 216
Figure 12.1: Stability Using Nyquist Criterion 24 25 26 27 28 29 30 31
disp ( ” which g i v e s K” ) disp ( ”K=2” ) ; disp ( ” f r e q o f o s c i l l a t i o n s i s c a l c u l a t e d by s o l v i n g e q u a t i o n f o r m e d by s ˆ2 row o f t h e r o u t h t a b l e ” ) K =2 k =2 A =2* k * s ^2+20 r = roots ( A ) disp ( %i * r (2) ,” f r e q u e n c y o f o s c i l l a t i o n s =” )
Scilab code Exa 12.23.i Stability Using Nyquist Criterion 217
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 12 2 3 i // p a g e 535 clf () ; s = %s ; s1 = - s ; disp ( ” f o r K=0.1 ” ) g =(0.1*( s +10) *( s +40) ) /( s *( s +1) *( s +4) ) ; g1 =(0.1*( s1 +10) *( s1 +40) ) /( s1 *( s1 +1) *( s1 +4) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; // m t l b a x i s ( [ − 1 . 5 0 . 2 −0.3 0 . 3 ] ) ; xtitle ( ’ N y q u i s t p l o t o f ( 0 . 1 ∗ ( s +10) ∗ ( s +40) ) / ( s ∗ ( s +1) ∗ ( s +4) ) ’ ) figure ; show_margins ( GH , ’ n y q u i s t ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s not e n c i r c l e d c l o c k w i s e by N y q u i s t p l o t , s o N=0 and P=0” ) N =0; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) p l o t anticlockwise P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s s t a b l e . ”)
218
Figure 12.2: Stability Using Nyquist Criterion
219
Figure 12.3: Stability Using Nyquist Criterion
220
Scilab code Exa 12.23.ii Stability Using Nyquist Criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 12 2 3 i i // p a g e 535 disp ( ” f o r K=1” ) g =(0.1*( s +10) *( s +40) ) /( s *( s +1) *( s +4) ) ; g1 =(0.1*( s1 +10) *( s1 +40) ) /( s1 *( s1 +1) *( s1 +4) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; // m t l b a x i s ([ −3 0 . 5 −0.6 0 . 6 ] ) ; xtitle ( ’ N y q u i s t p l o t o f ( 0 . 1 ∗ ( s +10) ∗ ( s +40) ) / ( s ∗ ( s +1) ∗ ( s +4) ) ’ ) figure ; show_margins ( GH , ’ n y q u i s t ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s encircled twice c l o c k w i s e by N y q u i s t p l o t , s o N=2 and P=0( g i v e n ) ” ) N = -2; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) plot anticlockwise P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=2 , t h e r e a r e two r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s u n s t a b l e . ”)
221
Figure 12.4: Stability Using Nyquist Criterion
222
Figure 12.5: Stability Using Nyquist Criterion
223
Scilab code Exa 12.23.iii Stability Using Nyquist Criterion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n // e x a m p l e 12 2 3 i i i // p a g e 535 disp ( ” f o r K=10” ) g =(10*( s +10) *( s +40) ) /( s *( s +1) *( s +4) ) ; g1 =(10*( s1 +10) *( s1 +40) ) /( s1 *( s1 +1) *( s1 +4) ) ; GH = syslin ( ’ c ’ ,g ) ; GH1 = syslin ( ’ c ’ , g1 ) ; nyquist ( GH ) ; nyquist ( GH1 ) ; // m t l b a x i s ( [ − 1 . 5 0 . 2 −0.3 0 . 3 ] ) ; xtitle ( ’ N y q u i s t p l o t o f ( 0 . 1 ∗ ( s +10) ∗ ( s +40) ) / ( s ∗ ( s +1) ∗ ( s +4) ) ’ ) figure ; show_margins ( GH , ’ n y q u i s t ’ ) disp ( ” s i n c e t h e p o i n t (−1+%i0 ) i s e n c i r c l e d o n c e i n c l o c k w i s e and o n c e i n a n t i c l o c k w i s e d i r e c t i o n by N y q u i s t p l o t , s o N=0 and P=0” ) N =0; // no . o f e n c i r c l e m e n t o f −1+%i0 by G( s )H( s ) p l o t anticlockwise P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l part Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e r e a l part disp (Z , ”Z=” ) disp ( ” a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t , hence system i s s t a b l e . ”)
224
Figure 12.6: Stability Using Nyquist Criterion
225
Figure 12.7: Gain and Phase Margin
226
Scilab code Exa 12.27 Gain and Phase Margin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// c a p t i o n : g a i n a n d p h a s e m a r g i n // e x a m p l e 12 2 7 // p a g e 5 4 3 clf () ; s = %s ; s1 = - s ; disp ( ” f o r K=0.5 ” ) g =(0.5) /( s *( s +1) ^2) ; GH = syslin ( ’ c ’ ,g ) ; nyquist ( GH ) ; // m t l b a x i s ([ −5 1 −500 5 0 0 ] ) ; xtitle ( ’ N y q u i s t p l o t o f ( 2 . 5 ∗ 3 ) / ( s ∗ ( 0 . 4 ∗ s +1) ∗ ( 0 . 2 ∗ s +1) ) ’ ) pm = p_margin ( GH ) disp ( pm , ” p h a s e m a r g i n=” ) gm = g_margin ( GH ) disp ( gm , ” g a i n m a r g i n=” )
Scilab code Exa 12.33 Determine Close Loop Stability 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : d e t e r m i n e c l o s e l o o p s t a b i l i t y // e x a m p l e 12 3 3 // p a g e 550 s = %s ; g =(720*( s +1.25) ) /( s *( s +10) *( s ^2+2* s +9) ) ; G = syslin ( ’ c ’ ,g ) fmin =0.1; fmax =100; bode (G , fmin , fmax ) [ gm , freqGM ]= g_margin ( G ) ; [ pm , freqPM ]= p_margin ( G ) ; 227
Figure 12.8: Determine Close Loop Stability
228
Figure 12.9: Root Locus 12 13 14 15 16 17 18
show_margins ( G ) ; disp ( gm , ” g a i n m a r g i n=” ) ; disp (( freqGM *2* %pi ) ,” g a i n m a r g i n f r e q=” ) ; disp ( pm , ” p h a s e m a r g i n=” ) ; disp (( freqPM *2* %pi ) ,” p h a s e m a r g i n f r e q=” ) ; show_margins ( G ) ; disp ( ” s i n c e g a i n and p h a s e m a r g i n a r e b o t h n e g a t i v e so system i s u n s t a b l e ”)
Scilab code Exa 12.42 Root Locus
229
1 // c a p t i o n : r o o t l o c u s 2 // e x a m p l e 12 4 2 3 // p a g e 562 4 s = %s ; 5 syms K ; 6 GH = K /( s *( s +2) *( s +4) ) 7 // s i n c e Mp=40%, s o .4= exp (( − z e t a ∗ %pi ) / ( s q r t (1− z e t a 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 34 35 36
ˆ2) ) zeta =0.3 // from g i v e n d a t a disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +2) *( s +4) ) + K K = sym ( ’ −( s ˆ3+6∗ s ˆ2+8∗ s ) ’ ) d = diff (K , s ) e = -3* s ^2 -12* s -8 r1 = roots ( e ) disp ( r1 , ” r o o t s=” ) disp ( ” −0.842 i s b r e a k away p o i n t s i n c i t l i e s on root l o c u s ”) CH = sym ( ’ s ˆ3+6∗ s ˆ2+8∗ s+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” (48 −K) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=48” ) ; K =48; k =48 230
37 a =6* s ^2+48 // i n t e r s e c t i o n
o f root l o c u s with
imaginary plane 38 r = roots ( a ) 39 g = k /( s *( s +2) *( s +4) ) 40 G = syslin ( ’ c ’ ,g ) 41 evans (g ,8) 42 xgrid (2) 43 disp ( ” t h e l i n e t h e t a=a c o s ( z e t a ) =72.5 i n t e r s e c t s 44 45 46 47 48 49 50
l o c u s a t s a =(−0.5+ i 1 . 6 5 ) ” ) disp ( ” t h e v a l u e o f K a t s=s a i s f i n d t o be 1 4 . 8 7 f o r Mp=40%” ) K =14.87 ts =4/0.5 // t s =4/( z e t a ∗wn ) Kv = limit ( s * GH ,s ,0) Kv = eval ( Kv ) Kv = float ( Kv ) disp ( Kv , ”Kv=” ) ;
Scilab code Exa 12.43 Root Locus and Value of K 1 2 3 4 5 6 7 8 9 10 11 12 13
root
// c a p t i o n : r o o t l o c u s a n d v a l u e o f K // e x a m p l e 1 2 . 4 3 // p a g e 564 s = %s ; syms K ; GH = K /( s *( s +2) *( s ^2+2* s +2) ) disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +2) *( s ^2+2* s +2) ) + K CH = sym ( ’ s ˆ4+4∗ s ˆ3+6∗ s ˆ2+4∗ s+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; 231
Figure 12.10: Root Locus and Value of K
232
14 c3 = coeffs ( CH , ’ s ’ ,3) ; 15 c4 = coeffs ( CH , ’ s ’ ,4) ; 16 b =[ c0 c1 c2 c3 c4 ] 17 routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] 18 routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
(1 ,3) ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0 ,0] routh =[ routh ;K ,0 ,0] K = sym ( ’ s ˆ4+4∗ s ˆ3+6∗ s ˆ2+4∗ s ’ ) d = diff (K , s ) e = -(4* s ^3+12* s ^2+12* s +4) r = roots ( e ) disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” ((20 −4K) / 5 ) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=5” ) ; K =5; k =5 a =5* s ^2+5 // i n t e r s e c t i o n o f r o o t l o c u s w i t h s p l a n e r = roots ( a ) disp (r , ” i n t e r s e c t i o n p o i n t w i t h i m a g i n a r y a x i s=” ) g = k /( s *( s +2) *( s ^2+2* s +2) ) G = syslin ( ’ c ’ ,g ) evans (g ,200) xgrid (2) disp ( ” a n g l e o f d e p a r t u r e =−90 and +90” ) disp ( ” breakaway p o i n t i s −1 and +j and − j ” ) disp ( ” on s o l v i n g we f i n d K=1” )
233
Figure 12.11: Root Locus and Value of K
234
Scilab code Exa 12.44 Root Locus and Value of K 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 33 34 35
// c a p t i o n : r o o t l o c u s a n d v a l u e o f K // e x a m p l e 1 2 . 4 4 // p a g e 565 s = %s ; syms K ; GH = K /(( s ^2+2* s +5) *( s ^2+2* s +2) ) disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =(( s ^2+2* s +5) *( s ^2+2* s +2) ) + K CH = sym ( ’ ( ( s ˆ2+2∗ s +5) ∗ ( s ˆ2+2∗ s +2) )+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; c4 = coeffs ( CH , ’ s ’ ,4) ; b =[ c0 c1 c2 c3 c4 ] routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh (1 ,3) ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0 ,0] routh =[ routh ;K ,0 ,0] K = sym ( ’ −( s ˆ2+2∗ s +5) ∗ ( s ˆ2+2∗ s +2) ’ ) d = diff (K , s ) e = -(4* s ^3+12* s ^2+22* s +14) r = roots ( e ) disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” ( ( 7 . 5 ∗ 1 4 − 4 (K+10) / 7 . 5 ) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K= 1 6 . 2 5 ” ) ; K =16.25; k =16.25 a =7.5* s ^2+26.25 // i n t e r s e c t i o n o f r o o t l o c u s w i t h s 235
Figure 12.12: Root Locus and Value of K
36 37 38 39 40 41
plane r = roots ( a ) g = k /(( s ^2+2* s +5) *( s ^2+2* s +2) ) G = syslin ( ’ c ’ ,g ) evans (g ,200) xgrid (2) disp (r , ” t h e p o i n t o f i n t e r s e c t i o n o f r o o t l o c u s w i t h i m a g i n a r y a x i s =” )
Scilab code Exa 12.45 Root Locus and Value of K
236
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 33 34 35 36
// c a p t i o n : r o o t l o c u s a n d v a l u e o f K // e x a m p l e 1 2 . 4 5 // p a g e 567 s = %s ; syms K ; GH = K *( s +1) /( s *( s +2) *( s ^2+4* s +8) ) disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =(( s *( s +2) *( s ^2+4* s +8) ) ) + K *( s +1) CH = sym ( ’ ( ( s ∗ ( s +2) ∗ ( s ˆ2+4∗ s +8) ) )+K∗ ( s +1) ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; c4 = coeffs ( CH , ’ s ’ ,4) ; b =[ c0 c1 c2 c3 c4 ] routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0] routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh (1 ,3) ,0] routh (3 ,1) = simple ( routh (3 ,1) ) t = routh (2:3 ,1:2) l = simple ( - det ( t ) / t (2 ,1) ) routh =[ routh ;l ,0 ,0] routh =[ routh ;K ,0 ,0] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” (Kˆ2 −28∗K−1280)=0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=52.4 and −24.42 ” ) ; K =52.4; // c o n s i d e r i n g p o s i t i v e v a l u e k =52.4 a =((80 -52.4) /6) * s ^2+52.4 // i n t e r s e c t i o n o f r o o t l o c u s with imaginary a x i s r = roots ( a ) g = k *( s +1) /( s *( s +2) *( s ^2+4* s +8) ) G = syslin ( ’ c ’ ,g ) clf () ; evans (g ,10) 237
Figure 12.13: Root Locus and Value of K 37 38
xgrid (2) disp (r , ” t h e p o i n t o f i n t e r s e c t i o n o f r o o t l o c u s w i t h i m a g i n a r y a x i s =” )
Scilab code Exa 12.46 Root Locus and Value of K 1 // c a p t i o n : r o o t l o c u s a n d v a l u e o f K 2 // e x a m p l e 1 2 . 4 6 3 // p a g e 570 4 s = %s ; 5 syms K ;
238
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 34 35 36 37 38 39 40 41
GH = K /( s *(( s +6) ^2) ) disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *(( s +6) ^2) ) + K CH = sym ( ’ ( s ∗ ( ( s +6) ˆ 2 ) )+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0] K = sym ( ’ −( s ∗ ( ( s +6) ˆ 2 ) ) ’ ) d = diff (K , s ) e =3* s ^2+24* s +36 r1 = roots ( e ) disp ( r1 , ” r o o t s=” ) disp ( ”−2 i s b r e a k away p o i n t s i n c i t l i e s on r o o t l o c u s ”) disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” ( −(K−432) / 1 2 ) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=432 ” ) ; K =432; // c o n s i d e r i n g p o s i t i v e v a l u e k =432 a =12* s ^2+ k // i n t e r s e c t i o n o f r o o t l o c u s w i t h imaginary axis plane r = roots ( a ) g = k /( s *(( s +6) ^2) ) G = syslin ( ’ c ’ ,g ) clf () ; evans (g ,5) xgrid (2) disp (r , ” t h e p o i n t o f i n t e r s e c t i o n o f r o o t l o c u s w i t h 239
Figure 12.14: Root Locus and Value of K i m a g i n a r y a x i s =” )
Scilab code Exa 12.48 Root Locus and Value of K 1 // c a p t i o n : r o o t l o c u s a n d v a l u e o f K 2 // e x a m p l e 12 4 8 3 // p a g e 574 4 s = %s ; 5 syms K ; 6 GH = K /( s *( s +2) *( s +4) ) 7 zeta =0.277
240
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 34 35 36 37 38 39 40 41 42
// from g i v e n d a t a disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s *( s +2) *( s +4) ) + K K = sym ( ’ −( s ˆ3+6∗ s ˆ2+8∗ s ) ’ ) d = diff (K , s ) e = -3* s ^2 -12* s -8 r1 = roots ( e ) disp ( r1 , ” r o o t s=” ) disp ( ” −0.85 i s b r e a k away p o i n t s i n c i t l i e s on r o o t l o c u s ”) CH = sym ( ’ s ˆ3+6∗ s ˆ2+8∗ s+K ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) c0 = coeffs ( CH , ’ s ’ ,0) ; c1 = coeffs ( CH , ’ s ’ ,1) ; c2 = coeffs ( CH , ’ s ’ ,2) ; c3 = coeffs ( CH , ’ s ’ ,3) ; b =[ c0 c1 c2 c3 ] n =4; routh =[ b ([4 ,2]) ; b ([3 ,1]) ]; routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0] t = routh (2:3 ,1:2) routh =[ routh ; - det ( t ) / t (2 ,1) ,0] disp ( routh , ” r o u t h=” ) disp ( ” f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ” ) ; disp ( ” (48 −K) =0 ” ) ; disp ( ” which g i v e s : ” ) ; disp ( ”K=48” ) ; K =48; k =48 a =6* s ^2+48 // i n t e r s e c t i o n o f r o o t l o c u s w i t h imaginary plane r = roots ( a ) g = k /( s *( s +2) *( s +4) ) G = syslin ( ’ c ’ ,g ) evans (g ,8) xgrid (2) disp ( ” t h e l i n e t h e t a=a c o s ( z e t a ) =73.9 i n t e r s e c t s r o o t l o c u s a t s a =(−0.5+ i 1 . 6 6 ) ” ) 241
Figure 12.15: Root Locus and Value of K 43 44 45 46 47 48 49
disp ( ” t h e v a l u e o f K a t s=s a i s f i n d t o be 15 f o r z e t a =0.277 ”) K =15 k =15 disp (r , ” t h e p o i n t o f i n t e r s e c t i o n o f r o o t l o c u s w i t h i m a g i n a r y a x i s =” ) g = k /( s *( s +2) *( s +4) ) cl = g /(1+ g ) disp ( cl , ”C( s ) /R( s )=” )
Scilab code Exa 12.49 Root Locus and Value of K 242
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
// c a p t i o n : r o o t l o c u s a n d v a l u e o f K // e x a m p l e 1 2 . 4 9 // p a g e 576 s = %s ; syms K ; GH =( K *( s +4) ) /( s +2) ^2 disp ( ” t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : ” ) CH =( s +2) ^2+( K *( s +4) ) CH = sym ( ’ ( ( s +2) ˆ 2 )+K∗ ( s +4) ’ ) ; disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) K = sym ( ’ ( ( s +2) ˆ 2 / ( s +4) ) ’ ) d = diff (K , s ) e =( s +2) *( s +6) r1 = roots ( e ) disp ( r1 , ” r o o t s=” ) disp ( ”−2 and −6 i s b r e a k away p o i n t ” ) g =( s +4) /(( s +2) ^2) G = syslin ( ’ c ’ ,g ) clf () ; evans (g ,10) xgrid (2) disp ( ” f o r wd=2 r a d / s e c , t h e p o i n t on r o o t l o c u s i s s =−4+j 2 ” ) disp ( ” t h e v a l u e o f K a t s=−4+j 2 i s 4 ” ) K =4 k =4 g = k *( s +4) /(( s +2) ^2) cl = g /(1+ g ) disp ( cl , ”C( s ) /R( s )=” )
Scilab code Exa 12.50 Root Locus and Closed loop Transfer Function 1
// c a p t i o n : 243
Figure 12.16: Root Locus and Closed loop Transfer Function
244
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
root locus and close loop transfer function // e x a m p l e 1 2 . 5 0 // p a g e 578 s = %s K =8 G = K /( s *( s +4) ) H =1; GH = G * H G = syslin ( ’ c ’ ,G ) evans (G ,8) xgrid (2) CH = s *( s +4) + K disp ( ’ =0 ’ ,CH , ” c h a r a c t e r s t i c s e q , CH=” ) r = roots ( CH ) disp (r , ” t h e p o i n t a t which K=8” ) cl = G /(1+ GH ) disp ( cl , ”C( s ) /R( s )=” )
disp ( ” p a r t b ” ) g = K /( s +4) h =1/ s gh = g * h CL = g /(1+ gh ) disp ( CL , ”C( s ) /R( s )=” )
Scilab code Exa 12.51 Root Locus and Gain and Phase Margin 1 // c a p t i o n : r o o t l o c u s a n d g a i n , p h a s e m a r g i n 2 // e x a m p l e 1 2 . 5 1 3 // p a g e 580 4 s = %s ;
245
Figure 12.17: Root Locus and Gain and Phase Margin
246
5 6 7 8 9 10 11 12 13
K =3.46 G = K /( s *( s +1) *( s +2) ) G = syslin ( ’ c ’ ,G ) clf () ; evans (G ,20) xgrid (2) [ gm , freq_gm ]= g_margin ( G ) [ pm , freq_pm ]= p_margin ( G ) disp ( gm , ” g a i n m a r g i n=” , freq_gm *2* %pi , ” g a i n m a r g i n f r e q=” ) 14 disp ( pm , ” p h a s e m a r g i n=” , freq_pm *2* %pi , ” p h a s e m a r g i n f r e q=” )
Scilab code Exa 12.54 Obtain State Matrix 1 2 3 4 5 6 7 8 9 10 11
// c a p t i o n : o b t a i n s t a t e m a t r i x // e x a m p l e 12 5 4 // p a g e 583 s = %s ; g =5*( s +2) /( s *( s +1) *( s +5) ) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 12.55 Obtain State Matrix 1 // c a p t i o n : o b t a i n s t a t e m a t r i x 2 // e x a m p l e 12 5 5 3 // p a g e 585 4 s = %s ;
247
5 6 7 8 9 10 11
g =50/( s *( s ^2+0.5* s +50) ) ; CL = syslin ( ’ c ’ ,g ) ; disp ( CL , ”C( s ) /R( s )=” ) ; SS = tf2ss ( CL ) [ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) ) disp ( SS , ” s t a t e s p a c e m a t r i x=” ) disp ( Ac , ”Ac” ,Bc , ”Bc” ,U , ”U” ,ind , ” i n d ” )
Scilab code Exa 12.56 Obtain State Transistion Matrix 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
// c a p t i o n : o b t a i n s t a t e t r a n s i s t i o n m a t r i x // e x a m p l e 12 5 6 // p a g e 586 s = %s ; syms t A =[0 1;0 -3] [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f s I −A r = inv ( p ) // i n v e r s e o f s I −A // f o r c a l c u l a t i n g s t a t e t r a n s i s t i o n m a t r i x ip =[0 0;0 0] i =1; j =1; for i =1:2 for j =1:2 if ( i ==2 & j ==1) else ip (i , j ) = ilaplace ( r (i , j ) ,s , t ) ; j = j +1; end end i = i +1; end r (2 ,1) =0 248
26
disp ( ip , ” s t a t e t r a n s i s t i o n m a t r i x , i p ( t )=” ) ;
Scilab code Exa 12.57 Obtain Time Response 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// c a p t i o n : o b t a i n t i m e r e s p o n s e // e x a m p l e 12 5 7 // p a g e 586 s = %s ; syms t A =[0 1; -2 -3] B =[1 0] ’ x0 =[0 0] ’ u =1/( s +1) [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f s I −A r = inv ( p ) // i n v e r s e o f s I −A m = r * B *(1/( s +1) ) ; // f o r c a l c u l a t i n g z e r o s t a t e r e s p o n s e x =[0;0] x (1 ,1) = ilaplace ( m (1 ,1) ,s , t ) ; x (2 ,1) = ilaplace ( m (2 ,1) ,s , t ) ; disp (x , ” t i m e r e s p o n s e o f t h e system , x ( t )=” ) ;
Scilab code Exa 12.59 Obtain Time Response 1 // c a p t i o n : o b t a i n t i m e r e s p o n s e 2 // e x a m p l e 12 5 9 3 // p a g e 590 4 s = %s ; 5 syms t 6 A =[ -1 0;1 -1] 7 B =[0 1] ’
249
8 9 10 11 12 13 14 15 16 17 18 19 20
x0 =[1 0] ’ [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f s I −A r = inv ( p ) // i n v e r s e o f s I −A m = r * B *(1/ s ) r1 = r * x0 X = r1 + m // f o r c a l c u l a t i n g z e r o s t a t e r e s p o n s e x =[0;0] x (1 ,1) = ilaplace ( X (1 ,1) ,s , t ) ; x (2 ,1) = ilaplace ( X (2 ,1) ,s , t ) ; disp (x , ” z e r o i n p u t r e s p o n s e o f t h e system , x ( t )=” ) ;
Scilab code Exa 12.61 Obtain Transfer Matrix 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// c a p t i o n : o b t a i n t r a n s f e r m a t r i x // e x a m p l e 12 6 1 // p a g e 592 s = %s ; syms t A =[ -1 -1;3 -5] B =[1 1] ’ C =[1 2] [ r c ]= size ( A ) ; // s i z e o f m a t r i x A p = s * eye (r , c ) -A ; // s ∗ I−A where I i s i d e n t i t y m a t r i x q = det ( p ) // d e t e r m i n a n t o f s I −A r = inv ( p ) // i n v e r s e o f s I −A G=C*r*B disp (G , ” t r a n s f e r m a t r i x=” )
250
Appendix Scilab code AP 1 SERIES OF TWO FUNCTION 1 function [ y ] = series ( sys1 , sys2 ) 2 y = sys1 * sys2 3 endfunction
Scilab code AP 2 PARALLEL OF TWO FUNCTION 1 function [ y ]= parallel ( sys1 , sys2 ) 2 y = sys1 + sys2 ; 3 endfunction
251