27
Solution for Take Home Exam 2 Problem 1: For the following closed-loop transfer functions find the maximum overshoot. Show the poles & zeros graphically & manually. Show the approximate & exact phase margin. Convert the transfer functions to state space & prove them by simulation. Use matlab as appropriate. a) to e) are: Part 1: find the maximum overshoot. The approximation formula for Mp is equation 2.18 on p. 21 of the text. The matlab code is: function Mp = getMp(num,den,Ts,i); sys = tf(num,den,Ts); [wn,z] = damp(sys); Mp = 100*exp(-pi*z(1)/sqrt(1-z(1)*z(1))); figure(i) y = dstep(num,den); dstep(num,den),grid on,hold on plot([0:length(y)-1]',(1+Mp/100*ones(1,length(y))),'r'),hold off title(['step response, Mp = ',num2str(Mp),'%']) In the above num is the discrete transfer function numerator, den is the denominator, Ts is the sampling

Solution for Take Home Exam 2

Embed Size (px)

DESCRIPTION

5.03 Part 1: find the maximum overshoot. The approximation formula for Mp is equation 2.18 on p. 21 of the text. function Mp = getMp(num,den,Ts,i); sys = tf(num,den,Ts); [wn,z] = damp(sys); Mp = 100*exp(­pi*z(1)/sqrt(1­z(1)*z(1))); figure(i) y = dstep(num,den); dstep(num,den),grid on,hold on plot([0:length(y)­1]',(1+Mp/100*ones(1,length(y))),'r'),hold off title(['step response, Mp = ',num2str(Mp),'%']) −+− zz zz zz zz 05.05.0 zC zC zC zC zC +− +− Solution for Take Home Exam 2 )( )(

Citation preview

Page 1: Solution for Take Home Exam 2

Solution for Take Home Exam 2

Problem 1: For the following closed-loop transfer functions find the maximum overshoot. Show the poles & zeros graphically & manually. Show the approximate & exact phase margin. Convert the transfer functions to state space & prove them by simulation. Use matlab as appropriate. a) to e) are:

Part 1: find the maximum overshoot. The approximation formula for Mp is equation 2.18

on p. 21 of the text.

The matlab code is:

function Mp = getMp(num,den,Ts,i);sys = tf(num,den,Ts);[wn,z] = damp(sys);Mp = 100*exp(-pi*z(1)/sqrt(1-z(1)*z(1)));figure(i)y = dstep(num,den);dstep(num,den),grid on,hold onplot([0:length(y)-1]',(1+Mp/100*ones(1,length(y))),'r'),hold offtitle(['step response, Mp = ',num2str(Mp),'%'])

In the above num is the discrete transfer function numerator, den is the denominator, Ts is the sampling interval (arbitrary in this case), and ‘i’ is the figure number.

The matlab driver code is:

num = [1 0.5]; den = 3*[1 -1 0.5]; Mp = getMp(num,den,10,1) num = [0.5 0]; den = [1 -1 0.5]; Mp = getMp(num,den,10,2) num = [1 0.5]; den = 3*[1 -1 0.5 0 0]; Mp = getMp(num,den,10,3)

Page 2: Solution for Take Home Exam 2

num = [0.5]; den = [1 -1 0.5 0 0]; Mp = getMp(num,den,10,4) num = conv(0.316*[1 0.002],[1 0.5]); den = conv([1 -1 0.5],[1 -0.05]); Mp = getMp(num,den,10,5)

The plots are:

Page 3: Solution for Take Home Exam 2

0 5 10 15 20 250

0.2

0.4

0.6

0.8

1

1.2

1.4step response, Mp = 25%

Time (sec)

Ampl

itude

0 5 10 15 20 250

0.2

0.4

0.6

0.8

1

1.2

1.4step response, Mp = 25%

Time (sec)

Ampl

itude

Page 4: Solution for Take Home Exam 2

0 5 10 15 20 25 300

0.2

0.4

0.6

0.8

1

1.2

1.4step response, Mp = 25%

Time (sec)

Ampl

itude

0 5 10 15 20 25 300

0.2

0.4

0.6

0.8

1

1.2

1.4step response, Mp = 25%

Time (sec)

Ampl

itude

Page 5: Solution for Take Home Exam 2

0 5 10 15 20 250

0.2

0.4

0.6

0.8

1

1.2

1.4step response, Mp = 25%

Time (sec)

Ampl

itude

In all cases the Mp is 25%.

Part 2): Show the poles & zeros graphically & manually. The matlab code is:

function getpolz(num,den,Ts,i)figure(i) sys = tf(num,den,Ts);[p,z] = pzmap(sys);pzmap(sys)title(['poles = ',num2str(p','%7.3f')])xlabel(['real axis. zeros = ',num2str(z','%7.3f')])

Page 6: Solution for Take Home Exam 2

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1poles = 0.500-0.500i 0.500+0.500i

real axis. zeros = -0.500

Imag

inar

y Ax

is

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1poles = 0.500-0.500i 0.500+0.500i

real axis. zeros = 0.000

Imag

inar

y Ax

is

Page 7: Solution for Take Home Exam 2

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1poles = 0.000+0.000i 0.000+0.000i 0.500-0.500i 0.500+0.500i

real axis. zeros = -0.500

Imag

inar

y A

xis

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1poles = 0.000+0.000i 0.000+0.000i 0.500-0.500i 0.500+0.500i

real axis. zeros =

Imag

inar

y Ax

is

Page 8: Solution for Take Home Exam 2

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1poles = 0.500-0.500i 0.500+0.500i 0.050+0.000i

real axis. zeros = -0.500 -0.002

Imag

inar

y Ax

is

Part 3): Show the approximate & exact phase margin. The matlab code is:

function getPM(num,den,Ts,i)figure(i) sys = tf(num,den,Ts);margin(sys)[wn,z] = damp(sys);xlabel(['the approximate PM = ',num2str(100*z(1))])

Page 9: Solution for Take Home Exam 2

-25

-20

-15

-10

-5

0

5

Mag

nitu

de (d

B)

10-2

10-1

100

101

-225

-180

-135

-90

-45

0

Phas

e (d

eg)

Bode DiagramGm = 9.54 dB (at 1.57 rad/sec) , Pm = 50.1 deg (at 0.982 rad/sec)

the approximate PM = 40.3713 (rad/sec)

-15

-10

-5

0

5

Mag

nitu

de (d

B)

10-2

10-1

100

101

-180

-135

-90

-45

0

Phas

e (d

eg)

Bode DiagramGm = 14 dB (at 3.14 rad/sec) , Pm = 60 deg (at 1.05 rad/sec)

the approximate PM = 40.3713 (rad/sec)

Page 10: Solution for Take Home Exam 2

-25

-20

-15

-10

-5

0

5

Mag

nitu

de (d

B)

10-2

10-1

100

101

-540

-360

-180

0

Phas

e (d

eg)

Bode DiagramGm = -2.36 dB (at 0.77 rad/sec) , Pm = -62.4 deg (at 0.982 rad/sec)

the approximate PM = 40.3713 (rad/sec)

-15

-10

-5

0

5

Mag

nitu

de (d

B)

10-2

10-1

100

101

-720

-540

-360

-180

0

Phas

e (d

eg)

Bode DiagramGm = -2.96 dB (at 0.683 rad/sec) , Pm = -120 deg (at 1.05 rad/sec)

the approximate PM = 40.3713 (rad/sec)

Page 11: Solution for Take Home Exam 2

-25

-20

-15

-10

-5

0

5

Mag

nitu

de (d

B)

10-2

10-1

100

101

-225

-180

-135

-90

-45

0

Phas

e (d

eg)

Bode DiagramGm = 9.11 dB (at 1.51 rad/sec) , Pm = 49.7 deg (at 0.968 rad/sec)

the approximate PM = 40.3713 (rad/sec)

Note that the approximate PM doesn’t vary, whereas the exact PM does vary significantly.

Part 4): Convert the transfer functions to state space & prove them by simulation.

The matlab code is:

function getss(num,den,Ts,i)figure(i) sys = tf(num,den,Ts);[phi,gam,c,d] = ssdata(sys);sysd = ss(phi,gam,c,d,Ts);step(sys,sysd)legend('tf','ss') The following plots show that they are plotted on top of each other. In this case, Ts = 1 sec.

Page 12: Solution for Take Home Exam 2

0 5 10 15 20 250

0.2

0.4

0.6

0.8

1

1.2

1.4Step Response

Time (sec)

Ampl

itude

tfss

0 5 10 15 20 250

0.2

0.4

0.6

0.8

1

1.2

1.4Step Response

Time (sec)

Ampl

itude

tfss

Page 13: Solution for Take Home Exam 2

0 5 10 15 20 25 300

0.2

0.4

0.6

0.8

1

1.2

1.4Step Response

Time (sec)

Ampl

itude

tfss

0 5 10 15 20 25 300

0.2

0.4

0.6

0.8

1

1.2

1.4Step Response

Time (sec)

Ampl

itude

tfss

Page 14: Solution for Take Home Exam 2

0 5 10 15 20 250

0.2

0.4

0.6

0.8

1

1.2

1.4Step Response

Time (sec)

Ampl

itude

tfss

4.11 Consider the system described by the transfer function .

a) Draw the block diagram corresponding to this system in control canonical form, define the state vector, and give the corresponding description matrices F, G, H, J. b) Write G(s) in partial fractions and draw the corresponding parallel block diagram with each component part in control canonical form. Define the state ξ and give the corresponding state description matrices A, B, C, D.

a)

Page 15: Solution for Take Home Exam 2

b) G(s) in partial fractions

Page 16: Solution for Take Home Exam 2

4.18 Draw out each block of Fig. 4.10 in a) control and b) observer canonical form. Write out the state-description matrices in each case.

One of the 1st steps is to convolve the numerator and denominator as follows:

conv([1 1],[1 -0.5 0.25])conv([1 -1 0],[1 -1.6 0.81]) which gives: [1.0000 0.5000 -0.2500 0.2500] for the numerator and,

[1.0000 -2.6000 2.4100 -0.8100 0] for the denominator.

Page 17: Solution for Take Home Exam 2

5.15 Find the transform of the output Y(s) and its samples Y*(s) for the block diagrams shown in Fig. 5.23. Indicate whether a transfer function exists in each case.

Page 18: Solution for Take Home Exam 2

5.16 Assume the following transfer functions are preceded by a sampler and zero-order hold and followed by a sampler. Compute the resulting discrete transfer functions.

The governing equation is , which is equation (2.39) of the text.

The table look up for a) or G1(s) is:

Page 19: Solution for Take Home Exam 2

The table look up for c) or G3(s) is:

The table look up for e) or G5(s) is:

The matlab code is:

Ts = 1;c2d(tf(1,[1 0 0]),Ts)c2d(tf(1,[1 1],'inputdelay',1.5),Ts)c2d(tf(1,[1 1 0]),Ts)c2d(tf(1,[1 1 0],'inputdelay',1.5),Ts)c2d(tf(1,[1 0 -1]),Ts) The assumed sample interval is 1 second.

The results are:

Transfer function: 0.5 z + 0.5-------------z^2 - 2 z + 1 Sampling time: 1 Transfer function: 0.3935 z + 0.2387z^(-1) * -----------------

Page 20: Solution for Take Home Exam 2

z^2 - 0.3679 z Sampling time: 1 Transfer function: 0.3679 z + 0.2642----------------------z^2 - 1.368 z + 0.3679 Sampling time: 1 Transfer function: 0.1065 z^2 + 0.4709 z + 0.05471z^(-1) * ------------------------------- z^3 - 1.368 z^2 + 0.3679 z Sampling time: 1 Transfer function:0.5431 z + 0.5431-----------------z^2 - 3.086 z + 1 Sampling time: 1

6.3 The following transfer function is a lead network designed to add about 60 degrees

phase lead at w1 = 3 rad/s .

a) For each of the following design methods compute and plot in the z-plane the pole and zero locations and compute the amount of phase lead given by the equivalent network at z1 = if T = 0.25 sec and the design is via1) Forward rectangular rule 2) Backward rectangular rule3) Bilinear rule4) Bilinear with prewarping (use w1 as the warping frequency)5) Zero-pole mapping6) Zero-order-hold equivalent7) Triangular-hold equivalent

b) Plot over the frequency range wl = 0.1 wh = 100 the amplitude and phase Bode plots for each of the above equivalents.

Compute the phase @ 3 rad/s for the lead network H(s) by the following matlab code:

w1 = 3;H = tf([1 1],[0.1 1]);

Page 21: Solution for Take Home Exam 2

[mag,ph] = bode(H,w1)

The result for the continuous lead is:mag = 3.0289, ph = 54.8658

The result for the forward rectangular rule is:mag = 2.9222, ph = 74.5542

The result for the backward rectangular rule is:mag = 3.0036, ph = 38.9183

The result for the bilinear rule is:mag = 3.1514, ph = 54.9030

The result for the bilinear rule with prewarp @ 3 rad/s is:mag = 3.0289, ph = 54.8658

The result for the matched zero-pole rule is:mag = 3.0112, ph = 47.5753

The result for the zero-order hold rule is:mag = 7.4779, ph = 58.1401

The result for the first-order hold rule is:mag = 3.1262, ph = 48.2400

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1H(s) continuous

Real Axis

Imag

inar

y Ax

is

-1.5 -1 -0.5 0 0.5 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Forw ard rectangular rule

Real Axis

Imag

inar

y Ax

is

Page 22: Solution for Take Home Exam 2

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Backw ard rectangular rule, phase @ 3 rad/s = 38.9183

Real Axis

Imag

inar

y Ax

is

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Trapezoid (bilinear) rule, phase @ 3 rad/s = 54.903

Real Axis

Imag

inar

y Ax

is

Page 23: Solution for Take Home Exam 2

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Trapezoid w ith prew arp @ 3 rule, phase @ 3 rad/s = 54.8658

Real Axis

Imag

inar

y Ax

is

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Zero-pole matched rule, phase @ 3 rad/s = 47.5753

Real Axis

Imag

inar

y Ax

is

Page 24: Solution for Take Home Exam 2

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Zero-order hold rule, phase @ 3 rad/s = 58.1401

Real Axis

Imag

inar

y Ax

is

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1First-order hold rule, phase @ 3 rad/s = 48.24

Real Axis

Imag

inar

y Ax

is

Page 25: Solution for Take Home Exam 2

0

10

20

30

40

Mag

nitu

de (d

B)

10-1

100

101

-90

0

90

180

270

360

Phas

e (d

eg)

Bode Diagram

Frequency (rad/sec)

Hbackforbilinprew arpzpzohfoh

The complete matlab code is:

function Prob_6_3()%close allw1 = 3;H = tf([1 1],[0.1 1]);figure(1)pzmap(H)title('H(s) continuous')[mag,ph] = bode(H,w1);T = 0.25;[a,b,c,d] = ssdata(H);[phif,gamf,hf,jf] = get_for(a,b,c,d,T);Hf = ss(phif,gamf,hf,jf,T);[mag,ph] = bode(Hf,w1);pzmap(Hf)title('Forward rectangular rule')[phib,gamb,hb,jb] = get_back(a,b,c,d,T);Hb = ss(phib,gamb,hb,jb,T);[mag,ph] = bode(Hb,w1);pzmap(Hb)title(['Backward rectangular rule, phase @ 3 rad/s = ',num2str(ph)])[phibil,gambil,hbil,jbil] = get_bil(a,b,c,d,T);Hbil = ss(phibil,gambil,hbil,jbil,T);[mag,ph] = bode(Hbil,w1);pzmap(Hbil)

Page 26: Solution for Take Home Exam 2

title(['Trapezoid (bilinear) rule, phase @ 3 rad/s = ',num2str(ph)])Hpre = c2d(H,T,'prewarp',w1);[mag,ph] = bode(Hpre,w1);pzmap(Hpre)title(['Trapezoid with prewarp @ 3 rule, phase @ 3 rad/s = ',num2str(ph)])Hmat = c2d(H,T,'matched');[mag,ph] = bode(Hmat,w1);pzmap(Hmat)title(['Zero-pole matched rule, phase @ 3 rad/s = ',num2str(ph)])Hzoh = c2d(H,T,'zoh');[mag,ph] = bode(Hzoh,w1);pzmap(Hzoh)title(['Zero-order hold rule, phase @ 3 rad/s = ',num2str(ph)])Hfoh = c2d(H,T,'foh');[mag,ph] = bode(Hfoh,w1);pzmap(Hfoh)title(['First-order hold rule, phase @ 3 rad/s = ',num2str(ph)])bode(H,Hf,Hb,Hbil,Hpre,Hmat,Hzoh,Hfoh,[0.1:.1:25])legend('H','back','for','bilin','prewarp','zp','zoh','foh') function [phif,gamf,hf,jf] = get_for(a,b,c,d,T);phif = eye(size(a)) + a*T;gamf = b*T;hf = c;jf = d; function [phib,gamb,hb,jb] = get_back(a,b,c,d,T);phib = inv(eye(size(a)) - a*T);gamb = phib*b*T;hb = c*phib;jb = d + c*gamb; function [phibil,gambil,hbil,jbil] = get_bil(a,b,c,d,T);temp = inv(eye(size(a)) - a*T/2);phibil = (eye(size(a)) + a*T/2)*temp;gambil = temp*b*sqrt(T);hbil = sqrt(T)*c*temp;jbil = d + c*temp*b*T/2;