+ All Categories
Home > Documents > Design of Compensators for Discrete Models with MATLAB

Design of Compensators for Discrete Models with MATLAB

Date post: 02-Apr-2015
Category:
Upload: ghulam-abbas
View: 463 times
Download: 0 times
Share this document with a friend
40
Design of Compensators for Discrete Models using MATLAB Davood Shaghaghi
Transcript
Page 1: Design of Compensators for Discrete Models with MATLAB

Design of Compensators for Discrete Models using

MATLAB

Davood Shaghaghi

Page 2: Design of Compensators for Discrete Models with MATLAB

Design of Compensators for

Discrete Models with

MATLAB

Using

CONTROL TOOLBOX

By

Davood Shaghaghi

Page 3: Design of Compensators for Discrete Models with MATLAB

In the name of Allah

This article is about the design of compensator in Matlab by using of Rltool and Control Toolbox.

I hope that this article will be useful for you and help you in your design.

Here four examples are provided from familiar book, DISCRETE CONTROL SYSTEMS – K. OGATA.

These examples can be found at the end of 4th chapter.

Best regards.

Davood Shaghaghi

Email: [email protected]

Student of Electrical Engineering

Department of Electrical Engineering

Hamadan University of Technology (HUT)

July 2009

Copying is permitted with source citation!

Page 4: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Solution:

Determination of the Z transform of the system:

Design of Compensators Using MATLAB

1

Page 5: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Please waiting until Rltool GUI is loaded …

Rltool is loaded. In the ‘Control and Estimation Tool Manager’ window you can see and change the

architecture of the system , mathematical equation of compensator (after designing),graphical

tuning (related to type of your design– Root Locus or Bode diagram-you can draw any plots needed

for design),analysis plot ( can plot impulse response, step response ,bode diagram ,nyquist diagram

and so on in form of open loop, close loop and etc.) and finally you can tune PID and other forms of

controller automatically.

2

Design of Compensators Using MATLAB

Page 6: Design of Compensators for Discrete Models with MATLAB

2

.5 %16.3

8 10

2 36

.5629 .40902

| | exp( . ) .69581

s s

d d

d

s

d

s

over shoot

z

z j

z

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

In other window (SISO Design for Design Task) you can see Root Locus plot or Bode plot or any

plots that you choose in managing window. You can add single zero, single pole and conjugate

zeroes or poles for compensator by use of specified section:

First, we must consider the problem conditions. Problem conditions – in this problem - are damping

ratio (zeta) and close-loop dominant pole.

Damping ratio value equals to 0.5, we must calculate close-loop dominant pole first:

single pole

single zero

conjugate pole

conjugate zero

Cleaning zero

or pole

3

Design of Compensators Using MATLAB

Page 7: Design of Compensators for Discrete Models with MATLAB

1

2

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

3

Setting conditions of the problem:

1) Damping ratio setting:

Setting damping ratio to value 0.5

Choose damping ratio from menu

Setting value Press OK to accept

2

1

4

Design of Compensators Using MATLAB

Page 8: Design of Compensators for Discrete Models with MATLAB

1

2

3

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

2) close-loop dominant pole setting:

You see the results in below window:

Setting close-loop dominant pole to value .5629 .4090z j

3 Type close-loop dominant pole

Press Close after

Editing or OK to

accept

Choose Region Constraint from this menu

Locus of Damping ratio

(is equal to .5)

Locus of close-loop

dominant pole (is equal to

.5629 .4090z j )

Secant location

5

Design of Compensators Using MATLAB

Page 9: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

In above window, black lines show the conditions of problem. If Root Locus passes from secant-

location of black lines (desirable conditions), your compensator satisfies conditions!

The problem has another condition and it is presence of integrator in the controller.

We set this condition by adding a pole in z=1 or select ‘Integrator’ from below menu in ‘Control and

Estimation Tool Manager’ window:

6

Design of Compensators Using MATLAB

1

Page 10: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

The result is the change in Root Locus diagram:

7

Design of Compensators Using MATLAB

You can change the location of pole

from this section.

2

Page 11: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

From ‘Control and Estimation Tool Manager’ window >> analysis plot, you can see closed-loop

step response of the system:

You see step response in below window:

8

Design of Compensators Using MATLAB

Page 12: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

But the system is sorely unstable! Here we use a zero for achieving desirable conditions. Therefore

you should change the location of zero until Root Locus passes the crossover:

How we can change the location of zero or pole?

In below window we explain this work:

Note:

When you move the pole or zero, be careful don't move the value of the gain of compensator!

You see the step response of system after adding one integrator and one zero:

First select the pole or zero that

you want to move it.

Then you can move it on

the real axis horizontally

by dragging.

?

9

Design of Compensators Using MATLAB

Page 13: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

The value of over shoot is equal to zero .We should change the gain of compensator to achieve the

desirable overshoot (16.3).

Similar to moving pole or zero, you can drag the gain (red quadrangular on the root locus) and

move it to satisfy the overshoot.

Compensator is designed!

And you see the step response of system after compensation:

10

Design of Compensators Using MATLAB

Page 14: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

For damping ratio equals to .5, overshoot value is equal to 16.3 that are satisfying.

Also the compensated system has good rise time to step input and this is desirable!

Determination of the static velocity error constant Kv:

To achieve this goal we must export the compensator transfer function(C) and maybe plant transfer

function (G) from Rltool to work space:

For exporting plant transfer function, repeat above steps, from step 4 and this time select plant G.

Now the plant transfer function and compensator are imported to work space and we can continue

the calculation:

11

Design of Compensators Using MATLAB

Page 15: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Solution:

We solve this problem analytically first and then test our solution with Rltool.

12

Design of Compensators Using MATLAB

Page 16: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

The system is type zero and so velocity error tends to be infinity! Therefore we add an integrator to

the system before compensator design (indeed we design two compensators: C1=1/s and C2=….).

As you see, velocity error is Kv=2.5. To compensate it, we multiply it by 2 until Kv be equal to 5:

13

Design of Compensators Using MATLAB

Page 17: Design of Compensators for Discrete Models with MATLAB

-150

-100

-50

0

50

100

Magnitu

de (

dB

)

10-2

10-1

100

101

102

103

104

0

90

180

270

Phase (

deg)

Bode Diagram

Gm = -5.62 dB (at 1.32 rad/sec) , Pm = -18 deg (at 1.8 rad/sec)

Frequency (rad/sec)

11 1

( )1 1

d

sTsTG sTs

sT

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Static velocity error constant is compensated. Now we can design the controller. The Bode diagram

of uncompensated system is as below:

Phase margin and gain margin is equal to -18 deg and -5.62 dB respectively. System is sorely

unstable .By using a phase-lag compensator; we will change PM to 60 deg and GM to 12 dB.

We understand that Phase lag transfer function is equal to:

14

Design of Compensators Using MATLAB

Page 18: Design of Compensators for Discrete Models with MATLAB

60 7 180 113 113 360 247

Bode Diagram

Gm = -5.62 dB (at 1.32 rad/sec) , Pm = -18 deg (at 1.8 rad/sec)

Frequency (rad/sec)

10-2

10-1

100

101

102

103

104

0

90

180

270

System: Gw

Frequency (rad/sec): 0.259

Phase (deg): 247

Phase (

deg)

-150

-100

-50

0

50

100

System: Gw

Frequency (rad/sec): 0.259

Magnitude (dB): 25.4

Magnitu

de (

dB

)

1 1 1* *.259 .0259

10 10T

20log 25.4 18.62

1 38.6 1( ) ( )

1 718.91 1d d

Ts sG s G s

Ts s

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

We should calculate the phase that leads to desirable phase margin:

According to Bode diagram, 247 phase deg occurs in 0.259 rad/sec frequency.

Magnitude of frequency response function in this frequency is equal to 25.5 dB, then:

And the compensator transfer function is equal to:

15

Design of Compensators Using MATLAB

Page 19: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Compensator is designed! For testing the results, we plot the compensated Bode diagram:

You see the Bode diagram in the next page…

16

Design of Compensators Using MATLAB

Page 20: Design of Compensators for Discrete Models with MATLAB

-200

-100

0

100

200

Magnitu

de (

dB

)

10-4

10-2

100

102

104

0

90

180

270

Phase (

deg)

Bode Diagram

Gm = 19.5 dB (at 1.3 rad/sec) , Pm = 62 deg (at 0.259 rad/sec)

Frequency (rad/sec)

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

The desirable condition has been obtained .Finally we should convert Continuous controller to

digital form.

Converting Continuous controller to digital form:

17

This coefficient is because of the Kv

compensation.

Design of Compensators Using MATLAB

Page 21: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Solution:

We should calculate the bilinear transfer function for discrete system:

Note:

We can ignore from value 3.804e-013

And consider that the system is type one

And assume the system is type one.

18

Design of Compensators Using MATLAB

Page 22: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

We Type transfer function again and ignore from mentioned value:

We should first compensate static velocity error constant. This parameter for uncompensated

system is equal to 1 but the desirable value is 10. Then:

Plot bode diagram for system (K *Gw). PM is equal to .0761 deg that less than desirable value (50

deg).

You can see the bode diagram in the next page …

19

Design of Compensators Using MATLAB

Page 23: Design of Compensators for Discrete Models with MATLAB

-50

0

50M

agnitu

de (

dB

)

10-2

10-1

100

101

102

103

104

105

90

135

180

225

270

Phase (

deg)

Bode Diagram

Gm = 0.0733 dB (at 3.18 rad/sec) , Pm = 0.0761 deg (at 3.16 rad/sec)

Frequency (rad/sec)

1( )

1d

TsG s

Ts

50 0.0761 7 56.92

1 1sin( ) sin(56.92) .838 0.0882

1 1

m

m

120 log ( ( ) ) 20 log ( )mG jw

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Here we use lead compensator to achieve desirable condition:

We calculate the requirement phase:

We should find the frequency from bode diagram that satisfies below equation:

20

Design of Compensators Using MATLAB

Page 24: Design of Compensators for Discrete Models with MATLAB

120 log( ( ) ) 20 log ( ) 10.546 5.920.0882

from bode diagram

m mG jw w

10-2

10-1

100

101

102

103

104

105

90

135

180

225

270

Phase (

deg)

Bode Diagram

Gm = 0.0733 dB (at 3.18 rad/sec) , Pm = 0.0761 deg (at 3.16 rad/sec)

Frequency (rad/sec)

-100

-50

0

50

100

System: Gw

Frequency (rad/sec): 5.92

Magnitude (dB): -10.5

Magnitu

de (

dB

)

5.921 15.92 0.568. . 0.0882

mw

mw TT T

0.568 0.050T T

1 .568( )

1 .050d

sG s

s

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

21

Design of Compensators Using MATLAB

Page 25: Design of Compensators for Discrete Models with MATLAB

-100

-50

0

50

100

Magnitu

de (

dB

)

10-2

10-1

100

101

102

103

104

105

90

135

180

225

270

Phase (

deg)

Bode Diagram

Gm = 10.4 dB (at 18.9 rad/sec) , Pm = 45.5 deg (at 5.91 rad/sec)

Frequency (rad/sec)

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Compensator is designed! For testing the results, plot the Bode diagram of compensated system:

You see Bode diagram of compensated system in below:

22

Design of Compensators Using MATLAB

Page 26: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

The phase margin after compensation, approach to 45.5. This value is less than desirable phase

margin; therefore we use Rltool to achieve this phase margin:

Please waiting until Rltool is loaded.

Then for see Bode diagram of system, operate below:

Select ‘ Open-Loop

Bode’ for Plot 2

Select this botton to show the diagram

23

Design of Compensators Using MATLAB

Page 27: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

You see Rltool window for the system with its compensator in below. Similar to problem B-4-10,

you can move the pole and zero by drag it.

We should move the pole or zero of compensator, to compensate requirement phase (50 - 45.5 =5.5

deg).

In this case we change the location of pole:

Select the pole or zero and change it’s

location when pressing the left click mouse.

We move the pole of compensator

so compensate the requirement

phase.

24

Design of Compensators Using MATLAB

Page 28: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

To achieve the transfer function of new compensator, we must export the compensator transfer

function (C) from Rltool to Work space:

Then we test the result so that is the phase margin satisfied or no?

25

Design of Compensators Using MATLAB

Page 29: Design of Compensators for Discrete Models with MATLAB

-50

0

50

100

Magnitu

de (

dB

)

10-2

10-1

100

101

102

103

104

105

90

135

180

225

270

Phase (

deg)

Bode Diagram

Gm = 10.6 dB (at 22.9 rad/sec) , Pm = 50 deg (at 6.03 rad/sec)

Frequency (rad/sec)

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Phase margin is satisfied.

Finally, we should convert the Continuous compensator to digital form:

26

This coefficient is because of Kv

compensation.

Design of Compensators Using MATLAB

Page 30: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

2

3 2

1 * (

0.358 0.05198 0.2951

1.77

) 0

( ) ( )3 0.6037 0.1694

1

magnitude condition k f z

f z Gpz

z zz

z

z

The number of samples per cycle of damped sinusoidal oscillation:

First using the magnitude condition, we find the closed loop dominant poles:

27

Design of Compensators Using MATLAB

Page 31: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Using the magnitude condition, we find that the closed loop poles are located at z=0.3164 + 0.2462i.

We determine this point on the root-locus diagram:

28

Design of Compensators Using MATLAB

Page 32: Design of Compensators for Discrete Models with MATLAB

?

1 .2462tan ( ) 37.88

.3164

o

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

z=0.3164 + 0.2462i

z=0.3164 - 0.2462i

29

Design of Compensators Using MATLAB

Closed loop dominant poles

Page 33: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

o

o

3609.5

37.88

The green line connecting the closed loop pole in the upper half of the z plane and the origin has an

angle 37.88 o .Hence, the number of samples per cycle of damped sinusoidal oscillation is:

30

Design of Compensators Using MATLAB

Page 34: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Solution:

First we should calculate the bilinear-transfer function for discrete system:

Note: we can ignore from value 3.804e-013

And assume the system is type one.

31

Design of Compensators Using MATLAB

Page 35: Design of Compensators for Discrete Models with MATLAB

-40

-20

0

20

40

60

80

Magnitu

de (

dB

)

10-2

10-1

100

101

102

103

104

90

135

180

225

270

315

Phase (

deg)

Bode Diagram

Gm = 1.69 dB (at 11.2 rad/sec) , Pm = 5.56 deg (at 9.88 rad/sec)

Frequency (rad/sec)

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

We Type transfer function again and ignore from mentioned value:

We should first compensate static velocity error constant. This parameter for uncompensated

system is equal to 1 but the desirable value is 10. Then:

Then plot bode diagram for system (K *Gw). PM is equal to 5.56 deg that less than desirable value

(50 deg).

32

Design of Compensators Using MATLAB

Page 36: Design of Compensators for Discrete Models with MATLAB

1( )

1d

TsG s

Ts

50 7 180 123 123 360 237

1 1 1* *3.2 .32

10 10T

20log 14.2 5.12

3.125 1( )

16 1d

sG s

s

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Here we use lag compensator to achieve desirable conditions:

We should calculate the requirement phase:

Design calculations:

Bode Diagram

Gm = 1.69 dB (at 11.2 rad/sec) , Pm = 5.56 deg (at 9.88 rad/sec)

Frequency (rad/sec)

10-2

10-1

100

101

102

103

104

90

135

180

225

270

315

System: Gw

Frequency (rad/sec): 3.2

Phase (deg): 237Phase (

deg)

-40

-20

0

20

40

60

80

System: Gw

Frequency (rad/sec): 3.2

Magnitude (dB): 14.2

Magnitu

de (

dB

)

33

Design of Compensators Using MATLAB

Page 37: Design of Compensators for Discrete Models with MATLAB

-50

0

50

100

Magnitu

de (

dB

)

10-3

10-2

10-1

100

101

102

103

104

90

135

180

225

270

Phase (

deg)

Bode Diagram

Gm = 15.5 dB (at 10.8 rad/sec) , Pm = 52.3 deg (at 3.21 rad/sec)

Frequency (rad/sec)

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

You can see Bode diagram of compensated system in below:

The desirable conditions have been obtained. Finally we should convert Continuous controller to

digital form.

34

Design of Compensators Using MATLAB

Page 38: Design of Compensators for Discrete Models with MATLAB

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Converting Continuous controller to digital form:

The number of samples per cycle of damped sinusoidal oscillation:

35

This coefficient is because of Kv

compensation.

Design of Compensators Using MATLAB

Page 39: Design of Compensators for Discrete Models with MATLAB

3 2

4 3 2

0.08287 0.09008 0.0561

1 *

2 0.06357

3.505 4.555 2.5

( ) 0

( ) ( )96 0.5454

1

magnitude condition k

z z z

z

f z

f z Gp zz z z

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

Similar to previous problem, we should use the magnitude condition and find the close loop poles:

Here we find the close loop poles:

The close loop poles are located at z=0.7494 + 0.3155i.

36

Design of Compensators Using MATLAB

Page 40: Design of Compensators for Discrete Models with MATLAB

Root Locus

Real Axis

Imagin

ary

Axis

-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

System: Gp

Gain: 0.992

Pole: 0.748 + 0.31i

Damping: 0.474

Overshoot (%): 18.4

Frequency (rad/sec): 4.46

?

1

o

o

.3155tan ( ) 22.83

.7494

360 15.76

22.83

o

da

vo

od

.sh

ag

ha

gh

i@g

ma

il.c

om

We determine these points on the root-locus diagram. the line connecting the closed loop pole in

the upper half of the z plane and the origin has an angle 37.88 o .Hence, the number of samples per

cycle of damped sinusoidal oscillation is: 360o/22.83o =15.76.

37

Design of Compensators Using MATLAB


Recommended