ENع
→Gain & phase margin
الدرس 33 · Frequency response

Gain margin and phase margin

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

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

The Nyquist criterion says whether a feedback loop is stable; the margins say how far it is from the edge. Cut the loop K/(s+1)³ with K = 4, send a sine round once, and read two numbers off the open-loop Bode plot: how much more gain it could take (6.02 dB) and how much more lag (27.1°). Then spend the whole gain margin and watch the closed loop oscillate.

ستتعلّم

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

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

How far from the edge?

This is the loop from the Nyquist lesson: a gain K = 4, the plant G(s) = 1/(s+1)³ and negative feedback. Nyquist said it is stable. Now we ask how stable: how far is it from the edge?

open loop    L(s) = K·G(s) = 4/(s+1)³
closed loop  y/r = L/(1 + L)

Nyquist: no encirclement of −1, so
the closed loop is stable.

A yes/no answer is not enough: a part
wears, a gain drifts. How much change can
the loop take before it goes unstable?
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. How far from the edge?

    This is the loop from the Nyquist lesson: a gain K = 4, the plant G(s) = 1/(s+1)³ and negative feedback. Nyquist said it is stable. Now we ask how stable: how far is it from the edge?

    open loop    L(s) = K·G(s) = 4/(s+1)³
    closed loop  y/r = L/(1 + L)
    
    Nyquist: no encirclement of −1, so
    the closed loop is stable.
    
    A yes/no answer is not enough: a part
    wears, a gain drifts. How much change can
    the loop take before it goes unstable?
  2. Cut the loop, send a sine

    Cut the loop at the junction and feed in a sine. It goes once through K and G and comes back changed: scaled by |L(jω)| and shifted by ∠L(jω). Sweeping ω draws the open-loop Bode and Nyquist plots.

    L(jω) = 4 / (1 + jω)³
    |L|   = 4 / (1 + ω²)^1.5
    ∠L    = −3·atan(ω)
    
    ω (rad/s)   |L|     ∠L
    0.2        3.77    −33.9°
    1.0        1.41    −135.0°
    5.0        0.030   −236.1°
    
    Small ω: comes back big, little shift.
    Large ω: comes back tiny, shifted a lot.
  3. The edge is L = −1

    Danger: a sine that comes back the same size and turned upside down, |L| = 1 and ∠L = −180°. The junction's minus sign flips it upright again, so it feeds itself for ever. On the plots: 0 dB, −180°, and the point −1.

    Join the loop again. The returning sine
    passes the minus sign at the junction:
    
      −1 × (sine shifted −180°) = the sine itself
    
    If it also came back the same size
    (|L| = 1), it would keep itself going with
    no input at all: an oscillation.
    
    edge:  L(jω) = −1
           |L| = 1  (0 dB)  and  ∠L = −180°
  4. Find where the phase hits −180°

    Slide the test frequency up the phase plot until the sine comes back exactly upside down. −3·atan ω = −180° gives ω = √3 = 1.73 rad/s, the phase crossover frequency. It does not depend on K.

    ∠L = −3·atan(ω) = −180°
    atan(ω) = 60°
    ω180 = √3 = 1.73 rad/s   (phase crossover)
    
    K only scales the size of L, never its
    angle, so ω180 stays put whatever K is.
  5. Gain margin: how much more gain

    At 1.73 rad/s the sine comes back upside down but only 0.50 as big (−6.02 dB), so it dies out. K could grow 2.0 times, 6.02 dB, before it came back full size. That headroom is the gain margin.

    # gain margin: 1 / |L| where the phase is -180°
    import math
    K = 4.0
    mag = lambda w: K / (1 + w * w) ** 1.5
    phase = lambda w: -3 * math.degrees(math.atan(w))
    lo, hi = 0.1, 10.0          # bisection on the phase
    for _ in range(60):
        mid = (lo + hi) / 2
        lo, hi = (mid, hi) if phase(mid) > -180 else (lo, mid)
    gm = 1 / mag(lo)
    print(round(lo, 2), round(gm, 2), round(20 * math.log10(gm), 2))  # 1.73 2.0 6.02
  6. Find where |L| = 1

    Now slide down the magnitude plot to where the sine comes back exactly the same size: |L| = 1, 0 dB. That happens at ω = 1.23 rad/s, the gain crossover frequency.

    |L| = 4 / (1 + ω²)^1.5 = 1
    1 + ω² = 4^(2/3) = 2.520
    ωc = 1.23 rad/s   (gain crossover)
    
    Below ωc the sine comes back bigger,
    above it smaller.
  7. Phase margin: how much more lag

    At 1.23 rad/s the sine comes back full size but shifted only −152.9°, not −180°. 27.1° more lag, from a delay or a slow sensor, would put it on the edge. That headroom is the phase margin.

    # phase margin: 180° + ∠L where |L| = 1
    import math
    K = 4.0
    mag = lambda w: K / (1 + w * w) ** 1.5
    lo, hi = 0.1, 10.0          # bisection on the size
    for _ in range(60):
        mid = (lo + hi) / 2
        lo, hi = (mid, hi) if mag(mid) > 1 else (lo, mid)
    pm = 180 - 3 * math.degrees(math.atan(lo))
    print(round(lo, 2), round(pm, 1))  # 1.23 27.1
  8. Both margins on the Nyquist plot

    The same two numbers are distances from −1. The curve crosses the negative real axis at −0.50: GM = 1/0.50 = 2.0. It crosses the unit circle 27.1° short of −1: that angle is the phase margin.

    L(jω180) = −0.50          GM = 1 / 0.50 = 2.0
    |L(jωc)| = 1, ∠L = −152.9°   PM = 27.1°
    
    Grow K: the curve grows about the origin
    until −0.50 reaches −1 (×2.0).
    Add lag: the curve turns clockwise until
    the unit-circle crossing reaches −1.
  9. Spend the whole gain margin

    Turn K up by the gain margin, 4 × 2.0 = 8. The magnitude curve rises 6.02 dB, both crossovers meet at 1.73 rad/s and both margins reach zero. Close the loop: the step response swings for ever.

    K = 8:  |L(jω180)| = 8/8 = 1, ∠L = −180°
            GM = 0 dB, PM = 0°
    closed-loop poles: ±j√3 and −3
    
    step response: swings between 0.12 and 1.66
    for ever, period 2π/√3 = 3.63 s.
    One more step up and it grows instead.
  10. More margin, calmer loop

    K = 4 (GM 6.02 dB, PM 27.1°) overshoots 54%. K = 2 (GM 12.0 dB, PM 67.6°) overshoots 30%. A common target is GM above 6 dB and PM of 30° to 60°: our K = 4 is short on phase margin.

    #          GM        PM      overshoot
    # K = 8    0 dB      0°      never settles
    # K = 4    6.02 dB   27.1°   54%
    # K = 2    12.0 dB   67.6°   30%
    
    # the same margins with python-control:
    import control
    L = control.tf([4], [1, 3, 3, 1])
    gm, pm, wcg, wcp = control.margin(L)
    # gm ≈ 2.0, pm ≈ 27.1, wcg ≈ 1.73, wcp ≈ 1.23

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