ENع
→Lag compensation
الدرس 42 · PID control and compensators

Lag compensation

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

18 دقيقة10 خطوات5 أسئلةAdvanced
عن هذا الدرس

A servo with a good transient still trails a moving target by 1.93 rad. Ten times the gain would fix the error but makes the loop unstable. A lag compensator, (s + 0.05)/(s + 0.005), raises only the low-frequency gain: Kv goes from 0.519 to 5.04 while the damping ratio stays 0.5. Design it on the root locus, read it on the Bode plot, and see its price: a slow tail.

ستتعلّم

حدّد ما تشعر بأنك أتقنته. هذا التقييم الذاتي لا يؤثر في درجة الدرس.

شكل 42 · تفاعلي
01 / 10

A servo with good damping

This servo, G(s) = 1/(s(s+1)(s+2)), was tuned in the lesson "Choosing the gain for a target damping ratio". K = 1.037 puts the closed-loop pair at −0.333 ± 0.577j, damping ratio 0.5. The transient is good.

plant       G(s) = 1 / (s(s + 1)(s + 2))
gain        K = 28/27 = 1.037
closed-loop poles  -0.333 ± 0.577j, -2.333
damping ratio      ζ = 0.5

The step response is fine. This lesson asks
a different question: how well does the arm
follow a command that keeps moving?
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. A servo with good damping

    This servo, G(s) = 1/(s(s+1)(s+2)), was tuned in the lesson "Choosing the gain for a target damping ratio". K = 1.037 puts the closed-loop pair at −0.333 ± 0.577j, damping ratio 0.5. The transient is good.

    plant       G(s) = 1 / (s(s + 1)(s + 2))
    gain        K = 28/27 = 1.037
    closed-loop poles  -0.333 ± 0.577j, -2.333
    damping ratio      ζ = 0.5
    
    The step response is fine. This lesson asks
    a different question: how well does the arm
    follow a command that keeps moving?
  2. Follow a ramp

    Now ask the arm to follow a ramp: the camera pans at a steady 1 rad/s. The arm matches the speed but trails behind. The error settles at 1.93 rad, almost two radians late. Far too much.

    # unit ramp r = t into the loop, RK4, K = 28/27
    K, dt = 28 / 27, 0.01
    x = [0.0, 0.0, 0.0]            # y, y', y''
    f = lambda t, x: [x[1], x[2], K * (t - x[0]) - 2 * x[1] - 3 * x[2]]
    t = 0.0
    for i in range(12000):         # 120 s
        k1 = f(t, x)
        k2 = f(t + dt / 2, [a + dt / 2 * b for a, b in zip(x, k1)])
        k3 = f(t + dt / 2, [a + dt / 2 * b for a, b in zip(x, k2)])
        k4 = f(t + dt, [a + dt * b for a, b in zip(x, k3)])
        x = [a + dt / 6 * (p + 2 * q + 2 * r + s) for a, p, q, r, s in zip(x, k1, k2, k3, k4)]
        t += dt
    print(round(t - x[0], 2))       # 1.93
  3. The error is 1/Kv

    For this loop the ramp error is 1/Kv. The velocity constant Kv = lim s→0 of s·K·G(s) = K/2 = 0.519. It is the low-frequency gain on the Bode plot. Ten times less error needs Kv ten times bigger, about 5.

    Kv = lim (s→0) s · K · G(s)
       = lim  K / ((s + 1)(s + 2))
       = K / 2 = 0.519
    
    ramp error  e(∞) = 1 / Kv = 1.93 rad
    
    wanted      e(∞) ≈ 0.2 rad  →  Kv ≈ 5
    
    On the Bode plot |K·G(jω)| ≈ Kv / ω at low
    frequency: Kv is the height of that line.
    (Error constants and system type are taught in
    the lesson "System type and error constants".)
  4. Just turn K up?

    The obvious fix is ten times the gain, K = 10.37. Watch the poles: the pair slides across the imaginary axis to +0.167 ± 1.756j. The loop is unstable, as it is for any K above 6. Gain alone cannot do both jobs.

    K = 10 × 28/27 = 10.37
    
    s³ + 3s² + 2s + 10.37 = 0
    poles  +0.167 ± 1.756j,  -3.333
    
    A pole with a positive real part grows like
    e^(+0.167t): the arm swings wider and wider.
    
    The pair crosses the jω axis at K = 6 (±1.41j).
    Kv would be 5.19, but the loop is useless.
  5. Add a lag compensator

    Instead, add a lag compensator: Gc(s) = (s + 0.05)/(s + 0.005). It is one zero and one pole, the pole ten times closer to the origin. At s = 0 its gain is 0.05/0.005 = 10; at high frequency it is 1.

    Gc(s) = (s + zc) / (s + pc),   zc = 0.05, pc = 0.005
    
    Gc(0)  = zc / pc = 10       (low frequency)
    Gc(∞)  = 1                  (high frequency)
    
    The pole is nearer the origin than the zero,
    so Gc's phase is negative at every frequency:
    it makes the output lag. Hence the name.
    
    Kv with the lag = K · Gc(0) / 2 = 5·K
  6. Why near the origin?

    Both sit very close to the origin, far from the pair we care about. Seen from the old design point, they look almost the same distance and direction: together they scale the loop by 0.968 and turn it just −3.5°. The locus barely moves.

    # what the lag does at the old design point s*
    import cmath, math
    s = complex(-1/3, 3 ** -0.5)
    Gc = (s + 0.05) / (s + 0.005)
    print(round(abs(Gc), 3), round(math.degrees(cmath.phase(Gc)), 1))   # 0.968 -3.5
    
    # a factor near 1 and an angle under 5°: the
    # locus near s* hardly changes (the usual
    # lag-design rule of thumb).
  7. Re-tune on the root locus

    Find where the ζ = 0.5 ray crosses the new locus: s = −0.314 ± 0.544j, with K = 1.008. Now Kv = K × 10 / 2 = 5.04, 9.7 times bigger. The damping ratio is still 0.5; the far pole sits at −2.32.

    # walk out along the ζ = 0.5 ray until ∠(Gc·G) = -180°
    import cmath, math
    G = lambda s: 1 / (s * (s + 1) * (s + 2))
    Gc = lambda s: (s + 0.05) / (s + 0.005)
    ray = cmath.exp(1j * math.radians(120))
    def angle(r):
        a = math.degrees(cmath.phase(Gc(r * ray) * G(r * ray)))
        return a - 360 if a > 0 else a
    lo, hi = 0.05, 1.4
    for _ in range(60):
        mid = (lo + hi) / 2
        lo, hi = (mid, hi) if angle(mid) > -180 else (lo, mid)
    s = lo * ray
    K = 1 / abs(Gc(s) * G(s))
    Kv = K * Gc(0) / 2
    print(round(K, 3), round(Kv, 2))   # 1.008 5.04
  8. The same design on Bode

    On the Bode plot the lag lifts the low-frequency gain by 20 dB: the factor of 10 in Kv. Its zero sits about a decade below crossover, so crossover barely moves (0.459 to 0.451 rad/s) and phase margin drops only from 52° to 47°.

                     without lag    with lag
    K                1.037          1.008
    low-freq gain    Kv/ω           10× higher (+20 dB)
    crossover ωc     0.459 rad/s    0.451 rad/s
    phase margin     52.4°          47.3°
    
    lag corners      0.005 (pole) and 0.05 (zero),
                     the zero about ωc / 9
    
    Bode recipe: keep the crossover, put the lag's
    zero a decade below it, let the pole set the
    low-frequency boost.
  9. Run the ramp again

    Run the ramp again. At first the error follows the old curve, because the lag acts only at low frequency. Then it drains away and settles at 0.198 rad, about ten times smaller than before.

    ramp error e(t) = t - y(t), integrated (RK4)
    
                  without lag   with lag
    Kv            0.519         5.04
    e(∞) = 1/Kv   1.93 rad      0.198 rad
    
    within 2 % of the final error after about
    113 s with the lag.
  10. The price: a slow tail

    The price is a slow tail. The lag leaves a closed-loop pole at −0.055, right beside its zero, so part of the error fades like e^(−0.055t): an 18 s time constant. Lag buys accuracy; lead buys speed.

    closed-loop poles with the lag (K = 1.008):
      -0.314 ± 0.544j   the dominant pair, ζ = 0.5
      -2.32              far left
      -0.055             slow, next to the zero -0.05
    
    1 / 0.055 ≈ 18 s time constant
    
    lag   raises low-frequency gain: accuracy
    lead  adds phase near crossover: speed
    (see the lesson "Lead compensation")

اختبار يتاح بعد الخطوة الأخيرة.