ENع
←Time delay
Lesson 36 · Frequency response

Time delay and lost phase

16 min10 steps5 questionsAdvanced
About this lesson

A pure time delay hands a signal on unchanged, only late. On the Bode plot that means no change in size but a phase loss of ωT that grows without limit. Follow one loop with a 45° phase margin as its measurement arrives 0.5 s, 0.785 s and then 1 s late: the margin shrinks, the loop rings forever, then goes unstable. The Nyquist plot shows the same story, and lowering the gain shows the cure.

You'll learn to

Tick what you feel confident about. These self-checks do not affect your lesson score.

Fig 36 · Interactive
01 / 10

A loop with a 45° margin

Our loop: a controller K/s, K = 1.41, drives a plant 1/(s + 1). Its open-loop Bode plot crosses 0 dB at ωc = 1 rad/s, where the phase is −135°. So the phase margin (lesson: Gain margin and phase margin) is 45°.

open loop  L(s) = K / (s (s + 1)),  K = √2

import math
K = math.sqrt(2)
def mag(w):   return K / (w * math.sqrt(1 + w*w))
def phase(w): return -90 - math.degrees(math.atan(w))
print(mag(1.0))          # 1.000  -> ωc = 1 rad/s
print(phase(1.0))        # -135.0
print(180 + phase(1.0))  # 45.0  phase margin
Loading figure…
or ← →
Read the lesson step by step
  1. A loop with a 45° margin

    Our loop: a controller K/s, K = 1.41, drives a plant 1/(s + 1). Its open-loop Bode plot crosses 0 dB at ωc = 1 rad/s, where the phase is −135°. So the phase margin (lesson: Gain margin and phase margin) is 45°.

    open loop  L(s) = K / (s (s + 1)),  K = √2
    
    import math
    K = math.sqrt(2)
    def mag(w):   return K / (w * math.sqrt(1 + w*w))
    def phase(w): return -90 - math.degrees(math.atan(w))
    print(mag(1.0))          # 1.000  -> ωc = 1 rad/s
    print(phase(1.0))        # -135.0
    print(180 + phase(1.0))  # 45.0  phase margin
  2. A delay copies the signal, late

    Now the measurement reaches the controller T = 0.5 s late, like water in a long pipe. A pure delay changes nothing except arrival time: out(t) = in(t − T). Each bead on the belt keeps the value it entered with for 0.5 s.

    a pure time delay of T seconds
      out(t) = in(t - T)
      transfer function e^(-sT)
    
    from collections import deque
    T, dt = 0.5, 0.01
    belt = deque([0.0] * int(T / dt))   # 50 slots
    def delay(x):
        belt.append(x)                  # new value in
        return belt.popleft()           # oldest value out
  3. Same size at every frequency

    Feed the delay a sine. Out comes the same sine, the same height, only shifted. So its gain is exactly 1, which is 0 dB, at every frequency: |e^(−jωT)| = 1. The delay leaves the magnitude plot untouched.

    import cmath
    T = 0.5
    for w in [0.1, 1, 4, 10]:
        d = cmath.exp(-1j * w * T)
        print(w, round(abs(d), 6))
    
    0.1 1.0
    1   1.0
    4   1.0
    10  1.0     # always 1, i.e. 0 dB
  4. Faster sines lose more phase

    The lag is always 0.5 s, but a faster sine has shorter cycles, so 0.5 s is a bigger slice of each one. Phase lost = ωT radians: 28.6° at 1 rad/s, 114.6° at 4 rad/s. It grows without limit.

    phase of e^(-jωT) = -ωT radians
                      = -57.3·ωT degrees
    
    import math
    T = 0.5
    for w in [0.1, 1, 4, 10]:
        print(w, round(math.degrees(w * T), 1))
    
    0.1 2.9
    1   28.6
    4   114.6
    10  286.5
    
    a straight line on a linear ω axis,
    a plunging curve on the log axis
  5. The loop loses its margin

    Put the delay in the loop. The magnitude plot is unchanged, so crossover stays at 1 rad/s. But there the phase is now −135° − 28.6° = −163.6°. The phase margin shrinks from 45° to 16.4°.

    L(s)·e^(-sT): multiply the sizes, add the angles
    
    def phase(w, T):
        return (-90 - math.degrees(math.atan(w))
                - math.degrees(w * T))
    print(phase(1.0, 0.5))      # -163.6
    print(180 + phase(1.0, 0.5))  # 16.4
    
    lost at crossover = ωc·T rad
                      = 1 × 0.5 rad = 28.6°
  6. Less margin, more ringing

    Step the setpoint from 0 to 1 and simulate. Without delay the output overshoots 23% and settles in 7.1 s. With the 0.5 s delay it overshoots 67% and takes 26.7 s. Same controller, same plant: only the lateness changed.

    # closed loop, step r = 1, from rest
    K, T, dt = math.sqrt(2), 0.5, 0.001
    y = z = 0.0
    late = [0.0] * int(T / dt)   # the belt
    peak = 0.0
    for n in range(30000):       # 30 s
        late.append(y)
        e = 1 - late.pop(0)      # error, seen late
        z += e * dt              # controller K/s
        y += (-y + K*z) * dt     # plant 1/(s+1)
        peak = max(peak, y)
    print(round(peak, 2))        # ≈ 1.67
  7. The delay margin

    How much delay can the loop take? Divide the phase margin, in radians, by the crossover: 0.785 / 1 = 0.785 s. With exactly that delay the phase at crossover is −180° and the output rings forever at 1 rad/s.

    delay margin = PM (in radians) / ωc
    
    pm = math.radians(45)
    print(pm / 1.0)       # 0.785 s
    
    T = 0.785 s: y swings between −0.01 and 2.01
    for ever, one swing every 6.28 s (2π/ωc)
    
    the loop is on the edge of stability
  8. Too late: unstable

    At T = 1 s the delay costs 57.3° at crossover. The phase there is −192.3°, a margin of −12.3°. Each correction now arrives so late that it pushes the wrong way, and every swing is bigger than the last.

    print(phase(1.0, 1.0))   # -192.3
    print(180 + phase(1.0, 1.0))  # -12.3
    
    negative margin: the closed loop is unstable
    each overshoot is about 1.59 × the one before
    
    the controller and plant are unchanged;
    1 s of lateness alone tipped it over
  9. Nyquist: the curve is twisted

    On the Nyquist plot the delay turns each point L(jω) clockwise by ωT radians and keeps its length. Low frequencies barely move; high ones spiral round the origin. At T = 1 s the curve crosses the real axis at −1.25, beyond −1: unstable.

    L(jω)·e^(-jωT): same length, angle -ωT more
    
    import cmath, math
    def Ld(w, T):
        s = 1j * w
        return math.sqrt(2) / (s*(s+1)) * cmath.exp(-s*T)
    
    crossing of the negative real axis (T = 1):
      atan(ω) + ω = π/2  ->  ω = 0.86 rad/s
      |L| there = 1.25 > 1, so -1 is encircled
    
    python-control models a delay with
    control.pade(T, n): num, den
  10. Living with delay

    You cannot tune a delay away, only respect it. Lower K to 0.43: crossover drops to 0.40 rad/s, where 1 s of delay costs only 23°, and the margin is back to 45°. The price: settling takes 14.2 s instead of 7.1 s.

    rule of thumb: keep ωc·T small
    
    solve atan(ωc) + ωc·T = π/4  (PM = 45°)
      ωc = 0.40 rad/s,  K = ωc·√(1 + ωc²) = 0.43
    
    T = 1 s, K = 0.43: overshoot 25%, settles in 14.2 s
    T = 0,   K = 1.41: overshoot 23%, settles in 7.1 s
    
    other cures: remove the delay at its source
    (sensor nearer, faster network) or a
    controller that predicts it (Smith predictor)

Quiz Unlocks after the last step.