ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 1 Solution to HW8 P10.21 We are given a system with open loop transfer function G(s) = K s(s/2 + 1)(s/6 + 1) (1) and unity negative feedback. We are asked to design a pair of identical cascaded phase-lead networks to compensate the system such that the closed-loop system has • velocity error constant Kv = 20, • phase margin near 45 degrees, • and closed loop bandwidth at least ω = 4 rad/s. Solution: We might ask why we would want to design a pair of identical phase-lead networks rather than a single network or two not necessarily identical ones. Hardware constraints would be most likely the reason we could not use a single network to obtain the entire phase margin adjustment. As for the request that the networks be identical, that minimizes the opportunity for installation errors (from the controls standpoint, they’re in series so it doesn’t matter which is first, but from a hardware standpoint, they may contain active components which require power sources or other connections which should not be confused). Also, if we wanted to keep a spare component on the shelf in case of failure, making the two networks the same means we only need to keep one spare rather than two. Now, to solve the stated problem, we first note that the definition of the velocity error constant is Kv = lim sG(s), (2) s→0 (see Section 5.7, page 262, of the textbook). Thus, to meet the design specification Kv = 20 we must choose K = 20. Our next step (following the outline on page 609 of the text) is to determine the phase margin of the uncompensated system. Using the Matlab command margin(tf([20],[1/12 1/2+1/6 1 0])) we obtain the Bode plot shown in Figure 1, which indicates that the phase margin of the uncompensated system is −20.7 degrees at 5.29 rad/s. Next, we determine α. If we were designing a single lead compensator to add the entire needed phase margin 45 + 20.7 ≈ 66 degrees α−1 = sin 66 deg α+1 (3) but since we want to use a pair of identical compensators, we let each of them provide half the required phase margin, so solve instead α−1 = sin 33 deg, α+1 using the Matlab command (4) ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 2 Figure 1: Open Loop Bode Diagram for P10.21 Bode Diagram Gm = −7.96 dB (at 3.46 rad/sec) , Pm = −20.7 deg (at 5.29 rad/sec) 100 Magnitude (dB) 50 0 −50 −100 −150 −90 Phase (deg) −135 −180 −225 −270 −2 10 −1 10 0 1 10 10 2 10 3 10 Frequency (rad/sec) alfa = (1+sin(33*pi/180))/(1-sin(33*pi/180)) to obtain α = 3.3732, so we’ll let α = 3.4. Note that we must not call our variable alpha because Matlab has a function called alpha. Next, we find the frequency at which the magnitude for the uncompensated network is −10 log 10 α or −5.3 dB. This gives us ωm = 6.8 rad/s, as shown in Figure 2. We must also multiply by α to compensate for the attenuation, therefore each of our twin compensators is √ √ √ √ α(s + ωm / α) 3.4(s + 6.8/ 3.4) √ √ = . (5) Gc (s) = s + ωm α s + 6.8 3.4 Our combined open loop transfer function is then G2c (s)G(s) = 20(3.4)(s + 6.8)2 s(s + 12.5)2 (s/2 + 1)(s/6 + 1) for which the phase margin is 50 degrees, as shown in Figure 3. (6) ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 3 Figure 2: Finding ωm in the Open Loop Bode Diagram for P10.21 Bode Diagram Gm = −7.96 dB (at 3.46 rad/sec) , Pm = −20.7 deg (at 5.29 rad/sec) 100 Magnitude (dB) 50 System: untitled1 Frequency (rad/sec): 6.81 Magnitude (dB): −5.25 0 −50 −100 −150 −90 Phase (deg) −135 −180 −225 −270 −2 10 −1 10 0 1 10 10 2 10 3 10 Frequency (rad/sec) Now we have to make a decision based on our application. Is 50 degrees close enough to 45 degrees? If not, we would adjust the estimated phase margin needed, recompute α, and repeat the procedure above. Not having a specific application in mind, we’ll assume that 50 degrees will do. Finally, we must check to see that we have achieved the required closed loop bandwidth. As shown in Figure 4, we have achieved a bandwidth of ωBW = 7.75 rad/s which exceeds 4 rad/s so we have met our design criteria. Here’s the Matlab script that I used, so that you can see how I automated the steps of checking the Bode plot to obtain the needed phase margin and the new crossover frequency. % % P10_21.m solves part of problem P10_21 from Dorf and Bishop 10th ed. % % 30 April 05 --sk % clear all ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 4 Figure 3: Open Loop Bode Diagram for Compensated System of P10.21 Bode Diagram Gm = 14.5 dB (at 12.9 rad/sec) , Pm = 50 deg (at 4.26 rad/sec) 50 Magnitude (dB) 0 −50 −100 −150 −90 Phase (deg) −135 −180 −225 −270 −1 10 0 10 1 10 Frequency (rad/sec) 2 10 3 10 G = tf([20],[1/12 1/2+1/6 1 0]); figure(1) margin(tf([20],[1/12 1/2+1/6 1 0])) %print -deps p10_21a % % % % % having determined that the phase margin of the open loop system is -20.7 degrees, we solve for alpha to obtain half the needed additional phase margin of 66 degrees. (To automate things, I’ve reiterated the margin command, this time with arguments to obtain the phase margin in the variable Pm.) [Gm,Pm,Wcg,Wcp] = margin(G); ph_needed = (45-Pm)/2; alfa = (1+sin(ph_needed*pi/180))/(1-sin(ph_needed*pi/180)) mmag = -10*log10(alfa) ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 5 Figure 4: Closed Loop Bode Diagram for Compensated System of P10.21 Bode Diagram Gm = 12.7 dB (at 12.9 rad/sec) , Pm = 76.3 deg (at 6.09 rad/sec) 50 Magnitude (dB) 0 System: untitled1 Frequency (rad/sec): 7.75 Magnitude (dB): −2.97 −50 −100 −150 0 Phase (deg) −90 −180 −270 −1 10 0 10 1 10 Frequency (rad/sec) 2 10 3 10 % having obtained alpha I automate the process of finding the % frequency omega_m at which the magnitude is mmag and then determine Gc wrange = logspace(-2,3,1000); [mag,ph] = bode(G,wrange); wm = interp1(20*log10(squeeze(mag))’,wrange’,mmag) Gc = tf(sqrt(alfa)*[1 wm/sqrt(alfa)],[1 wm*sqrt(alfa)]) GcGcG = series(series(Gc,Gc),G) figure(2) margin(GcGcG) %print -deps p10_21ol figure(3) margin(feedback(GcGcG,1)) %print -deps p10_21cl ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 6 P10.22 We are asked to design a phase-lag network for the same system, having open loop transfer function K G(s) = (7) s(s/2 + 1)(s/6 + 1) and unity negative feedback, such that the closed-loop system has • velocity error constant Kv = 20, • phase margin near 45 degrees, and • closed loop bandwidth at least ω = 2 rad/s. What’s changed from P10.21 is that the bandwidth requirement has been relaxed. Solution: As in the previous problem, we first note that the definition of the velocity error constant is Kv = lim sG(s), (8) s→0 (see Section 5.7, page 262, of the textbook). Thus, to meet the design specification Kv = 20 we must choose K = 20. As determined in the previous problem from the Bode plot shown in Figure 1, the phase margin of the uncompensated system is −20.7 degrees at 5.29 rad/s. From the Bode plot in Figure 1, we find the frequency ωc′ at which the phase margin (plus 5 degrees for the phase lag network) would be satisfied if the magnitude curve crossed 0 dB there. As shown in Figure 2, we choose ωc′ to be that frequency at which the phase is −180 + 45 + 5 = −130 degrees, namely ωc′ = 1.12 rad/s. We see that we will need to adjust the attenuation by a gain of −23.7 dB in order to have the magnitude curve cross 0 dB at ωc′ . We place the zero of the compensator one decade below ωc′ , i.e. at ωz = 0.11. We determine the value of α from −20 log10 α = −24 (9) to be α = 15.22. The pole of the lag network is then placed at ωz /α ≈ 0.0074, so lag compensator has transfer function Gc = (s + 0.011) 15.22(s + 0.0074) (10) and the closed-loop transfer function will be T (s) = Gc (s)G(s) 20(s + 0.11) = . 1 + Gc (s)G(s) 15.21(s + 0.0074)(s/2 + 1)(s/6 + 1) + 20(s + 0.11) (11) As shown in Figure 5, the phase margin requirement is met. Figure 6 shows that the bandwidth requirement is met to within one percent, which we will declare to be adequate. Otherwise, we’d have to fiddle with gains and pole locations to improve it. The Matlab script used to generate these results is shown below. ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 7 Figure 5: Open Loop Bode Diagram for Compensated System of P10.22 Bode Diagram Gm = 15.1 dB (at 3.34 rad/sec) , Pm = 44.6 deg (at 1.13 rad/sec) 150 Magnitude (dB) 100 50 0 −50 −100 −150 −90 Phase (deg) −135 −180 −225 −270 −4 10 −3 10 −2 10 −1 0 10 10 Frequency (rad/sec) 1 10 2 10 3 10 % % P10_22.m solves part of problem P10_22 from Dorf and Bishop 10th ed. % % 30 April 05 --sk % clear all G = tf([20],[1/12 1/2+1/6 1 0]) figure(1) margin(tf([20],[1/12 1/2+1/6 1 0])) print -deps p10_22a wrange = logspace(-2,3,1000); [mag,ph] = bode(G,wrange); wc = interp1(squeeze(ph)’,wrange’,-130) mmag = 20*log10(interp1(wrange’,squeeze(mag)’,wc)) alfa = 10^(-mmag/-20) ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 8 Figure 6: Closed Loop Bode Diagram for Compensated System of P10.22 Bode Diagram Gm = 13.4 dB (at 3.34 rad/sec) , Pm = 62 deg (at 1.67 rad/sec) 50 Magnitude (dB) 0 System: untitled1 Frequency (rad/sec): 1.99 Magnitude (dB): −2.98 −50 −100 −150 0 Phase (deg) −90 −180 −270 −2 10 −1 10 0 1 10 10 2 10 3 10 Frequency (rad/sec) Gc = tf([1 wc/10],alfa*[1 (wc/10)/alfa]) figure(2) margin(series(Gc,G)) print -deps p10_22ol figure(3) margin(feedback(series(Gc,G),1)) print -deps p10_22cl P10.23 We are again given the system with unity negative feedback and forward path transfer function open loop transfer function G(s) = K . s(s/2 + 1)(s/6 + 1) We are asked to design a lead-lag compensator such that the closed-loop system has (12) ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 9 • velocity error constant Kv = 20, • phase margin near 45 degrees, and • closed loop bandwidth at least ω = 2 rad/s but not more than 10 rad/s. We are given the general form of the lead-lag compensator transfer function, with α = 10 for both the lead and lag portions, that is, Gc (s) = s )(1 + sb ) (1 + 10a s , ) (1 + as )(1 + 10b (13) and told to select a to characterize the lag portion of the compensator and b to characterize the lead portion of the compensator. Actually, if we check the text, we find that a should correspond to the lead portion and b should correspond to the lag portion. Solution: As in the previous problem, we first note that the definition of the velocity error constant is Kv = lim sG(s), (14) s→0 (see Section 5.7, page 262, of the textbook). Thus, to meet the design specification Kv = 20 we must choose K = 20. We are told on page 612 of the textbook that the idea of using a lead-lag network is to “[provide] the attenuation of a phase-lag network and the lead-phase angle of a phase-lead network”. Let’s see what this means. The network structure that’s been specified in (13) fixes α = 10 for both the lead network and the lag network. Looking first at the lead network, we can solve sin φm = α−1 α+1 (15) for the phase angle that we will obtain from the lead filter (irrespective of the actual values of the zero and pole that we eventually choose). The resulting phase contribution is φm = sin−1 (9/11) = 55 deg. (16) On the other hand, the attenuation introduced by the phase lag network is −20 log10 α at the chosen crossover frequency, (see Step 6 on page 609 of the text). This is −20 dB. The uncompensated system has magnitude 20 dB at 1.54 rad/s as shown in Figure 7. Then from Step 6, we choose crossover frequency ωc′ = 1.54 and (as in Step 4), place the zero of the lag filter one decade below the crossover frequency at 0.154 rad/s. The pole is then placed at 0.154/α = 0.0154 rad/s. Let’s see what we have so far. The phase margin of the combined system is −22.2 degrees as shown in Figure 8. Now we have to correct the phase margin. Our lead filter will give us 30 degrees of phase margin at its crossover frequency, so we must choose the zero and pole accordingly. The √ √ crossover frequency should be ωm = zp with p = ωm α. From the Bode plot of this open loop system, we choose ωm to be that frequency at which the phase is −180 + 45 √− 30 = −165 rad/s. This gives us ωm = 2.35 rad/s. Accordingly, we choose p = 2.35 10 and ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 10 Figure 7: Open Loop Bode Diagram for System of P10.23 Bode Diagram Gm = −7.96 dB (at 3.46 rad/sec) , Pm = −20.7 deg (at 5.29 rad/sec) 100 Magnitude (dB) 50 0 System: G Frequency (rad/sec): 1.54 Magnitude (dB): 20 −50 −100 −150 −90 Phase (deg) −135 −180 −225 −270 −2 10 −1 0 10 1 10 10 2 10 3 10 Frequency (rad/sec) √ z = 2.35/ 10 and obtain phase margin of 47 degrees, as shown in Figure 9, and closed-loop bandwidth of around 6.35 rad/s as show in Figure 10. The lead-lag compensator obtained has transfer function Gc = (s + 0.154)(s + 0.0154) . s + 0.743)(s + 7.43) The Matlab script used is given below. % % P10_23.m solves part of problem P10_23 from Dorf and Bishop 10th ed. % % 30 April 05 --sk % clear all G = tf([20],[1/12 1/2+1/6 1 0]) figure(1) (17) ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 11 Figure 8: Open Loop Bode Diagram for Lag Compensated System of P10.23 Bode Diagram Gm = 11.2 dB (at 3.3 rad/sec) , Pm = 32.8 deg (at 1.54 rad/sec) 150 Magnitude (dB) 100 50 0 −50 −100 −150 −90 Phase (deg) −135 −180 System: untitled1 Frequency (rad/sec): 2.35 Phase (deg): −165 −225 −270 −4 10 −3 10 −2 10 −1 0 10 10 Frequency (rad/sec) 1 10 margin(G) %print -deps p10_23a alfa=10; mmag = -20*log10(alfa) wrange = logspace(-2,3,1000); [mag,ph] = bode(G,wrange); wcp = interp1(20*log10(squeeze(mag))’,wrange’,-mmag) Gc_lag = tf(1/10*[1 wcp/10],[1 (wcp/10)/alfa]) figure(2) margin(series(Gc_lag,G)) %print -deps p10_23ol1 wm=2.35 %%% where phase is -180+45-30=-165 Gc_lead = tf(alfa*[1 wm/sqrt(alfa)],[1 wm*sqrt(alfa)]) 2 10 3 10 ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 12 Figure 9: Open Loop Bode Diagram for Compensated System of P10.23 Bode Diagram Gm = 10.7 dB (at 7.69 rad/sec) , Pm = 47 deg (at 3.69 rad/sec) 150 Magnitude (dB) 100 50 0 −50 −100 −150 −45 Phase (deg) −90 −135 −180 −225 −270 −4 10 −3 10 −2 10 −1 0 10 10 Frequency (rad/sec) 1 10 figure(3) margin(series(Gc_lead,series(Gc_lag,G))) print -deps p10_23ol2 figure(4) margin(feedback(series(Gc_lead,series(Gc_lag,G)),1)) print -deps p10_23cl 2 10 3 10 ECE382/ME482 Spring 2005 Homework 8 Solution December 11, 2007 13 Figure 10: Closed Loop Bode Diagram for Compensated System of P10.23 Bode Diagram Gm = 7.74 dB (at 7.69 rad/sec) , Pm = 41.5 deg (at 5.59 rad/sec) 50 Magnitude (dB) 0 System: untitled1 Frequency (rad/sec): 6.37 Magnitude (dB): −3.05 −50 −100 −150 0 Phase (deg) −90 −180 −270 −1 10 0 10 1 10 Frequency (rad/sec) 2 10 3 10