A compensator designed on paper is only as good as the plant model behind it. Measuring the loop gain, in the lab with a network analyser or in simulation with the same method, is how you find out what the loop really does. This article explains the injection method, how to apply it to a switching converter in simulation, how to choose the injection amplitude and the sweep range, and how to read the margins from the result.
What loop gain tells you
For a feedback loop with forward path and feedback , the loop gain is . The closed-loop response depends on , so the loop is close to instability wherever approaches , that is, 0 dB at −180°. Two numbers measure the distance:
- Phase margin (PM): , where is the crossover frequency at which dB.
- Gain margin (GM): in dB, where is the frequency at which .
For a loop that behaves like a second-order system near crossover, phase margin maps to damping and step overshoot:
| Phase margin | Damping ratio ζ | Step overshoot |
|---|---|---|
| 45° | 0.42 | 23 % |
| 60° | 0.60 | 9.5 % |
The overshoot is . Typical design targets are a phase margin of 45° to 60° and a gain margin of at least 6 to 10 dB, held at every corner of line, load, temperature and tolerance.
Middlebrook's injection method
You cannot open the loop of a running converter without losing its operating point. R. D. Middlebrook's method (1975) keeps the loop closed. A small voltage source is inserted in series at a point in the loop. Call the voltage on the downstream side of the source (forward, going into the rest of the loop) and the voltage on the upstream side (returned by the loop). The measured loop gain is
It equals the true loop gain only when the impedance looking upstream from the injection point, , is much smaller than the impedance looking downstream, :
So must be small compared with 1 and with at every frequency of interest. The classic place is between the converter output, which has an output impedance of milliohms, and the top of the feedback divider, which has kilohms. There is around , and the measurement is accurate well above crossover.
On a board, the injection goes across a small resistor (10 Ω to 50 Ω) through an isolating transformer. In simulation, an ideal voltage source does the job without disturbing the DC point.
Inside a control diagram, the loop can also be broken at a signal, for example the output of the error amplifier. Signals have no source or load impedance, so the injection is exact: .
Averaged model or switching model
Averaged model. Replace the switches with their averaged equivalent, linearise at the operating point and run a small-signal AC analysis. It is fast and exact for the model, but it leaves out what averaging removes: the sampling effect of the modulator, the delay of a digital controller, and behaviour near half the switching frequency.
Switching model with perturbation. Keep the switching circuit, add a small sinusoid at frequency , let the circuit reach periodic steady state, then extract the fundamental of and with a discrete Fourier transform. Repeat at each frequency. This captures the real sampled behaviour, delays included, at the cost of one settled transient per frequency point.
Choosing the injection amplitude
The amplitude is a compromise.
- Too large and the loop leaves its linear region: the duty cycle hits a limit, the current limit acts, or the converter crosses into discontinuous conduction for part of the cycle. A practical upper bound is a perturbation of a few percent of the output voltage, and no duty saturation at any point of the cycle.
- Too small and the response is buried in switching ripple and numerical noise.
Measuring over an integer number of periods of both the injection and the switching frequency keeps the switching ripple out of the injected bin. Avoid injection frequencies at or near harmonics of .
Choosing the sweep range and the cost
- Lower limit. About a tenth of the expected crossover. Lower frequencies add little information about stability and cost a lot: each point needs several injection periods after the circuit has settled.
- Upper limit. Below half the switching frequency. The modulator samples the control signal once or twice per period, and above the measured response aliases.
- Number of points. A handful per decade is enough to find crossover and the phase at it. Add points around the crossover afterwards.
To see why the lower limit matters, consider a point at 100 Hz on a converter switching at 200 kHz. Ten injection periods take 0.1 s, which is 20,000 switching periods. At 200 time steps per period that is 4 million steps, for one point, after the initial settling.
Reading the result: an example
Suppose a perturbation sweep from 2 kHz to 90 kHz on a 200 kHz buck gives:
- crosses 0 dB at 18 kHz, where . The phase margin is .
- crosses −180° at 70 kHz, where dB. The gain margin is 11 dB.
Both meet a 45° and 6 dB target at this corner. Now repeat at the corners that move the plant most: minimum and maximum input voltage, light and full load, and the tolerance extremes of the inductor and the output capacitor. In voltage mode, the gain margin at light load is often the one that fails, because the LC resonance is barely damped there.
A large phase margin does not guarantee a gain margin. The plot below is from Voltecx: the 12 V to 3.3 V, 200 kHz buck of the PI compensator article, closed in voltage mode with the PI that design.voltageLoop designs for it (, ).
The loop crosses 0 dB at 2.52 kHz with 84° of phase margin. Above crossover the LC resonance at 5.56 kHz lifts back to just below 0 dB, right where the phase passes −180°, so the gain margin is only 2.4 dB. Judged by its phase margin alone, this loop would look very safe.
Also look for conditional stability: a region below crossover where the phase dips below −180° while the gain is still above 0 dB. The loop is stable, but a drop in gain, such as during start-up or a current limit, can make it oscillate.
Comparing with the design
If the measured crossover is lower than designed, the plant gain is lower than modelled: check the modulator gain, the sensor gain and the divider. If the phase margin is lower than designed, look for delay you did not model: digital sampling and computation, gate-driver propagation, or the sampling double pole of current mode at .
The method follows R. D. Middlebrook, "Measurement of loop gain in feedback systems", International Journal of Electronics, 1975, and the treatment in R. W. Erickson and D. Maksimović, Fundamentals of Power Electronics, 3rd ed., in its chapter on controller design.
Try it in Voltecx
analysis.loopGainbreaks a control signal (signal) and reports asmagnitudeDbandphaseDeg. With"method": "linear"it uses complex nodal analysis, exact for a linear or averaged circuit. With"method": "perturbation"it adds a small sinusoid to the running transient simulation of the switching circuit, settles each frequency and reports the periods, steps and amplitude it used. Start with few points.- In a spec,
pmMinDegandgmMinDbset the margins, and theloopobject sets the signal, the sweep limits (by default the switching frequency divided by 500 and by 20), the number of points and the amplitude.spec.verifychecks the margins at the input corners. design.robustLoopdesigns the voltage loop so that it keeps its margins at every corner of input, load, inductor, capacitor, ESR and modulator delay.
The perturbation method is slower because every frequency needs its own settled run. Read the warnings in the result before you trust a point, and compare the margins with the averaged model: a large difference usually means a delay or a sampling effect that the averaged model leaves out.