38
Matlab program template % enter plant transfer function Gp(s) nump = …. ; denp=…. ; %Draw root locus %adjust window size, x-limit, y-limit, etc % enter desired closed loop step response specification: % you may allow both uppper and lower limits … … % convert from specs to zeta, omegan, sigma, omegad … … % hold the graph, and plot allowable region for pole location on RL graph … … % obtain controller transfer function %if PD or lead needed, design a PD or lead %if PI or lag needed, design a PI or lag %design P, or final decision on overall gain % get controller TF % obtain closed loop transfer function from Gp(s) and C(s) … … numcl=…; dencl=…; … … % obtain closed-loop step response … … % compute actual step response specs, using your program from last week … … % are they good? % compute the actual closed-loop poles, place “x” at those locations … … % are they in the allowable region?

Matlab program template

  • Upload
    lavi

  • View
    30

  • Download
    0

Embed Size (px)

DESCRIPTION

Matlab program template. % enter plant transfer function Gp(s) nump = …. ; denp=…. ; %Draw root locus … %adjust window size, x-limit, y-limit, etc … % enter desired closed loop step response specification: % you may allow both uppper and lower limits … … - PowerPoint PPT Presentation

Citation preview

Page 1: Matlab program template

Matlab program template% enter plant transfer function Gp(s)nump = …. ; denp=…. ; %Draw root locus…%adjust window size, x-limit, y-limit, etc…% enter desired closed loop step response specification: % you may allow both uppper and lower limits… …% convert from specs to zeta, omegan, sigma, omegad… …% hold the graph, and plot allowable region for pole location on RL graph… …% obtain controller transfer function

%if PD or lead needed, design a PD or lead…%if PI or lag needed, design a PI or lag…%design P, or final decision on overall gain…

% get controller TF… % obtain closed loop transfer function from Gp(s) and C(s)… … numcl=…; dencl=…; … …% obtain closed-loop step response… …% compute actual step response specs, using your program from last week… …% are they good?% compute the actual closed-loop poles, place “x” at those locations… …% are they in the allowable region?

Page 2: Matlab program template

Controller design by R.L.Typical setup:

C(s) G(s)

01

1

1

sd

sn

ps

zsK

sdsn

sG

21

21)(psps

zszsKsC

Controller Design Goal: 1.Select poles and zero of C(s) so that R.L. pass through desired region2.Select K corresponding to a good choice of dominant pole pair

Page 3: Matlab program template

Proportional control design

1. Draw R.L. for given plant

2. Draw desired region for poles from specs

3. Pick a point on R.L. and in desired region• Use ginput to get point and convert to complex #

4. Compute K using abs

and polyval

5. Obtain closed-loop TF

6. Obtain step response and compute specs

7. Decide if modification is needed

01sd

snK

DPGsGK

11

Page 4: Matlab program template

When to use:If R.L. of G(s) goes through

the desired region for c.l. poles

What is that region:– From design specs, get desired Mp, ts, tr,

etc.– Use formulae for 2nd order system to get

desired ωn , ζ, σ, ωd

– Identify / plot these in s-plane

Page 5: Matlab program template

Example:

When C(s) = 1, things are okayBut we want initial response speed as fast

as possible; yet we can only tolerate 10% overshoot.

Sol: From the above, we need that means:

6

1

ss

%10pM6.0

C(s)

Page 6: Matlab program template

This is a cone around –Re axis with ±60° area

We also want tr to be as small as possible.i.e. : want ωn as large as possible

i.e. : want pd to be as far away from s = 0 as possible

1. Draw R.L.

2. Pick pd on R.L., in cone & | pd | max

3. 2561

ddd

pppG

K

Page 7: Matlab program template

Root Locus

Real Axis

Imag

inar

y A

xis

-7 -6 -5 -4 -3 -2 -1 0 1-5

-4

-3

-2

-1

0

1

2

3

4

5

System: sysGain: 24.9Pole: -3 - 3.99iDamping: 0.601Overshoot (%): 9.43Frequency (rad/sec): 4.99

n=1; d=[1 6 0]; sys_p = tf(n,d);rlocus(sys_p)[x,y]=ginput(1); pd=x+j*y;Gpd = evalfr(sys_p,pd); K=1/abs(Gpd); K=25

Page 8: Matlab program template

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.60

0.2

0.4

0.6

0.8

1

1.2

1.4

System: sysTime (sec): 0.79Amplitude: 1.09

Step Response

Time (sec)

Am

plit

ud

e

sys_cl = feedback(K*sys_p,1);step(sys_cl);

Page 9: Matlab program template

Example:

Want: , as fast as possibleSol:

1. Draw R.L. for2.

Draw cone ±45° about –Re axis3. Pick pd as the crossing point of

the = 0.7 line & R.L.4.

62

10

ssssG

%5pM

9368.010621

dddd

P ppppG

K

7.0%5 pM

6)2(

10

sssC(s)

pd=-0.9+j0.9

Page 10: Matlab program template

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

-15

-10

-5

0

5

10

15

20Root Locus

Real Axis

Imag

inar

y Ax

is

Page 11: Matlab program template

0 1 2 3 4 5 6 7 80

0.2

0.4

0.6

0.8

1

Step Response

Time (sec)

Am

plit

ud

e

Overshoot is a little too much.

Re-choose pd =-0.8+j0.8

Page 12: Matlab program template
Page 13: Matlab program template

-6 -5 -4 -3 -2 -1 0 1-5

0

50.120.240.380.50.640.76

0.88

0.97

0.120.240.380.50.640.76

0.88

0.97

123456

Root Locus

Real Axis

Imag

inary

Axis

Page 14: Matlab program template

ylim([0,yss*(1+Mp)])

0 1 2 3 4 5 6 70

0.2

0.4

0.6

0.8

1

Step Response

Time (sec)

Am

plit

ud

e

Page 15: Matlab program template

Controller tuning:

1. First design typically may not work

2. Identify trends of specs changes as K is increased.e.g.: as KP , pole

3. Perform closed-loop step response

4. Adjust K to improve specse.g. If MP too much, the 2. says reduce KP

Pd M&,,

Page 16: Matlab program template

PD controller design

• This is introducing an additional zero to the R.L. for G(s)

• Use this if the dominant pole pair branches of G(s) do not pass through the desired region

• Place additional zero to “bend” the RL into the desired region

zsKsKKsC DDP DP KKz

Page 17: Matlab program template

Design steps:

1. From specs, draw desired region for pole.Pick from region, not on RL

2. Compute

3. Select

4. Select:

dd jp dpG dd pGzpz s.t.

dd pGz tan i.e.

DP

ddD

KzKpGzp

K1

Gpd=evalfr(sys_p,pd)phi=pi - angle(Gpd)

z=abs(real(pd))+abs(imag(pd)/tan(pi-phi))

Kd=1/abs(pd+z)/abs(Gpd)

Page 18: Matlab program template

Example:

Want:Sol:

(pd not on R.L.)

(Need a zero to attract R.L. to pd)

%2sec2%,5 fortM sp 7.0%5 pM

24

sec2 s

s tt

22 Choose jpd 707.0,2,2 d

)2(

1

ssC(s)

Page 19: Matlab program template
Page 20: Matlab program template

2.

3.

4.

4

tan dz

22222

1

jjdpG

222 jj

4

3

4

5

24

3

4122

8

222222422

11

DP

D

KzKjjj

K

ssC 28

44

3 dpG

Page 21: Matlab program template

0 0.5 1 1.5 2 2.5 30

0.2

0.4

0.6

0.8

1

Step Response

Time (sec)

Am

plit

ud

e

ts is OK

But Mp too large

To redesign:Reduce d

pd=-2+j1.5

Page 22: Matlab program template

Gpd = evalfr(sys_p, pd)Gpd = - 0.1600 + 0.2133i

phi = pi - angle(Gpd)phi = 0.9273

z = abs(real(pd)) + abs(imag(pd)/tan(pi - phi))z = 3.1250

Kd = 1/abs(pd+z)/abs(Gpd)Kd = 2

Kp = z*KdKp = 6.2500

sys_c=tf([Kd Kp], 1);sys_cl=feedback(sys_c*sys_p, 1)Transfer function: 2 s + 6.25----------------s^2 + 4 s + 6.25

step(sys_cl); ylim([0 yss*(1+2*Mp)])

Page 23: Matlab program template

0 0.5 1 1.5 2 2.5 30

0.2

0.4

0.6

0.8

1

Step Response

Time (sec)

Am

plit

ud

e

Page 24: Matlab program template

Drawbacks of PD• Not proper : deg of num > deg of den

• High frequency gain → ∞:

• High gain for noiseSaturates circuits

Cannot be implemented physically

as jKK DP

Page 25: Matlab program template

Lead Controller

• Approximation to PD

• Same usefulness as PD

• It contributes a lead angle:

0

zpps

zsKsC

zppC dd

ppd

Page 26: Matlab program template

Lead Design:

1. Draw R.L. for G2. From specs draw region for desired

c.l. poles3. Select pd from region

4. LetPick –z somewhere below pd on –Re axisLetSelect

dd jp dpG

121 ,zpd 2 s.t. ppp d

2tan i.e. dp

C(s) G(s)

Page 27: Matlab program template

• There are many choices of z, p

• More neg. (–z) & (–p) → more close to PD & more sensitive to noise, and worse steady-state error

• But if –z is > Re(pd), pd may not dominate

dd

d

dpdp

zdp pGzp

pp

pGK

1Let

ps

zsKsC

:is controllerYour

Page 28: Matlab program template

Example: Lead DesignMP is fine,

but too slow.Want: Don’t increase MP

but double the resp. speed

Sol: Original system: C(s) = 1

Since MP is a function of ζ, speed is proportional to ωn

5.022,2 nn

4224 TF c.l.

ss

C(s))2(

4

ss

Page 29: Matlab program template
Page 30: Matlab program template

Draw R.L. & desiredregion

Pick pd right at the

vertex:

(Could pick pd a little

inside the region to allow “flex”)

5.0 new want weHence 4 new nω

322 jpd

Page 31: Matlab program template

Clearly, R.L. does not pass through pd, nor the desired region.need PD or Lead to “bend” the R.L. into region.(Note our choice may be the easiest to achieve)

Let’s do Lead:

2 ddd pppG

623

2

Page 32: Matlab program template

Pick –z to the left of pd

4,4Pick zz

3

41

dp

663then 12

2tanthen dp 8322

3

1

7

2

4

1

dpdppdp

zdpK

8

47 s

ssC

Page 33: Matlab program template

0 0.5 1 1.5 2 2.5 30

0.2

0.4

0.6

0.8

1

1.2

Step Response

Time (sec)

Am

plit

ud

e

Speed is doubled, but over shoot is too much.

Page 34: Matlab program template

0 0.5 1 1.5 2 2.5 30

0.2

0.4

0.6

0.8

1

1.2Step Response

Time (sec)

Am

plit

ud

e

8

47

s

ssC

10

46

s

ssCChange controller from to

To reduce the gain a bit, and make it a little closer to PD

Page 35: Matlab program template

Particular choice of z :

2221

ddddd

pABpApzpzOzp

ppd2

OpOAp dd dp

OApBp dd bisect

s.t. B Choose

ABpOBp dd

OApd2

1

dp2

1

22

dp

Page 36: Matlab program template

1tan dz 2tan dp

322 :example prev.In jpd 32,2 d

get weprocedure, above Follow

46.5

93.273.4 s

ssC

359.0,%21 :step c.l. rp tM

repeat. , 5.2 to2 change σ

375.0,%1.16 :step c.l. rp tM

Page 37: Matlab program template
Page 38: Matlab program template