C6 · Lesson 51 · Feedback lab
Loop gain, phase margin and peaking in NumPy
Stability analysis comes down to one function, the loop gain . Where its magnitude crosses one, its phase tells you how close the loop is to oscillating, and the closed-loop response's peak shows the same thing from the outside. In this lab you'll compute the loop gain of a multi-pole amplifier, find its crossover and phase margin by bisection, and measure the closed-loop peaking, then use them to see how much margin it takes to get a flat response.
- The closed-loop response of an amplifier with , a dominant pole at 10 Hz and a second pole at , with feedback factor β.
- With β = 1 (a follower) and = 1 MHz the response peaks about 1.2 dB before rolling off: 52° of margin.
- Raise or lower β: the peak disappears. Lower : it grows into a sharp resonance, a loop about to ring.
Predict
A follower's loop gain has a dominant pole and a second pole at the follower's GBW. How much does its closed-loop response peak?
About 1.2 dB. That loop has about 52° of phase margin; the closed-loop magnitude rises a little above its DC value just before rolling off. Peaking appears when the margin falls below about 65°, and grows quickly below 45°.
Name it
The loop gain
For an amplifier with DC gain and poles (in hertz), with feedback β:
In NumPy, start with as a complex array the length of f and divide by each factor.
Crossover and phase margin
falls monotonically, so bisection finds the crossover where ; search on so the steps are even across decades. The phase margin is
computed from the arctangents, since np.angle wraps to ±180° and can't tell 190° of lag from −170°.
Closed-loop peaking
The closed-loop gain is . Sample it densely on a logarithmic grid and compare its largest magnitude with its DC value . For two poles, about 65° of margin gives a maximally flat response, 45° gives 2.3 dB of peaking, and 30° about 6 dB.
Worked example
A follower (, poles at 10 Hz and 1 MHz). Find its crossover and phase margin.
Show the solution
- Crossover. Bisection gives = 786 kHz.
- Phase from each pole. so PM = 51.8°.
- Compare the quick estimate. With at GBW (1 MHz) it gives 45°; the exact crossover is lower, so the margin is better.
Answer the loop crosses over at 786 kHz with a phase margin of 51.8°.
Worked example
The same amplifier with β = 0.1 (a gain of 10). Find its margin.
Show the solution
- Crossover. The loop gain is ten times smaller, so it crosses one at 99.5 kHz, a decade below the second pole.
- Phase margin. PM = 84.3°, and the closed-loop response doesn't peak at all.
- The pattern. Higher closed-loop gain means less loop gain and more margin.
Answer the phase margin is 84.3°, with crossover at 99.5 kHz.
Check
A single-pole amplifier ( = 10000, pole at 100 Hz) has β = 0.01. What is at 50 kHz?
Check
A loop crosses over at 0.5 MHz, far above its dominant pole, with further poles at 1 MHz and 40 MHz. What is its phase margin?
Check
Write loop_gain(f, A0, beta, poles) (complex at the frequencies f) and phase_margin(A0, beta, poles) returning (fc, pm): the crossover by bisection on between 1 Hz and 10¹² Hz, and the margin from the arctangents.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write peaking_db(A0, beta, poles): the closed-loop gain's maximum over np.logspace(0, 12, 200001) Hz, in dB relative to its DC value .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why does a smaller phase margin show up as peaking in the closed-loop response?
The closed-loop gain is , and near crossover the loop gain has a magnitude close to one. If its phase there is close to −180°, then is the sum of 1 and a vector pointing nearly the opposite way, so it becomes small, and dividing by a small number makes the closed-loop gain rise above its low-frequency value. With a large phase margin the loop gain's vector points well away from −1 and never gets small. Peaking in frequency is the same thing as ringing in time: both come from closed-loop poles close to the imaginary axis.
Practice
Keep practicing
5 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.