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

S2 · Lesson 18 · Feedback lab

Loop gain, phase margin, step response and the nulling resistor, in Python

Stability analysis is where hand estimates and simulators most often disagree, because the estimates hide their approximations: "90° minus the arctangent" assumes the dominant pole is far below crossover, and "overshoot from phase margin" assumes a pure two-pole loop. This lab computes the exact numbers instead: it finds a two-pole loop's crossover and phase margin by bisection, simulates its closed-loop step response with Runge–Kutta to measure the real overshoot, and checks the right-half-plane zero that a nulling resistor moves.

  • The curve is the closed-loop step response of a follower built from a two-pole amplifier (dominant pole far below, second pole at k times the gain-bandwidth), ζ=12k.
  • At k = 2 the overshoot is 4.3%; at k = 1 it's 16%; at k = 4 the response is critically damped.
  • The lab's simulation reproduces these values numerically from the loop's poles.

Predict

A follower uses an amplifier with A0=104, a dominant pole at 1 kHz and a second pole at 20 MHz. What phase margin does it have?

Name it

The tools

  • Loop gain: L(f)=A0β/((1+jf/p1)(1+jf/p2)). The crossover fc solves |L|=1 (bisection in log f), and the phase margin is 180°+∠L(fc).
  • Closed loop: with poles ω1,ω2 the follower obeys y′′+(ω1+ω2)y′+ω1ω2(1+A0β)y=ω1ω2A0x. Integrating it with RK4 gives the exact step response.
  • Nulling resistor: in a Miller-compensated two-stage op amp, Rz in series with Cc moves the zero from gm2/Cc to 1/(Cc(1/gm2−Rz)): infinity at Rz=1/gm2, and into the left half plane beyond.

Check

Write phase_margin(A0, p1, p2, beta): return (phase margin in degrees, crossover frequency in Hz) for the two-pole loop, bisecting in log f between 1 Hz and 1012 Hz.

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

Check

Write step_overshoot(A0, p1, p2, beta, n=200000): integrate the closed-loop equation from rest with a unit step input by RK4 over 20 natural periods (T=20/b with b=ω1ω2(1+A0β)) in n steps, and return the overshoot in percent over the final value.

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

Check

Write rhp_zero(gm2, Cc, Rz): the compensation zero 1/(Cc(1/gm2−Rz)) in rad/s (positive means right half plane), returning math.inf when Rz=1/gm2 exactly; and rz_for_cancel(gm2, Cc, p2): the Rz that puts the zero on a left-half-plane pole at −p2 (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 pm_rule(p2_over_ft): the rule-of-thumb phase margin 90°−arctan⁡(1/k) for a second pole at k times the unity-gain frequency, and pm_error(A0, p1, k): the exact margin (from phase_margin with β = 1 and p2=kA0p1) minus the rule's.

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

Explain why

Why is the phase-margin rule of thumb "90° minus arctan of the unity-gain frequency over the second pole" slightly pessimistic for a two-pole amplifier?