You are on page 1of 10

Lecture 7:Examples using compensators

Venkata Sonti
Department of Mechanical Engineering
Indian Institute of Science
Bangalore, India, 560012
This draft: March 12, 2008

Example 1:Spring Mass Damper with step input

Consider the earlier spring mass damper system with values: M=1,C=10,K=20. The loop trsnafer
function GH is given by
1
GH = 2
s + 10s + 20
We need to design a controller for a step response with the specs
zero steady state error
less than 20% overshoot
settling time less than 2 sec
Lets look at the bode diagram 1. Last lecture we found that lim GH = kp . From the bode
s0
diagram this is just the low frequency asymptote of the amplitude plot. The value is -26 dB which
is 20log10(0.05). The step response shows this value of steady state. The system is overdamped
and stable so our ideas of bandwidth will not hold. Lets reduce the steady state error with a
integral controller. Lets use 10/s. The step and bode plots are shown in figure 2. The PM is 76
degrees and so the system is quite heavily damped. The steady state error has been reduced but
the settling time is 8 sec. We can reduce the settling time by raising the gain.
Again there is only integral controller, ki=100. The phase margin has gone down to 18 deg.
There is a big overshoot. Rise time is 0.4 sec. Settling time is 8 sec. It is obvious that the system
is more unstable.
The lead compensator as seen earlier brings an additional phase margin which also raises
damping and reduces overshoot and settling time. So we design a lead compensator. We try to
give an additional 40 degrees phase margin. Right now we have about 18 degrees. However, lead
compensator also adds gain at higher frequencies. Hence, the gain crossover frequency will shift
to the right. It can be seen from the figure 3 that as we move to the right the phase curve is
dropping rapidly toward -180 and hence if we wish to add 40 degrees phase margin, we should
compensate for the dropping phase and curve and calculate for 60 degrees. So
m = 60o and a =

1 + sin(m )
1 sin(m )

step response of M=1,C=10,k=20

Bode diagram of M=1,C=10,k=20


0.05

Phase (deg); Magnitude (dB)

-20

0.045

-40

0.04

-60

Amplitude

0.035

-80
-100
0
50

0.03
0.025
0.02
0.015

100

0.01

150

0.005

200 1
10

10

0
0

10

10

0.5

Frequency (rad/sec)

1.5

Time (sec.)

Figure 1: Bode plot and step response for 1/s2 + 10s + 20. closed loop.

step response of Integral Cont

Bode Diagrams
50

0.9

0.8

50

0.7

Amplitude

Phase (deg); Magnitude (dB)

Gm=26.021 dB (at 4.4721 rad/sec), Pm=76.041 deg. (at 0.49116 rad/sec)

100
150
0

0.6
0.5
0.4
0.3

100

0.2
200

0.1
300 2
10

10

10

10

0
0

10

1.6

3.2

4.8

6.4

Time (sec.)

Frequency (rad/sec)

Figure 2: Bode plot and step response Int controller 10/s for 1/s2 + 10s + 20. closed loop.

step response for ki=100

100

50

1.8

1.6
1.4

50
Amplitude

Phase (deg); Magnitude (dB)

Gm=6.0206 dB (at 4.4721 rad/sec), Pm=18.916 deg. (at 3.0757 rad/sec)

100
0
100

1.2
1
0.8
0.6
0.4

200

0.2

300 2
10

10

10

10

0
0

10

Frequency (rad/sec)

Time (sec.)

Figure 3: Bode plot and step response Int controller 100/s for 1/s2 + 10s + 20. closed loop.
At high frequencies the gain given by a is 20log10(a) = 22.8779dB. The question is where will
this additional phase get added. Obviously, it gets added at the new gain crossover, which is
yet unknown! However, the phase is added at the center of the lead compensator bode diagram
where the amplitude is 20log10(a)/2 = 11.44dB. Hence, the frequency point which is currently
the gain crossover (gain=0dB) point must have been at -11.44 dB prior to compensation. Hence,
we look for the point where the current gain value is -11.44 dB and this is = 5.93rad/s. From

a and we can find the value of T = 1/( a ). The lead compensator is then given by
C(s) =

aT s + 1
0.6292s + 1
=
Ts + 1
0.0452s + 1

With the above compensator applied the bode and step response change to what is given in figure
4.
We use a second compensator to gain some more phase margin. However, as the curve rapidly
moves toward -180 not much is possible. See figure 5.

First lead compensator

Step response with the first lead compensator

100

1.4

50

1.2

0
1

50

Amplitude

Phase (deg); Magnitude (dB)

Gm=12.371 dB (at 13.922 rad/sec), Pm=44.635 deg. (at 6.0508 rad/sec)

100
0

0.8
0.6

100

0.4

200

0.2

300 2
10

10

10
Frequency (rad/sec)

10

a=13.92, om=5.93

0
0

10

0.5

1.5

2.5

Time (sec.)

Figure 4: Bode plot and step response after lead compensation 1

Bode plot with the second lead compensator


1.4
Gm=10.185 dB (at 19.559 rad/sec), Pm=44.723 deg. (at 10.02 rad/sec)

Step response after second lead compensator

Phase (deg); Magnitude (dB)

100

1.2

50
0

50

a=3, om=8.5

0.8
100
50

0.6

100

0.4

150
200
250 2
10

0.2
1

10

10

10

10

0
0

Frequency (rad/sec)

0.5

1.5

Figure 5: Bode plot and step response after lead compensation 2

2.5

3.5

Example: Lag compensation on the cart problem

The open-loop transfer function for this problem is :


1
Y (s)
=
U (s)
ms + b
m=1000, b=50, U(s)=10 Y(s)=Velocity output
The design criteria are:
Rise time < 5 sec
Overshoot < 10%
Steady state error <2%

2.1

Bode plot and open-loop response

The first step in solving this problem using frequency response is to determine what open-loop
transfer function to use. Just like for the Root-Locus design method, we will only use a proportional controller to solve the problem. The open-loop transfer function are shown below.
1
Y (s)
=
U (s)
ms + b
In order to use a Bode plot, the open-loop response must be stable. Let Kp equals 1 for
now and see how the open-loop response looks like. Create an new m-file and enter the following
commands.
m = 1000; b = 50; u = 500; Kp=1;
numo=[Kp]; deno=[m b];
step (u*numo,deno)
Running this m-file in the Matlab command window should give you the following plot (figure
6)
bode(numo,deno) should give you the following Bode plot also (figure 6).

2.2

Proportional controller

Lets see what system characteristics we can determine from the above Bode plot. Recall that
the bandwidth frequency (BW) (the frequency at the gain M(dB)=-6 -7.5dB) is roughly equals
to the natural frequency (Wn). Using the equation T r = 1.8/n = 1.8/BW the rise time (Tr)
for our system can be determined to be extremely long since the gain shown above do not reach
-6 -7.5dB. The damping ratio is roughly equals to the phase margin (in degrees) divided by 100.
Since our phase margin is approximately 155 degrees, the damping ratio will be 1.55. Thus, we
know that the system is overdamped (since the damping ratio is greater than 1). Finally, the
steady-state error can be found from the following equation:
e() =

1
.100% and 10(M
1 + mag

dB/20)

= mag

where M dB is the low frequency gain. For our system, since the low frequency gain M(dB) is
approximately -35dB, the steady-state error should be 98%. We can confirm these by generating
a closed-loop step response (figure 7).
5

Step response for the openloop system

Bode plot of the openloop system

10

30

Phase (deg); Magnitude (dB)

9
8

6
5
4
3
2

50
60
70
0

50

1
0
0

20

40

60

80

100

120

100 2
10

10

Time (sec.)

Frequency (rad/sec)

Figure 6: Step response and bode plot of the open loop cart system.

Step response for the closed loop system Kp=1


0.2
0.18
0.16
0.14

Amplitude

Amplitude

40

0.12
0.1
0.08
0.06
0.04
0.02
0
0

20

40

60

80

100

120

Time (sec.)

Figure 7: Step response of the closed loop cart system.

10

In terms of the Bode plot, if we can shift the gain upward so that both the bandwidth
frequency and the low frequency gain increase, then both the rise time and the steady-state
error will improve. We can do that by increasing the proportional gain (Kp). Lets increase the
proportional gain (Kp) to ,say, 100 and see what happens. Change the m-file to the following.
m = 1000; b = 50; u = 10; Kp=100;
numo=[Kp]; deno=[m b];
bode(numo,deno)
Running this m-file in the Matlab command window should give you the following Bode plot
and step response(figure 8).
Step response of the closed loop system kp=100

Bode plot of the open loop system kp=100

7
6

0
10

Amplitude

30
0

To: Y(1)

20

To: Y(1)

Phase (deg); Magnitude (dB)

10

4
3
2

50
1

100 2
10

10

10

Frequency (rad/sec)

0
0

10

15

20

25

30

35

40

Time (sec.)

Figure 8: Step response and bode plot of the closed loop cart system kp=100.
Now, the low frequency gain is about 6dB (magnitude 2) which predicts the steady-state error
of 33%. The bandwidth frequency is about 0.1 rad/sec so that the rise time should be around 18
seconds confirmed by figure 8.
As we predicted, both the steady-state error and the rise time have improved. Lets increase
the proportional gain even higher and see what happens. Change the m-file to the following and
rerun it. You should get the following Bode plot.
m = 1000; b = 50; u = 10; Kp=600;
numo=[Kp/b]; deno=[m/b 1];
bode(numo,deno)
Now, the low frequency gain is approximately 20dB (magnitude 10) that predicts the steadystate error of 9%, and the bandwidth frequency is around 0.6 that predicts the rise time of 3 sec
(within the desired value). Thus, both the steady-state error and the rise time should have been
improved. Again, lets confirm these by generating the closed-loop step response (figure 9).
If you noticed, the steady-state error will eventually reach the desired value by increasing the
proportional gain even higher. However, by the time the steady-state error reaches the desired
value, the rise time becomes too fast (unrealistic for the real physical system). Thus, lets leave
the Kp as it is and implement a lag controller to handle the steady-state error problem.

Bode plot of the open loop system kp=600

Step response of the closed loop system kp=600


10

30

8
10
7
0

Amplitude

Phase (deg); Magnitude (dB)

9
20

10
0

6
5
4
3

50

2
1

100 2
10

10

10

0
0

Frequency (rad/sec)

1.5

4.5

7.5

Time (sec.)

Figure 9: Step response and bode plot of the closed loop cart system kp=600.

2.3

Lag controller

If you take a look at the Lag or Phase-Lag Compensator using Frequency Responsesection of the
Lead and Lag Compensator page, the lag controller adds gain at the low freqencies while keeping
the bandwidth frequency at the same place. This is actually what we need: Larger low frequency
gain to reduce the steady-state error and keep the same bandwidth frequency to maintain the
desired rise time. The transfer function of the lag controller is shown below.
G(s) =

1 1 + aT s
a<1
a 1 + Ts

Now, we need to choose a value for a and T. Recall from the Lag or Phase-Lag Compensator
using Frequency Response page, the steady-state error will decrease by a factor of a. The value
T should be chosen so that two corner frequencies will not be placed close together because
transient response gets worse. So let a equals 0.05 and T equals 700 and see what happens. Copy
the following m-file and run it in the Matlab command window. You should see the following
Bode plot.
m = 1000; b = 50; u = 10; Kp=600;
numo=[Kp/b]; deno=[m/b 1];
a = 0.05; T=700; numlag = [a*T 1]; denlag = a*[T 1]; newnum = conv(numo,numlag); newden
= conv(deno,denlag);
bode(newnum,newden)
figure [numc,denc]=cloop(newnum,newden); step (u*numc,denc)
Since the low frequency gain has increased while the bandwidth frequency stayed the same,
the steady-state error should be reduced and the rise time should stay the same. Lets confirm
this by generating a closed-loop step response (figure 10)
We can see that the steady-state error has been met. However, the settling time is too long.
To fix this, raise the proportional gain to Kp=1500. With this change made, the following Bode
and step response plots can be generated. (figure 11)
8

Bode plot of the open loop system with lag compensator kp=600

Step response of the closed loop system with lag compensator kp=600
10

60

9
8

20

Amplitude

Phase (deg); Magnitude (dB)

40

20
0

6
5
4
3

50

2
1

100 4
10

10

10

0
0

10

10

10

15

20

Time (sec.)

Frequency (rad/sec)

Figure 10: Step response and bode plot of the closed loop cart system with compensator kp=600.

Step response of the closed loop system with lag compensator kp=1500Step response of the closed loop system with lag compensator kp=1500
10
60
40

8
7

20
Amplitude

Phase (deg); Magnitude (dB)

0
0

6
5
4
3

50

2
1

100 4
10

10

10

10

0
0

10

Frequency (rad/sec)

12

16

Time (sec.)

Figure 11: Step response and bode plot of the closed loop cart system with compensator kp=1500.

As you can see, the overshoot is in fact zero, the steady state error is close to zero, the rise
time is about 2 seconds, and the settling time is less than 3.5 seconds. The system has now met
all of the design requirements. No more iteration is needed.

10

You might also like