You are on page 1of 12

ES322 - PW 3

PID Controllers and the Root-Locus


Solutions

March 01, 2021

Exercise 1
Consider the following system:
1
S(s) =
(s + 2)(s + 5)
1. Sketch the poles of this system.
Solution: The poles are located in s = −2 and s = −5. It has no zeros,
thus the behavior will be the behavior of a pure second-order system.
With Matlab, we define the system with:
S = zpk([], [-2 -5], 1);

Figure 1: Poles of the open-loop system

2. At first, we will use a proportional controller R(s) = k. Sketch the root


locus of the system RS(s) with the hand.

1
Solution: The root-locus is by definition the location of the poles of the
closed-loop as the gain parameter k of the regulator R varies. In Matlab
we can just compute the root-locus based with the command:
[R, K] = rlocus(S);
There are two different root-loci, namely for all k ≥ 0 and for k < 0. The
latter leads to a slower system that eventually becomes unstable, so we’ll
focus on the case k ≥ 0. This root locus 2.

Figure 2: Root locus of a proportional controller R(s) = k

To sketch this root locus (RL) with the hand, follow the rules as given in
the lectures:
ˆ The real-axis segment is located to the left of an odd number of
poles/zeros when counted from the right (for k ≥ 0).
ˆ The OL system has two poles, thus the RL has two branches
ˆ The OL system has no zeros, thus both branches end on infinity
(asymptotes). The formula says that these asymptotes are located
at θ = π and θ = −π.
ˆ When the branches meet on the real segment, they gain an imaginary
component and move symmetrically to infinity in direction θ.
3. Given these constraints:
ˆ We want a system as fast as possible.
ˆ We can’t tolerate any overshoot.
How would we choose the gain k? Verify in MATLAB1 how much this gain
would be. Where do the poles lie? How about any zeroes?
1 To compute the root-locus in Matlab, use the command rlocus

2
Solution: The fastest system without overshoot is the critically damped
system, when both branches meet on the real axis. The corresponding k
is 2.25 and the closed-loop system thus has a double pole in p = 3.5 and
no zeroes:
kS 2.25
SCL = =
1 + kS (s + 3.5)2
In Matlab we can compute this with the feedback command:
k = 2.25;
sys_cl = feedback(k*S, 1)
4. Based on what you’ve found in the previous question, what is the static
error of the system in closed loop?
Solution: The static error (t → ∞) can be computed with the theorem
of Tauber applied to the closed-loop system SCL , with which we compute
the final value of the step response of this system:
2.25
lim y(t) = lim SCL (s) = = 0.1837
t→∞ s→0 3.52
The static error is thus

lim (t) = 1 − lim y(t) = 1 − 0.1837 = 0.8163


t→∞ t→∞

5. This static error is too large for our purposes. Ideally, we would like a
static error of zero. Propose the simplest controller that can achieve this
in our case and sketch by hand the root locus of this new system RS(s).
Solution: An integral controller RP (s) = 1s leads to an infinite static
gain, and thus to a zero static error. The root locus of R(s)S(s) is shown
in figure 3 and can be constructed by the same rules as above. Since we
now have 3 poles (and still no zeros), the orientation of the asymptotes is
different: they go to θ = π3 , θ = π and θ = −π 3 . Hence, the system can
become unstable when we increase k too much, which was not the case
above.
R = tf([1], [1 0])
figure; rlocus(R*S);

3
k
Figure 3: Root locus of an integral controller RP (s) = s

6. With MATLAB, find the value of the k that satisfies both conditions from
above, and verify that the static gain is indeed zero2 .
Solution: Once again, we place the poles of the closed loop system in
the critically damped position, thus where the branches meet on the real
axis. The corresponding k is 4.06 and the step response is given in 4. This
system has indeed a zero static error.

k
Figure 4: Step response of CL with integral controller RP (s) = s
2 To compute a system in closed-loop: either express the full equation e.g. RS
1+RS
or use
the command feedback

4
This system has 3 poles: one fast pole in s ≈ −5.2 and two confounded
slow poles in s ≈ −0.87.
7. The system we have now is too slow. How can we make it faster? Start
from the initial system and use a PID controller.
Solution: The slower response can be seen in figure 3 where the left-most
pole necessarily is located to the right of the slowest pole of the open-
loop system. This is a consequence of placing a pole in s = 0 and the
construction rules of the root locus. The most obvious way to make the
system faster is to place a pole in s = −2, which cancels the slowest pole
of S. We do this by including a zero of R(s) in the same spot. R(s) also
contains a pole in s = 0 to obtain a zero static error:

(s + 2)
RP I (s) =
s
. By choosing k, we obtain a PI controller: kRP I (s) = k + 2k
s with kP = k
and kI = 2k. When we choose k = 6.25, we get critically damped system
(see the root locus of R(s)S(s) ). In Matlab, we do this with:
ps = pole(S)
R = zpk([ps(1)], [0], 1)
figure; rlocus(R*S)
k=6.25;
sys_cl = feedback(k*R*S, 1);

(s+2)
Figure 5: Root locus of a PI controller RP I (s) = s

When we compare the step response of this system in figure 6 with the one
of the I controller in figure 4, we notice that this system is faster (measured
by both rise time or settling time since we don’t have overshoot) by a factor
of about 3. This system has strictly speaking three poles:

5
(a) One in s = −2, which is cancelled by the zero of R(s). However,
mind that this pole will be present if we consider other input-output
relations, e.g. when we investigate the impact of a disturbance η on
the command u - see PW 2 on feedback.
(b) Two confounded poles in s = −2.5.
The poles of this critically damped system are about three times as fast
as the the I-controller (recall: poles in s ≈ −0.87), hence the threefold
decrease in rise time.

(s+2)
Figure 6: Step response of CL with PI controller RP I (s) = s

Question: Can the closed-loop be made even faster? If so, what is the
true limit on the system speed?

6
Exercise 2
Consider the following system (with TS = 0.5s):
z+1
S(z) =
(z − 2.7)(z − 0.4)

1. Sketch the poles and zeros of S(z). What about the stability of the open-
loop system?
Solution: Poles are located in z = 2.7 and z = 0.4, with a single zero in
z = −1 - see figure 7. This is necessary if we want that the second sample
u(n = 1) of a step response is not zero. The first pole has a modulus
larger than one and thus is the open-loop system unstable. The first role
of feedback will be to render the closed-loop system stable.

Figure 7: Poles and zeros of S(z)

2. Sketch the root locus of S(z) with the hand. Then verify with Matlab.
Solution: Since the OL system has two poles and a single zero, the root
locus will have an asymptote on θ = π for k ≥ 0. The complete trace of
the root locus is shown in figure 8. All this can be computed in Matlab
with:
Ts = 0.5;
S = zpk([-1], [2.7, 0.4], 1, Ts);
figure; pzmap(S);
figure; rlocus(S);

7
Figure 8: Root locus of S(z)

3. We wish to implement a proportional controller R(z) = k. Can this kind


of controller stabilize the system?
Solution: The behavior of the root locus in figure 8 shows that a simple
proportional controller can never stabilize the system. Indeed, for every
choice of k there is a pole of the closed-loop system that will be located
outside the unit circle and will thus result in an unstable system.
4. Propose a controller R(z) that stabilizes the system.
ˆ Sketch the root-locus of the combination controller-system RS(z)
with the hand.
ˆ Check the step response of the system in closed-loop3
ˆ Give the recurrence equation that you will use to implement this
controller.
ˆ Check the behavior of the command u(n) when you apply a step to
the input of the system in closed-loop. |u(n)| should not exceed 20
[units].
If any of these steps poses a problem, adapt your controller and start over.
Solution:
ˆ Attempt 1
We propose (naively!) to just cancel the unstable pole in z = 2.7 by
putting a zero on top of it in the controller R1 (z) = (z − 2.7). THIS IS
NOT ALLOWED. Two reasons:
1. Since the poles of the systems are determined by (a) a modeling step
(establishing the differential equations, estimating the parameters)
and (b) a discretization step, the exact location of the poles is not
3 For now, zero static gain is not a requirement

8
known. Thus if we try to cancel unstable poles by putting a zero
on top of them, we may be a bit off and the closed-loop system will
remain unstable.
2. Even if everything went perfectly, the pole will not be canceled for
other input-output relations, like for disturbances η on the command
u. Thus the system will remain unstable for these input-output re-
lations.
ˆ Attempt 2
We propose (again naively!) to cancel the stable pole in z = 0.4 with
R2 (z) = k(z − 0.4). The root locus of R2 (z)S(z) now becomes:

Figure 9: Root locus of R2 (z)S(z)

To stabilize the system, we must choose k ≥ 0.88. Picking k = 0.9, gives


the step response in figure 10. All this is done in Matlab with:

R = zpk([0.4],[],1, Ts)
figure; rlocus(R*S)
k=0.9;
sys_cl = feedback(k*R*S, 1);
figure; step(sys_cl);

9
Figure 10: Step response of SCL (z)

U (z)
However, we cannot implement this controller, since with R(z) = E(z) =
k(z − 0.4) corresponds the following recurrence equation:

u(n) = k((n + 1) − 0.4(n))

thus we need to have knowledge of a future error (n + 1). The reason is
that our controller is not proper (degree of numerator > degree denom-
inator). Matlab will give an error when trying to simulate the behavior
of just R2 (z) (e.g. when computing the step response of R2 (z) or even
U (z)
W (z) ).

ˆ Attempt 3
We can make R2 (z) proper by delaying it by 1 time step: R3 (z) =
z −1 R2 (z) = k(1 − 0.4z −1 ). The recurrence relation is then

u(n) = k((n) − 0.4(n − 1))

which is perfectly realizable.

The controller still has a zero in z = 0.4 but now also has a pole in z = 0.
The root locus becomes:

10
Figure 11: Root locus of R3 (z)S(z)

This system can be stabilized since part of the two branches are simul-
taneously located within the unit circle, but the range of valid k’s is not
that large.
By choosing k = 0.88, we obtain this step response:

Figure 12: Step response of SCL (z)

When we simulate a step applied to the reference w on the system com-


mand u or, in other words, simulate the step response of4
U (z) R(z)
=
W (z) 1 + R(z)S(z)
4 This is done by defining uw = f eedback(k ∗ R3, S)

11
to monitor the behavior of U (z), we find the step response in figure 13 (in
blue).
Notice that we exceed the constraint |u(n)| ≤ 20, thus we should again
iterate over the different steps. However, by choosing the k above slightly
larger (e.g. k = 0.9), we are able to respect the input constraint (see figure
13 in red).

U (z)
Figure 13: Step response of W (z) for different k

12

You might also like