ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 1 Solution to HW7 AP8.4 We are given the forward and feedback path transfer functions for a unity negative feedback system. The forward path transfer function is G(s) = s2 1 + 3.2s + 16 and the feedback path transfer function is H(s) = 1 . 0.5s + 1 We are asked to sketch the Bode diagram for G(s)H(s). Solution: First we find the corner frequencies ω. For H(s) we have a pole at s = −2, hence a corner at ω = 2 and for G(s) we have ω n = 4 and ζ = 3.2/(2ωn ) = 0.4. Thus for the complex pole pair, q and ωr = ωn 1 − 2ζ 2 = 3.2 1 = 1.36. 2ζ 1 − ζ 2 To determine the magnitude for low frequencies, we must rewrite the transfer function as Mpω = |G(ωr )| = G(s)H(s) = p 1/16 . (s2 /16 + 3.2s/16 + 1)(s/2 + 1) Then for frequencies below ω = 2 we have horizontal asymptote |G(ω)H(ω)| = 20 log 10 (1/16) = −24 dB. From ω = 2 to ω = 4 our asymptote has a slope of −20 dB/decade. Superimposed on this is a peak of height 20 log 10 (Mpω ) about ωr . Beyond ω = 4, we have asymptotic slope −60 dB/decade since there are a total of three poles. For the phase plot, we have an asymptote that decreases from 0 to −90 degrees over the frequency range 2/10 to 2 ∗ 10 rad/s (2 decades centered at ω = 2 rad/s). Another goes from −90 to −180 over the range 4/10 to 4 ∗ 10 rad/s (2 decades centered at ω = 4 rad/s). We add these to get the asymptotic phase curve which goes from zero degrees at frequencies below ω = 2/10 to −270 degrees at ω = 4 ∗ 10 and above. From this information we could generate the plots by hand. The exact magnitude and phase curves generated by Matlab are shown in Figure 1. The transcript of the Matlab session is given below. >> GH = tf([1/16],conv([1/16 3.2/16 1],[1/2 1])) Transfer function: 0.0625 -----------------------------------0.03125 s^3 + 0.1625 s^2 + 0.7 s + 1 >> bode(GH); grid; >> title(’Magnitude and Phase Plots for AP8.4’) >> print -deps ap8_4.eps ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 2 Figure 1: Definitions of angles for departure angle calculation Magnitude and Phase Plots for AP8.4 −20 −30 −40 Magnitude (dB) −50 −60 −70 −80 −90 −100 −110 Phase (deg) −120 0 −90 −180 −270 −2 10 −1 0 10 1 10 10 2 10 Frequency (rad/sec) AP8.5 We are given the closed–loop transfer function T (s) = 10(s + 1) + 9s + 10 s2 for a “unity feedback” system and asked to find the open–loop transfer function, generate a log–magnitude–phase plot, and determine whether the open– and closed–loop systems are stable. Solution: The answers to these questions depend upon whether we assume negative feedback or positive feedback. Probably the authors intended to use negative feedback. (a) Assuming negative feedback we have T (s) = G(s) 1 + G(s) so G(s) = (1 + G(s)) 10(s + 1) s2 + 9s + 10 ECE382/ME482 Spring 2004 then Homework 7 Solution April 4, 2004 3 s2 + 9s + 10 G(s) = 10(s + 1) (1 + G(s)) and solving for G(s) yields G(s) = 10(s + 1) . s(s − 1) If we assume positive feedback, we would similarly obtain G(s) = s2 10(s + 1) . + 19s + 20 (b) The log–magnitude–phase plots for the three transfer functions are given in Figure 2. In the plot legend, “NF” stands for negative feedback and “PF” stands for positive feedback. The Matlab script that generated this figure is given below. clsys = tf([10 10],[1 9 10]); olsysn = tf([10 10],[1 -1 0]); olsysp = tf([10 10],[1 19 20]); w = logspace(-1,3,1000); [magc,pc,wc] = bode(clsys,w); [magon,pon,won] = bode(olsysn,w); [magop,pop,wop] = bode(olsysp,w); plot(squeeze(pc),20*log10(squeeze(magc))) hold on plot(squeeze(pon),20*log10(squeeze(magon)),’--’) plot(squeeze(pop),20*log10(squeeze(magop)),’-.’) legend(’Closed-Loop’,’Open-Loop, NF’,’Open-Loop, PF’) a = find(wc >= 1); b = find(wc >= 10); c = find(wc >= 50); d = find(wc >= 110); e = find(wc >= 500); omega_index = [a(1) b(1) c(1) d(1) e(1)] wc(omega_index) for index = omega_index, plot(pc(1,1,index),20*log10(magc(1,1,index)),’xr’) plot(pon(1,1,index),20*log10(magon(1,1,index)),’xr’) plot(pop(1,1,index),20*log10(magop(1,1,index)),’xr’) end; title(’Log-Magnitude-Phase Plot for AP8.5b’) xlabel(’Phase (deg)’) ylabel(’Magnitude (dB)’) grid print -depsc ap8_5.eps (c) The poles of the given closed–loop system are −1.3 and −7.7 so the closed–loop system is stable. If we assume negative feedback, the open–loop system obtained has a pole ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 4 Figure 2: Plot generated by Matlab for AP8.5 Log−Magnitude−Phase Plot for AP8.5b 40 Closed−Loop Open−Loop, NF Open−Loop, PF 30 20 Magnitude (dB) 10 0 −10 −20 −30 −40 −50 −100 −50 0 50 100 Phase (deg) 150 200 250 300 in the right–half plane, hence is unstable. If we assume positive feedback, the poles are −1.12 and −17.88, hence stable. DP8.2 We are given a negative unity feedback system with a controller preceding the plant in the forward path. The controller transfer function is G c (s) = K(s + 1)/(s + 5) and the plant transfer function is 1 . G(s) = 2 s(s + 2s + 10) We are asked to sketch the Bode diagrams for the open– and closed–loop transfer functions when K = 20. We are then asked to determine the frequencies for which the gain is 0 dB and for which the phase is −180 degrees in the open–loop case. Next, we are asked to determine Mpω , ωr and ωB for the closed–loop transfer function for two different values of the gain, K = 20 and K = 40. Finally, we are asked to choose the one of these gains that gives the shortest settling time while keeping the overshoot in response to a step input less than 35%. Solution: ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 5 (a) With K = 20, the open–loop transfer function is Gc (s)G(s) = 20(s + 1) 20(s + 1)/50 = 2 s(s + 5)(s + 2s + 10) s(s/5 + 1)(s2 /10 + 2s/10 + 1) which yields a corner frequency of ω = 1 for the √ real zero, another of ω = 5 for the real pole √ at s = −5 and another at ω n =p 10 due to the complex pole pair. With ζ = 1/ 10 = 0.32 we find Mpω = (2ζ 1 − ζ 2 )−1 = 1.67. We could now use asymptotes to draw the Bode diagram. The magnitude plot would have slope −20dB/decade for ω < 1, value 0+20 log 10 (2/5) at ω = 1 and slope of −60 dB/decade for large ω. The phase plot would start at −90 degrees (due to the pole at the origin), increase due to the zero at s = −1, and decrease due to each of the poles to −270 degrees for large ω. From the Bode plot we determine that the gain is 0 dB at approximately ω = 0.4 rad/s and the phase is −180 degrees at approximately ω = 4 rad/s. (For the exact values, see the output of the margin command in the transcript below.) The Bode plot is given in Figure 3. (b) The closed–loop transfer function is T (s) = 20s + 20 s+1 Gc (s)G(s) = 4 = 4 1 + Gc (s)G(s) s + 7s3 + 20s2 + 70s + 20 s /20 + 7s3 /20 + s2 + 7s/2 + 1 which has poles −5.55, −0.57 ± 3.36j, and −0.31. The Bode plots generated for the closed–loop transfer function using Matlab are shown in Figure 3. The transcript of the commands that generated this plot is given below. >> K = 20; >> olsys = tf(K*[1 1],conv([1 5 0],[1 2 10])) Transfer function: 20 s + 20 --------------------------s^4 + 7 s^3 + 20 s^2 + 50 s >> clsys = feedback(olsys,1) Transfer function: 20 s + 20 -------------------------------s^4 + 7 s^3 + 20 s^2 + 70 s + 20 >> [mag,phase,w] = bode(olsys); >> [Gm,Pm,Wcg,Wcp] = margin(mag,phase,w) Gm = 3.1772 ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 6 Figure 3: Bode plot generated by Matlab for Problem DP8.2, parts (a) and (b) Magnitude and Phase Plots for DP8.2 Magnitude (dB) 50 0 −50 Phase (deg) −100 0 Open−Loop Closed−Loop −90 −180 −270 −2 −1 10 10 0 10 Frequency (rad/sec) Pm = 103.6808 Wcg = 4.0269 Wcp = 0.4433 >> 20*log10(Gm) ans = %% gain margin in dB 1 10 2 10 ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 7 10.0410 >> >> >> >> bode(olsys,’-’,clsys,’-.’); grid; title(’Magnitude and Phase Plots for DP8.2’) legend(’Open-Loop’,’Closed-Loop’) print -deps dp8_2.eps (c) To determine Mpω and ωr , we must factor the denominators of the closed–loop transfer functions obtained for K = 20 and K = 40. We then identify the complex pole pairs and use the Matlab command poly to obtain the second order polynomial corresponding to the complex pole pair. Identifying the polynomial with s 2 +2ζωn s+ ωn2 allows us to easily compute ζ for each case. We then use equations (8.36) and (8.37) from the text to compute ωr and Mpω , respectively. For the case K = 20, we find ωr = 3.31 and Mpω = 3.04. For the case K = 40, we find ωr = 3.68 and Mpω = 7.04. To determine the bandwidths, we plot the Bode diagrams for both cases, as shown in Figure 4. We notice that for both cases, the magnitude dips more than 3 dB below the low frequency value before the peak occurs, so that if we automated the bandwidth search procedure we would have to exercise caution to identify the −3 dB point after the peak rather than the one before. Clicking on points on the Bode plots to determine the values leads us to conclude that the bandwidth for the case K = 20 is approximately 3.5 rad/s whereas the bandwidth for the case K = 40 is approximately 4.6 rad/s. The transcript of the session that generated the required values and the Bode plots if given below. >> K = 40; >> olsys2 = tf(K*[1 1],conv([1 5 0],[1 2 10])) Transfer function: 40 s + 40 --------------------------s^4 + 7 s^3 + 20 s^2 + 50 s >> clsys2 = feedback(olsys2,1) Transfer function: 40 s + 40 -------------------------------s^4 + 7 s^3 + 20 s^2 + 90 s + 40 >> [num2,den2] = tfdata(clsys2,’v’) num2 = 0 0 0 40 40 ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 8 Figure 4: Bode plots generated by Matlab for Problem DP8.2, part (c) Magnitude and Phase Plots for DP8.2, part (c) 50 Magnitude (dB) 0 −50 −100 Phase (deg) −150 0 K=20 K=40 −90 −180 −270 −2 −1 10 0 10 1 10 10 Frequency (rad/sec) den2 = 1 7 20 90 40 >> poles2 = roots(den2) poles2 = -5.9844 -0.2632 + 3.6872i -0.2632 - 3.6872i -0.4891 >> [num,den]=tfdata(clsys,’v’) num = 2 10 3 10 ECE382/ME482 Spring 2004 Homework 7 Solution 0 0 0 20 20 1 7 20 70 20 den = >> poles = roots(den) poles = -5.5518 -0.5689 + 3.3590i -0.5689 - 3.3590i -0.3104 >> p1 = poly([poles(2) poles(3)]) p1 = 1.0000 1.1379 11.6066 >> p2 = poly([poles2(2) poles2(3)]) p2 = 1.0000 0.5265 13.6647 >> zeta1 = p1(2)/2/sqrt(p1(3)) zeta1 = 0.1670 >> zeta2 = p2(2)/2/sqrt(p2(3)) zeta2 = 0.0712 >> wn1=sqrt(p1(3)) wn1 = 3.4068 April 4, 2004 9 ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 10 >> wn2=sqrt(p2(3)) wn2 = 3.6966 >> wr1 = wn1*sqrt(1-2*zeta1^2) wr1 = 3.3105 >> wr2 = wn2*sqrt(1-2*zeta2^2) wr2 = 3.6778 >> Mpw1 = 1/(2*zeta1*sqrt(1-zeta1^2)) Mpw1 = 3.0367 >> Mpw2 = 1/(2*zeta2*sqrt(1-zeta2^2)) Mpw2 = 7.0394 >> >> >> >> bode(clsys,’-’,clsys2,’-.’); grid title(’Magnitude and Phase Plots for DP8.2, part (c)’) legend(’K=20’,’K=40’); print -depsc dp8_2c.eps (d) Here we plot the step responses, shown in Figure 5, for the transfer functions corresponding to the two gains. The peak overshoot is less than 35% in both cases. We see that the settling times appear to be identical, so to check more carefully, we isolate the segment of the step response between 98% and 102% of the final value. This is shown in Figure 6, which indicates that the 2% settling times are essentially identical, whereas the K = 20 system has a shorter 1% settling time than the K = 40 system. If we are only concerned with the settling time we would choose K = 20. Otherwise, if the rise time were the most important remaining factor in determining our choice of K we would choose the faster system with K = 40 but if large oscillations were undesirable we would tend to choose the slower system with K = 20. The Matlab ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 11 script used is included below. Figure 5: Step responses generated by Matlab for Problem DP8.2, part (d) Step responses for DP8.2 1.4 K=20 K=40 1.2 1 0.8 0.6 0.4 0.2 0 0 5 10 15 Time (s) 20 K = 20; olsys = tf(K*[1 1],conv([1 5 0],[1 2 10])) clsys = feedback(olsys,1) K = 40; olsys2 = tf(K*[1 1],conv([1 5 0],[1 2 10])) clsys2 = feedback(olsys2,1) t = [0:.01:30]; y = step(clsys,t); y40 = step(clsys2,t); figure(13); plot(t,y,t,y40,’-.’);grid; title(’Step responses for DP8.2’), xlabel(’Time (s)’); legend(’K=20’,’K=40’); print -deps dp8_2d1.eps 25 30 ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 12 Figure 6: Close-up of step responses generated by Matlab for Problem DP8.2, part (d) Close−up Plot, DP8.2 Step Response 1.025 K=20 K=40 1.02 1.015 Truncated Response 1.01 1.005 1 0.995 0.99 0.985 0.98 0 5 10 15 Time (s) 20 25 30 % check to see which has shorter 2% settling time for index = 1:3001, test1(index) = min(max(y(index),.98),1.02); test2(index) = min(max(y40(index),.98),1.02); end; figure(15); plot(t,test1,t,test2); title(’Close-up Plot, DP8.2 Step Response’); xlabel(’Time (s)’); ylabel(’Truncated Response’); legend(’K=20’,’K=40’); print -deps dp8_2d2.eps DP8.4 We are given a negative unity feedback system with a controller preceding the plant in the forward path. The controller transfer function is G c (s) = K(τ s + 1)/(s/10 + 1) and ECE382/ME482 Spring 2004 Homework 7 Solution the plant transfer function is G(s) = April 4, 2004 13 1 . (s/2 + 1)2 We are asked to select a gain K and a controller constant τ so that the bandwidth of the closed–loop system is maximized subject to the constraining M pω < 1.5, and to determine the bandwidth achieved using the selected values. Solution: First, let’s invert the expression for M pω in terms of ζ to find the range of ζ’s that correspond to Mpω ≤ 1.5. M pω = 1 ≤ 1.5 2ζ 1 − ζ 2 p holds if 1 ≤ 1.5(2)ζ q 1 − ζ 2. Squaring both sides and rearranging terms we determine that the condition is equivalent to ζ 4 − ζ 2 + 1/9 ≤ 0, so solving the quadratic yields the constraint 0.3464 < ζ < 0.9327. Next, we will apply a two–step root locus procedure (following the method of section 7.5, pp. 354–359 of the text) to the closed–loop transfer function T (s) = Gc (s)G(s) K(τ s + 1) = . 1 + Gc (s)G(s) (s/10 + 1)(s/2 + 1)2 + K(τ s + 1) Expanding the denominator yields the third–order polynomial 0.025s3 + 0.35s2 + (1.1 + Kτ )s + (1 + K) or, multiplying by 40, s3 + 14s2 + 40(1.1 + Kτ )s + 40(1 + K). We will work with this last version. Dividing both sides of s3 + 14s2 + 40(1.1 + Kτ )s + 40(1 + K) = 0 by s3 + 14s2 + 44s + 40(1 + K) yields 1+ s3 + 14s2 40Kτ s = 0. + 44s + 40(1 + K) (1) We then apply the root locus procedure to the denominator of the second term. Dividing both sides of s3 + 14s2 + 44s + 40(1 + K) = 0 by s3 + 14s2 + 44s + 40 yields 1+ s3 40K = 0. + 14s2 + 44s + 40 ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 14 Figure 7: Root locus plot generated by Matlab for K in Problem DP8.4, Root Locus for Gain K in DP8.4 20 15 System: untitled1 Gain: 13.9 Pole: −0.0212 + 6.54i Damping: 0.00324 Overshoot (%): 99 Frequency (rad/sec): 6.54 10 Imaginary Axis 5 0 −5 −10 −15 −20 −30 −25 −20 −15 −10 −5 0 5 10 Real Axis The root locus for this equation in shown in Figure 7, and the limiting value for the gain K is determined by finding the value of K for which the loci cross the imaginary axis. This yields an upper bound on K for the system to remain stable. We choose K = 13.9, corresponding to poles at −0.0212 ± 6.54j (slightly to the left of the imaginary axis). Now we substitute the value K = 13.9 into (1) to obtain 1+ s3 40(13.9)τ s = 0. + 14s2 + 44s + 40(13.9) The root locus for τ is now shown in Figure 8. We will achieve a larger bandwidth when we have a larger ωr so we choose ζ = 0.35 near the lower bound on ζ. We choose a point on the root locus where the damping is approximately 0.35 and find that the corresponding gain is 0.483, so we select τ = 0.48. The resulting closed–loop transfer function is then T (s) = (13.9)(48s/100 + 1) . (s/10 + 1)(s/2 + 1)2 + 13.9(48s/100 + 1) To verify that we have met our design objectives we generate the Bode plot shown in Figure 9 using the following commands. ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 15 Figure 8: Root locus plot generated by Matlab for τ in Problem DP8.4, Root Locus for Gain τ in DP8.4 50 40 System: untitled1 Gain: 0.483 Pole: −5.95 + 15.9i Damping: 0.35 Overshoot (%): 30.9 Frequency (rad/sec): 17 30 20 Imaginary Axis 10 0 −10 −20 −30 −40 −50 −14 −12 −10 −8 −6 −4 −2 0 Real Axis bode(tf(13.9*[48/100 1],[0.025 0.35 1.1+13.9*48/100 13.9] )); grid; title(’Bode Diagram for Closed-Loop Transfer Function DP8.4 with ... \tau=0.48 and K=13.9’); By clicking on the plot we find that the peak value of the magnitude plot is approximately 2.86 dB, which is within 20 log 10 (1.5) = 3.52 dB of the low frequency value 0 dB at ω = 0.1 rad/s. Similarly, we find that ωB is approximately 23.2 rad/s. MP8.5 We are given a unity negative feedback system in which the controller with transfer function Gc (s) precedes the plant, whose transfer function is G(s), in the forward path. We are asked to obtain Bode plots of both the open and closed–loop transfer functions for this system. Solution: The magnitude and phase plots are shown in Figure 11. A transcript of the Matlab commands that generated the plots is shown below. >> Gc = tf([1],[1 1]); >> G = tf([10],[1 3 1]); ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 16 Figure 9: Bode plot generated by Matlab for Problem DP8.4, Bode Diagram for Closed−Loop Transfer Function in DP8.4 withτ = 0.48 and K = 13.9 20 10 Magnitude (dB) 0 System: untitled1 −10 Frequency (rad/sec): 0.103 Magnitude (dB): −0.0015 −20 System: untitled1 Frequency (rad/sec): 23.2 Magnitude (dB): −3.01 −30 −40 −50 −60 −70 −80 0 Phase (deg) −45 −90 −135 −180 −1 10 0 10 1 10 Frequency (rad/sec) >> olsys = series(Gc,G) Transfer function: 10 --------------------s^3 + 4 s^2 + 4 s + 1 >> clsys = feedback(olsys,1) Transfer function: 10 ---------------------s^3 + 4 s^2 + 4 s + 11 >> bode(olsys,’-’,clsys’-.’); grid; >> title(’Magnitude and Phase Plots for MP8.5’) >> legend(’Open-Loop’,’Closed-Loop’) 2 10 3 10 ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 17 Figure 10: Magnitude and Phase Plots generated by Matlab for Problem MP8.5 Magnitude and Phase Plots for MP8.5 20 Magnitude (dB) 0 −20 −40 −60 −80 Phase (deg) −100 0 Open−Loop Closed−Loop −90 −180 −270 −2 10 −1 0 10 10 1 10 2 10 Frequency (rad/sec) >> print -depsc mp8_5.eps MP8.6 We are given the forward path transfer function for a unity negative feedback system. The forward path transfer function is G(s) = 1 . s(s + 2p) We are asked to use Matlab to plot the bandwidth vs. the parameter p for 0 < p < 1. Solution: The closed–loop transfer function is G(s) = 1 , s2 + 2ps + 1 which corresponds to ωn = 1 and ζ = p. The following script Matlab script generates the requested plot, which is given in Figure 11. ECE382/ME482 Spring 2004 Homework 7 Solution April 4, 2004 18 p = w = num for [0:0.001:1]’; logspace(-1,1,2000); = 1; index = 1:length(p), den = [1 2*p(index) 0]; clsys = feedback(tf(num,den),1); [mag,phase,w] = bode(clsys,w); a = find(mag<0.707); wb(index) = w(a(1)); end; figure(10) plot(p,wb);grid; xlabel(’p’) ylabel(’Bandwidth \omega_b (rad/s)’) title(’Plot for MP8.6’) print -deps mp8_6.eps Figure 11: Plot of system bandwidth vs. value of p for Problem MP8.6 Plot for MP8.6 1.6 1.5 1.4 1.2 b Bandwidth ω (rad/s) 1.3 1.1 1 0.9 0.8 0.7 0.6 0 0.1 0.2 0.3 0.4 0.5 p 0.6 0.7 0.8 0.9 1