S931 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

S9 · Lesson 31 · Frequency-response lab

Evaluating loop transfer functions on the imaginary axis, counting Nyquist encirclements by phase unwrapping, finding the sensitivity peak, and computing the delay margin

Lessons 23 to 30 read stability and robustness off frequency responses: the Nyquist plot's encirclements, the margins, the sensitivity peak, how much delay a loop can swallow. Those plots are drawn by computers, and the numbers behind them come from a few simple routines: evaluate L(jω), track its phase without losing whole turns, search for peaks and crossings. In this lab you'll write them and check each against a result you can derive by hand.

  • The curve is 20log⁡|S(jω)| for the loop L=K/(s+1)3, with K on the slider.
  • Below crossover |S| is small; near crossover it peaks, and the peak grows sharply as K approaches 8, the gain at which the Nyquist plot passes through −1.
  • Above K = 8 the plot encircles −1 twice and the closed loop has two unstable poles, though |S| itself shows only a finite bump.

Predict

How many times does the Nyquist plot of L=10/(s+1)3 encircle −1?

Name it

What the lab computes

  • L(jω) for L=N(s)/D(s) given as coefficient lists, by Horner's rule on s=jω.
  • Encirclements of −1: the net number of turns of 1+L(jω) around the origin as ω runs from −∞ to ∞, counted clockwise. For a stable, strictly proper L with real coefficients, the negative-frequency half mirrors the positive one, so it's twice the unwrapped phase change from ω ≈ 0 to ω → ∞, divided by −2π. Unwrapping means adding or subtracting 2π whenever consecutive samples jump by more than π.
  • Sensitivity peak Ms=maxω⁡1/|1+L(jω)| on a dense logarithmic grid.
  • Delay margin: find the crossover ωc where |L| = 1 by bisection in log ω, then PM/ω_c with PM in radians.

Check

Write freq_resp(num, den, w): L(jω) for coefficient lists (highest power first), and bode_point(num, den, w): its magnitude in dB and phase in degrees (principal value).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write encirclements(num, den): the net clockwise encirclements of −1 by the Nyquist plot of a stable, strictly proper L, by unwrapping the phase of 1 + L(jω) on 20 000 log-spaced frequencies from 10⁻⁴ to 10⁴ rad/s and doubling for the negative frequencies. Return a rounded integer.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write peak_sensitivity(num, den): Ms on 20 000 log-spaced frequencies from 10⁻³ to 10³ rad/s.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write delay_margin(num, den): find the gain crossover by bisection on log ω between 10⁻⁴ and 10⁴ (assume |L| falls through 1 once), then return PM/ω_c in seconds, with the phase taken in (−360°, 0].

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why must a Nyquist encirclement count unwrap the phase rather than just look at where the plot ends?