Lag-lead compensators

Updated

December 6, 2024

In this section, we study a class of frequency domain controllers known as the lead-lag compensators. To get intution, we start with the simplest form of controllers: the proportional controller.

1 Improving transient response via gain adjustment

Example 1 Consider the open-loop transfer function \[ G(s) = \frac{1000}{s(s+10)}. \] Find the value of gain \(K\) such that the gain adjusted system \(KG(s)\) has a PM of \(45 ^∘\).

Solution

We first calculate the PM of the system

From the plot, we can see that the gain plot intersects the 0dB line at \(ω = 10\sqrt{10}\) (the green circle). Thus, \(ω_{\rm gc} = 10\sqrt{10}\) rad/s. At \(ω_{\rm gc} = 10\sqrt{10}\), we have \(\angle G(j ω_{\rm gc}) = -157.5 ^∘\). Thus, \(\text{PM} = 180 ^∘ - 157.5 ^∘ = 22.5 ^∘\).

The desired PM is \(45 ^∘\). For that, we want the phase at the gain crossover frequency to be \(-180 ^∘ + 45 ^∘ = -135 ^∘\) (the cyan horizontal line). So the desired gain crossover frequency is \(ω^d_{\rm gc} = 10\) rad/s.

For that to happen, we need a gain compensation equal to 20dB, so that the cyan point in the gain plot becomes the new gain crossover frequency.

Thus, we need a gain compensation of \(K = -20 \text{dB} = \dfrac{1}{10}\).

The gain adjustment procedure can be summarized as follows:

  1. Draw the Bode plot (both gain and phase plots).
  2. Find the frequence \(ω^d_{\rm gc}\) on the phase plot that gives the desired PM.
  3. Add a gain compensation \(K\) of \(-20\log| G(ω^d_{\rm gc})|\)

Then, the system \(KG(s)\) has a PM equal to the desired PM. The drawback is that the above procedure changes the error constant of the system. For instance, in Example 1, gain adjustment changes the velocity constant from \(K_v = 100\) to \(K_v = 10\).

In the rest of the section, we design two forms of compensators that allow us to change the PM without an impact on the error constants.

2 Lag Compensator

The primary function of a lag compensator is to provide attentuation in the high-frequency range to give a system sufficient phase margin. The general form of the lag compensator is \[ KG_c(s) = K \cdot \frac {1}{α} \cdot \frac{s + \dfrac{1}{T}}{s + \dfrac{1}{αT}}, \quad α > 1. \] The lag compesnator is parameterized controller with three tunable parameters: \(K\), \(T\), and \(α\). The Bode plot of \(G_c(s)\) for \(α = 10\) is shown in Figure 1. Typically, we use this to design a compensator for type-1 system to meet requirements that can be translated in terms of phase margin and velocity constant.

Figure 1: Bode plot of \(G_c(s)\) for \(α = 10\). Note that at \(ω = 10/T\) (the green dot), the phase has returned back to zero.

Given a desired velocity constant and phase margin, we choose the parameters \(K\), \(T\), and \(α\) of the lag-compensator as follows:

  1. Determine gain \(K\) to achieve the desired error constant.

    Note that \(G_c(s)\) can be written as \[ G_c(s) = \frac{1}{α} \cdot \frac{s + \dfrac{1}{T}}{s + \dfrac{1}{αT}} = \frac{1 + sT}{1 + s α T} \] which is a normalized transfer function with unity gain. Thus, \(G_c(s)\) does not provide any gain compensation at low frequency. Therefore, it has no impact on the error constants.

    Thus, \[ \bbox[5pt,border: 1px solid] {\text{Error constant of $KG_c(s)G(s)$}} = \bbox[5pt,border: 1px solid] {K \cdot \text{Error constant of $G(s)$}} \]

  2. Determine the target phase margin and the desired gain crossover frequency.

    Consider the gain compensated system \(H(s) = KG(s)\) and check if \(H(s)\) has the desired PM. If so, we are done and don’t really need the compensator \(G_c(s)\). But typically the gain compensated system \(H(s)\) will not have the desired PM. In that case, we choose \[ \text{target PM} = \text{desired PM} + \text{($5 ^∘$ to $12 ^∘$)}. \]

    The reason that we add \(5 ^∘\) to \(12 ^∘\) to the PM is because we will follow a crude method to design a lag compensator. The \(5 ^∘\) to \(12 ^∘\) is a safety margin. We target something higher so that even if we don’t achieve the target PM, we hope that we may at least achieve the desired PM. In this course, we will always take the safety margin to be \(12 ^∘\).

    Now, we look at the phase plot of \(H(s)\), which is the same as the phase plot of \(G(s)\), and find the desired gain crossover frequency \(ω^d_{\rm gc}\) such that \[ \angle H(j ω^d_{\rm gc}) = - 180 + \text{target PM}. \] We want that at this frequency the gain plot of \(H(s)\) should pass through the 0dB line.

  3. Determine the zero (and thus the value of \(T\)).

    Look at the Bode plot of Figure 1. Observe that at frequencies above \(10/T\) (the green dot in the plot), the lag compensator \(G_c(s)\) has negligible phase, but provides a gain attentuation of \(-20 \log α\) dB. So, we choose \[ \dfrac{10}{T} = ω^d_{\rm gc}. \] With this choice, we have \[ \angle G_c(j ω^d_{\rm gc})H(j ω^d_{\rm gc}) \approx \angle H(j ω^d_{\rm gc}). \] The above relationship is an approximation rather than an equality because we are using the straight line approximations for the phase plot. In reality, the phase of \(G_c(j ω^d_{\rm gc})\) at \(10/T\) is not exactly zero. This was one of the reasons that we added a safety margin of \(5 ^∘\) to \(12 ^∘\).

  4. Determine the attentuation needed to be \(ω^d_{\rm gc}\) the gain crossover frequency

    Since \(H(s)\) did not have the desired PM (in step 2), it must be the case that \(| H(j ω^d_{\rm gc}) |_{\rm dB} \ge 0\, {\rm dB}\). We choose \(α\) such that \[| H(j ω^d_{\rm gc}) |_{dB} - 20 \log α = 0. \] This ensures that \(|G_c(j ω^d_{\rm gc}) H(j ω^d_{\rm gc}|_{\rm dB} \approx 0\,{\rm dB}\). Therefore, the PM of \(K G_c(s) G(s)\) is approximately the target PM. In practise, we are slightly off because both the gain and the phase plots were approximations.

Example 2 Consider the open loop system \[ G(s) = \dfrac{100}{s(s+10)(s+100)}. \] Suppose we want a PM of \(60 ^∘\) and a velocity constant of \(K_v = 100\). Design a lag compensator that meets this specificiation.

Solution

As a first step, we draw the Bode plot of \(G(s)\). First we normalize the numerator and the denominator: \[ G(s) = \frac{1}{10} \cdot \frac{1}{s \Bigl( 1 + \dfrac{s}{10} \Bigr) \Bigl( 1 + \dfrac{s}{100} \Bigr)}. \] The correponding Bode plot is shown in Figure 2.

Figure 2: Bode plot for \(G(s)\) of Example 2.

We now follow the steps to find \(K\), \(T\), and \(α\) parameters of the lag compensator.

  1. Determine \(K\)

    Observe that the initial \(-20\) dB line crosses the \(0\) dB line at \(ω = 0.1\). Thus, the velocity constant of \(G(s)\) is \(0.1\). [We could have obtained this from the expression of the normalized TF as well]. The desrived velocity constant is \(K_v = 100\). Thus, we want \[ K = \dfrac{\text{desired $K_v$}}{\text{current $K_v$}} = \frac{100}{0.1} = 1000 = 60\,{\rm dB}. \]

    For the next parts, we will consider the gain-compensated transfer function \(H(s) = KG(s)\). The magnitude plot of \(H(s)\) is the similar to the magnitude plot of \(G(s)\) but is shifted up by \(20 \log K = 60\) dB. The phase plot is \(H(s)\) is the same as the phase plot of \(G(s)\).

  2. Determine \(1/T\).

    The desired phase margin is \(60 ^∘\). So, we set \[\text{target PM} = 60 ^∘ + 12 ^∘ = 72 ^∘. \] So, we need to find the frequency \(ω^d_{\rm gc}\) on the phase plot of \(H(s)\) such that \[ \angle H(j ω^d_{\rm gc}) = - 180 ^∘ + 72 ^∘ = -108 ^∘. \]

    From Figure 2, we can see that \(ω^d_{\rm gc} \in (1, 10)\). From the straight line approximation plot, we have that \[ \frac{P_1 - P_{ω}}{\log 1 - \log ω^d_{\rm gc}} = -45 ^∘ \]

    Thus, \[ \log ω^d_{\rm gc} = \log 1 + \frac{P_1 - P_{ω}}{45 ^∘} = \frac{-90 + 108}{45} = \frac{18}{45} = \frac{2}{5} = 0.4. \] Thus, \[ω^d_{\rm gc} = 2.5119.\]

    Finally, we choose \[ \frac{10}{T} = ω^d_{\rm gc} \implies \frac{1}{T} = 0.25119. \]

  3. Determining \(α\)

    Now we look at the magnitude plot of \(H(s)\) and compute \(| H(j ω^{d}_{\rm gc})|\). Recall that the magnitude plot of \(H(s)\) is equal to the magnitude plot of \(G(s)\) shifted up by \(60\) dB (which is \(20\log K\)). Thus, we have \[ | H(j ω) |_{\rm dB} = | G(j ω)|_{\rm dB} + 60. \]

    From the gain plot of \(G(s)\), we have \[ \frac{G_1 - G_{ω}}{\log 1 - \log ω^d_{\rm gc}} = -20 \]

    Thus, \[ G_{ω} = G_1 + 20(\log 1 - \log ω^d_{\rm gc}) = -20 + 20(- 0.4) = -28\,{\rm dB}. \] Consequently, \[ H(j ω^d_{\rm gc}) = -28\,{\rm dB} + 60\,{\rm dB} = 32\,{\rm dB}. \]

    So, we need the lag compensator to provide an attenuation of \(32\) dB. So, we want \[ 20 \log α = 32 \implies α = 39.81. \]

Combining everything together, we get that the lag-compensator is given by

\[ KG_c(s) = 25.1193 \cdot \frac{s + 0.2512}{s + 0.0063} \]

Verification

Now we compare the Bode plot of the uncompensated system \(G(s)\) and the compensated system \(KG_c(s)G(s)\).

using ControlSystems, Plots

s = tf('s')

K = 1_000.0
Tinv = 0.25119
α = 39.81

G = 100/(s * (s+10) * (s+100))
KGc = K/α * (s + Tinv)/(s + Tinv/α)

ω = exp10.(range(-4,4,length=100))

marginplot(G, ω, label=L"$G(s)$")
marginplot!(KGc*G, ω, label=L"$KG_c(s)G(s)$")

Note that the phase margin of the compensated system is \(69.11 ^∘\) instead of the target of \(72 ^∘\). The difference explains why we were using an additional phase margin of \(12 ^∘\).

Also note that at \(ω_{\rm gc} = 2.47\) (shown by the red vertical line on the phase plot), the phase of the uncompensated system \(G(s)\) is almost the same as the phase of the compensated system \(KG_c(s)G(s)\). At the same time, the compensated system has a larger velocity constant than the uncompensated system, so provides a better error constant (which can also be read from the Bode plot).

If we had only tried the gain compensated system \(K G(s)\), the phase margin would be bad.

using ControlSystems, Plots

s = tf('s')

K = 1_000.0

G = 100/(s * (s+10) * (s+100))

ω = exp10.(range(-4,4,length=100))

marginplot(G, ω, label=L"$G(s)$")
marginplot!(K*G, ω, label=L"$KG(s)$")

Thus, the lag compensated system enables us to get the same error constant as the gain compensated system and, at the same time, have a good phase margin.

using ControlSystems, Plots

s = tf('s')

K = 1_000.0
Tinv = 0.25119
α = 39.81

G = 100/(s * (s+10) * (s+100))
KGc = K/α * (s + Tinv)/(s + Tinv/α)

CL_1 = feedback(G)
CL_2 = feedback(K*G)
CL_3 = feedback(KGc*G)

ramp(x,t) = [t] # Input needs to be a vector

res_1 = lsim(CL_1, ramp, 5)
res_2 = lsim(CL_2, ramp, 5)
res_3 = lsim(CL_3, ramp, 5)

plt = plot(size=(600,300))
plot!(plt, res_1.t, [res_1.u' res_1.y'], label=[L"u(t)" L"y_1(t)"])
plot!(plt, res_2.t, res_2.y', label=L"y_2(t)")
plot!(plt, res_3.t, res_3.y', label=L"y_3(t)")

In the above plot \(y_1(t)\) is the ramp response of the uncompensated system, \(y_2(t)\) is the ramp response of the gain compensated system, and \(y_3(t)\) is the ramp response of the lag compensated system.

Note that the uncompensated system has a large error (because it has a small error constant); the gain compensated system has a small steady-state error, but has overshoot and oscillations (because it has small phase margin); while the lag compensatoed system has small steady-state error (the error becomes much smaller if we let the system run for longer time) but has no overshoot or oscillations.

3 Lead Compensator

The general form of the lead compensaotor is \[ KG_c(s) = K \cdot \frac{1}{β} \cdot \frac{s + \dfrac{1}{T}}{s + \dfrac{1}{βT}}, \quad β < 1. \] As was the case for the lag compensator, the lead compensator is parameterized by three tunable parameters: \(K\), \(T\), and \(β\). The Bode plot of \(G_c(s)\) for \(β = 0.1\) is shown in Figure 3. Typically, we use the lead compensator to design a compensator for a type-1 system to meet requirements that can be translated in terms of phase margin and velocity constant.

Figure 3: Bode plot of \(G_c(s)\) for \(β = 0.1\). Note that the phase is the maximum at \(ω = 1/\sqrt{β}T\).

Given a desired velocity constant and phase margin, we choose the parameters \(K\), \(T\), and \(β\) of the lead-compensator as follows:

  1. Determine gain \(K\) to achieve the desired error constant.

    This step is exactly the same as in the case of the lag-compensator.

  2. Determine the required phase compensation

    • As in the case of the lag compensator, choose the target phase margin as \[\text{target phase margin} = \text{desired phase margin} + 12 ^∘. \]
    • Consider the gain compensated system \(H(s) = KG(s)\) and find its phase margin.
    • Required phase compensation is given as follows: \[ Φ_M = \text{target phase margin} - \text{phase margin of $KG(s)$}. \]
  3. Determine \(β\)

    With a bit of algebra, we can show that the maximum phase of \(G_c(s)\) satisfies: \[ \sin(Φ_M) = \frac{1 - β}{1 + β}. \] Thus, the value of \(β\) needed to achieve the required \(Φ_M\) is \[ β = \frac{1 - \sin Φ_M}{1 + \sin Φ_M}. \]

  4. Determine \(1/T\)

    As can be seen from Figure 3, the peak of the phase curve is at \[ ω_{\max} = \frac{1}{\sqrt{β} T}. \] Moreover, at that frequency \[ |G_c(j ω_{\max})| = 10 \log \frac{1}{β}\, {\rm dB}.\]

    We want \(ω_{\max}\) to be the new gain crossover frequency. In order to do so, we set \(ω_{\max}\) to be the frequency at which the magnitude of the gain compensated system is the \(-10 \log \frac 1{β}\). This ensures that \[ |K G_c(j ω_{\max}) G(j ω_{\max})|_{\rm dB} = |K G(j ω_{\max})|_{\rm dB} + |G_c(j ω_{\max})|_{\rm dB} = 0\,{\rm dB} \] so that \(ω_{\max}\) is the new gain crossover frequency. This gives us the value of \(ω_{\max}\).

    Finally, we set \[ \frac{1}{\sqrt{β}T} = ω_{\max} \implies \frac{1}{T} = ω_{\max} \sqrt{β}. \]

Example 3 Reconsider Example 2 and design a lead compensator to meet the specifications.

Solution

As a first step, we draw the Bode plot of \(G(s)\), which is shown in Figure 2. We now follow the steps to find \(K\), \(T\), and \(β\) parameters of the lead compensator.

  1. Determine \(K\)

    This step is the same as before, and we find that \[ K = 1000 = 60\,{\rm dB}. \]

  2. Determine required phase comensation

    The desired PM is \(60 ^∘\). So we set \[ \text{target phase margin} = 60 ^∘ + 12 ^∘ = 72 ^∘. \]

    Next we determine the PM of the gain compensated system \(H(s) = KG(s)\). To do so, we first find the gain cutoff frequency \(ω_{\rm gc}\), which is the frequency where \(|KG(j ω)| = 0\,{\rm dB}\), or equivalently, \(|G(j ω)| = -60\,{\rm dB}\).

    From Figure 2, we can see that \(ω_{\rm gc} \in (10, 100)\). So we have \[ \frac{G_{10} - G_{ω}}{\log 10 - \log ω_{\rm gc}} = -40, \] Thus, \[ \log ω_{\rm gc} = \log 10 + \frac{-40 + 60}{40} = 1.5. \] Hence, \(ω_{\rm gc} = 10^{1.5} = 31.6227\).

    Now we compute the phase at \(ω_{\rm gc}\). We have \[ \frac{P_{10} - P_{ω}}{\log 10 - \log ω_{\rm gc}} = -90. \] Hence, \[ P_{ω} = P_{10} + 90(1.5 - 1) = 180 ^∘. \] Thus, the \(\text{PM} = 0 ^∘\).

  3. Determine \(β\)

    The required phase compensation is given by \[ Φ_M = \text{target PM} - \text{current PM} = 72 ^∘. \] Hence, \[ β = \frac{1 - \sin Φ_M}{1 + \sin Φ_M} = 0.025. \]

  4. Determine \(1/T\)

    We now find the new gain crossover frequency. For that matter, we first find the gain at the peak of the lead compensator: \[ |G_c(j ω_{\max})| = 10 \log \frac 1{β} = 16\,{\rm dB}. \] Now, to find the new gain crossover frequency, we find the frequency at which the magnitude of the gain compensated system is the negative of \(|G_c(j ω_{\max})|\), i.e., find \(ω^d_{\rm gc}\) such that \[ |KG(j ω^d_{\rm gc})| = - |G_c(j ω_{\max})| = -16\,{\rm dB}. \] Thus, \[ |G(j ω^d_{\rm gc})| = -16\,{\rm dB} - 60\,{\rm dB} = -72\,{\rm dB}. \]

    From the Bode plot, we know that \(ω^d_{\rm gc} \in (10, 100)\). THus, \[ \frac{G_{10} - G_{ω}}{\log 10 - \log ω^d_{\rm gc}} = -40. \] Thus, \[ \log ω^d_{\rm gc} = \log 10 + \frac{-40 + 76}{40} = 1.9. \] Thus, \(ω^d_{\rm gc} = 10^{1.9} = 79.4328\).

    Hence, we have \[ \frac 1T = ω^d_{\rm gc} \sqrt{β} = 12.58. \]

Combining everything together, we get that the lead-compensator is given by

\[ KG_c(s) = 40000 \cdot \frac{s + 12.5594}{s + 502.3760} \]

Verification

Now we compare the Bode plot of the uncompensated system \(G(s)\) and the compensated system \(KG_c(s)G(s)\).

using ControlSystems, Plots

s = tf('s')

K = 1_000.0
Tinv = 12.5594
β = 0.025


G = 100/(s * (s+10) * (s+100))
KGc = K/β * (s + Tinv)/(s + Tinv/β)

ω = exp10.(range(-4,4,length=100))

marginplot(G, ω, label=L"$G(s)$")
marginplot!(KGc*G, ω, label=L"$KG_c(s)G(s)$")

Note that the phase margin of the compensated system is \(46.78 ^∘\) instead of the target of \(72 ^∘\). Thus the choice of \(12 ^∘\) safety margin did not work here and we would need to retry this with a larger safety margin.

Now we compare the performance of the lead compensator with the gain compensated and uncompensated systems.

using ControlSystems, Plots

s = tf('s')

K = 1_000.0
Tinv = 12.5594
β = 0.025

G = 100/(s * (s+10) * (s+100))
KGc = K/β * (s + Tinv)/(s + Tinv/β)

CL_1 = feedback(G)
CL_2 = feedback(K*G)
CL_3 = feedback(KGc*G)

ramp(x,t) = [t] # Input needs to be a vector

res_1 = lsim(CL_1, ramp, 5)
res_2 = lsim(CL_2, ramp, 5)
res_3 = lsim(CL_3, ramp, 5)

plt = plot(size=(600,300))
plot!(plt, res_1.t, [res_1.u' res_1.y'], label=[L"u(t)" L"y_1(t)"])
plot!(plt, res_2.t, res_2.y', label=L"y_2(t)")
plot!(plt, res_3.t, res_3.y', label=L"y_3(t)")

In the above plot \(y_1(t)\) is the ramp response of the uncompensated system, \(y_2(t)\) is the ramp response of the gain compensated system, and \(y_3(t)\) is the ramp response of the lag compensated system.

Note that the uncompensated system has a large error (because it has a small error constant); the gain compensated system has a small steady-state error, but has overshoot and oscillations (because it has small phase margin); while the lead compensatoed system has small steady-state error but has little overshoot or oscillations. (Even though we did not achieve the target PM of \(60 ^∘\), the achieved PM of \(46.78 ^∘\) is still good, so the ramp response is good.