Issuu on Google+

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: C( z) z + 0 .5 = 2 R( z ) 3( z − z + 0.5) C( z) 0 .5 z = 2 R( z ) ( z − z + 0.5) C( z) z −2 ( z + 0.5) = R( z ) 3( z 2 − z + 0.5)

C( z) 0.5 z −2 = 2 R( z ) ( z − z + 0.5) C ( z ) 0.316( z + 0.002)( z + 0.5) = R( z ) ( z 2 − z + 0.5)( z − 0.05) Part 1: find the maximum overshoot. The approximation formula for Mp is equation 2.18

on p. 21 of the text. M p ≈ e

πζ 1−ζ 2

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 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) 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:


step response, Mp = 25% 1.4

1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15

20

25

Time (sec)

step response, Mp = 25% 1.4

1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15 Time (sec)

20

25


step response, Mp = 25% 1.4

1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15

20

25

30

Time (sec)

step response, Mp = 25% 1.4

1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15 Time (sec)

20

25

30


step response, Mp = 25% 1.4

1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15

20

Time (sec)

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')])

25


poles = 0.500-0.500i 0.500+0.500i 1 0.8 0.6

Imaginary Axis

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

1

real axis. zeros = -0.500

poles = 0.500-0.500i 0.500+0.500i 1 0.8 0.6

Imaginary Axis

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

real axis. zeros = 0.000

0.4

0.6

0.8

1


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

Imaginary Axis

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

1

real axis. zeros = -0.500

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

Imaginary Axis

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

real axis. zeros =

0.4

0.6

0.8

1


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

Imaginary Axis

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

real axis. zeros = -0.500 -0.002

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))])

1


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

Magnitude (dB)

0 -5 -10 -15 -20 -25 0

Phase (deg)

-45 -90 -135 -180 -225 -2

10

-1

10

0

10

10

1

the approximate PM = 40.3713 (rad/sec)

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

Magnitude (dB)

0

-5

-10

-15 0

Phase (deg)

-45 -90 -135 -180 -2

10

-1

10

0

10

the approximate PM = 40.3713 (rad/sec)

1

10


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

Magnitude (dB)

0 -5 -10 -15 -20

Phase (deg)

-25 0

-180

-360

-540 -2

10

-1

10

0

10

10

1

the approximate PM = 40.3713 (rad/sec)

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

Magnitude (dB)

0

-5

-10

-15 0

Phase (deg)

-180 -360 -540 -720 10

-2

-1

10

10

0

the approximate PM = 40.3713 (rad/sec)

1

10


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

Magnitude (dB)

0 -5 -10 -15 -20 -25 0

Phase (deg)

-45 -90 -135 -180 -225 -2

10

-1

10

0

10

1

10

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.


Step Response 1.4 tf ss 1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15

20

25

Time (sec)

Step Response 1.4 tf ss 1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15 Time (sec)

20

25


Step Response 1.4 tf ss 1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15

20

25

30

Time (sec)

Step Response 1.4 tf ss 1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15 Time (sec)

20

25

30


Step Response 1.4 tf ss 1.2

Amplitude

1

0.8

0.6

0.4

0.2

0

0

5

10

15

20

25

Time (sec)

4.11 Consider the system described by the transfer function

Y (s) 3 = G ( s) = U ( s) ( s + 1)( s + 3) .

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)

Y ( s) 3 3 b( s ) = G ( s) = = 2 = U ( s) ( s + 1)( s + 3) s + 4s + 3 a( s)


u

1/a(s)

ξ

b(s)

y

Note that ξ is a partial state.

The states are the outputs of the integrators

Control Canonical Form Block Diagram u

1/s

Σ

1/s

3

y

-4 -3

b) G(s) in partial fractions

3 A B A( s + 3) + B ( s + 1) = + = ( s + 1)( s + 3) ( s + 1) ( s + 3) ( s + 1)( s + 3) A( s + 3) + B( s + 1) s ( A + B ) + ( 3 A + B ) = ⇒ A + B = 0;3 A + B = 3 ( s + 1)( s + 3) ( s + 1)( s + 3)

G(s) =

A = −B ⇒ 3 A − A = 2 A = 3 ⇒ A = 1.5 & B = −1.5 3

( s + 1)( s + 3)

=

1.5 1.5 − ( s + 1) ( s + 3)


Σ u

1/s

3/2

y1

-1 Σ

1/s

Σ -3/2

-3

y

Parallel Block Diagram

y2

The states are the outputs of the integrators

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.


e(k)

u(k) Control Canonical Form

Observer Canonical Form

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.


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. 1 s2 e −1.5 s G2 ( s) = s +1 1 G3 ( s ) = s ( s +1) G1 ( s ) =

e −1.5 s s ( s +1) 1 G5 ( s ) = 2 s −1 G4 ( s) =

G ( s )  −1 The governing equation is G ( z ) = (1 − z ) Z   , which is equation (2.39) of the  s  text. The table look up for a) or G1(s) is:


G ( s) 1 1 ⇒ 1 = 3 2 s s s 2  G1 ( s )   1  T z ( z + 1) Z  = Z 3  = 3  s  2 ( z − 1)  s 

G1 ( s ) =

z − 1 T 2 z ( z + 1) T 2 ( z + 1) ⇒ G1 ( z ) = = z 2 ( z − 1) 3 2 ( z − 1) 2

The table look up for c) or G3(s) is: G (s) 1 1 G3 ( s ) = ⇒ 3 = 2 s ( s + 1) s s ( s + 1) G3 ( z ) = G3 ( z ) =

[(

) ( (

z − 1  G3 ( s )  z − 1 z T − 1 + e −T z + 1 − e −T − Te −T Z = z z ( z − 1) 2 z − e −T  s 

[(T − 1 + e ) z + (1 − e − Te )] ( z − 1) ( z − e ) −T

−T

−T

−T

The table look up for e) or G5(s) is: G ( s) 1 1 G5 ( s ) = 2 ⇒ 5 = 2 s s −1 s s −1

(

G5 ( z ) =

(

)

)

z − 1  G5 ( s )  z − 1 e T + e −T − 2 ( z + 1) Z = z z z − e −T z − e T  s 

(

)(

The matlab code is: Ts = 1; c2d(tf(1,[1 c2d(tf(1,[1 c2d(tf(1,[1 c2d(tf(1,[1 c2d(tf(1,[1

0 0]),Ts) 1],'inputdelay',1.5),Ts) 1 0]),Ts) 1 0],'inputdelay',1.5),Ts) 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.2387 z^(-1) * -----------------

)

)

)]


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.05471 z^(-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 H ( s ) =

s +1 . 0.1s +1

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 = e jw1T if T = 0.25 sec and the design is via 1) Forward rectangular rule 2) Backward rectangular rule 3) Bilinear rule 4) Bilinear with prewarping (use w1 as the warping frequency) 5) Zero-pole mapping 6) Zero-order-hold equivalent 7) 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]);


[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 Forw ard rectangular rule

H(s) continuous

1

1

0.8

0.6

0.6

0.4

0.4

0.2

0.2

Imaginary Axis

Imaginary Axis

0.8

0 -0.2

0 -0.2

-0.4

-0.4

-0.6

-0.6

-0.8

-0.8

-1 -10

-9

-8

-7

-6

-5 Real Axis

-4

-3

-2

-1

0

-1 -1.5

-1

-0.5

0 Real Axis

0.5

1


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

Imaginary Axis

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

1

Real Axis

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

Imaginary Axis

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

-0.8

-0.6

-0.4

-0.2

0 Real Axis

0.2

0.4

0.6

0.8

1


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

Imaginary Axis

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

1

Real Axis

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

Imaginary Axis

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

-0.8

-0.6

-0.4

-0.2

0 Real Axis

0.2

0.4

0.6

0.8

1


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

Imaginary Axis

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

1

Real Axis

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

Imaginary Axis

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

-0.8

-0.6

-0.4

-0.2

0 Real Axis

0.2

0.4

0.6

0.8

1


Bode Diagram 40 H back for

Magnitude (dB)

30

bilin 20

prew arp zp zoh

10

foh

0 360

Phase (deg)

270 180 90 0 -90 -1

10

0

10

1

10

Frequency (rad/sec)

The complete matlab code is: function Prob_6_3() % close all w1 = 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)


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;


Solution for Take Home Exam 2