Peak Current-Mode Control and Digital Control
The Type III loop of Voltage-Mode Control needed five capacitors and resistors placed around an LC resonance whose damping changes with the load and whose ESR zero moves with temperature. Peak current-mode control removes the resonance from the outer loop: an inner loop ends each switching period when the inductor current reaches a value set by the voltage loop, so the inductor behaves like a current source and the plant becomes first-order. It also limits the current cycle by cycle and shares current between paralleled phases, which is why so many DC-DC controllers use it. It has one trap, subharmonic oscillation above 50 % duty, cured by slope compensation. The second half of the lesson moves the loop into a microcontroller: sampling, computation delay and the resolution of a digital PWM.
How peak current mode works
A clock turns the switch on at the start of each period. The sensed inductor current, (a shunt or a sense FET with gain in volts per ampere), rises with slope ; a comparator turns the switch off when it reaches the control voltage minus a compensation ramp of slope . For a buck, with the slopes in amperes per second:
Subharmonic oscillation. Suppose the valley current starts one period too high by . The rising current meets the threshold earlier, the switch opens earlier, and the current falls for longer. Following the two slopes through one period gives the error at the next valley:
Without a ramp, in steady state: below the error shrinks and alternates; above it grows, alternating every period, and the converter oscillates at . A ramp with makes at the operating duty cycle; (half the downslope) covers a buck at every duty cycle up to and is the usual choice, and makes the error vanish in one period. More ramp is not free: the loop gradually turns back into voltage mode, and the current limit (set through ) now depends on .
import numpy as np
# peak current mode, buck 20 V -> 12 V (D = 0.6), L = 100 uH, Ts = 10 us; output held at 12 V
Vin, Vo, L, Ts = 20.0, 12.0, 100e-6, 10e-6
Sn, Sf = (Vin - Vo) / L, Vo / L # A/s, on- and off-slopes
print(f"Sn = {Sn*1e-6:.2f} A/us, Sf = {Sf*1e-6:.2f} A/us, D = {Vo/Vin:.2f}")
def cycles(Se, i0, ic=4.0, n=8, Dmax=0.9):
"""valley currents, cycle by cycle: the switch opens when iL reaches ic - Se t (or at Dmax)"""
out, i = [], i0
for _ in range(n):
t_on = min((ic - i) / (Sn + Se), Dmax * Ts) # iL = i + Sn t meets ic - Se t
t_on = max(t_on, 0.0)
i = i + Sn * t_on - Sf * (Ts - t_on)
out.append(i)
return out
i_ss = lambda Se: 4.0 - Se * 0.6 * Ts - Sn * 0.6 * Ts # steady valley at D = 0.6
for name, Se in (("no ramp", 0.0), ("Se = Sf/2", Sf / 2), ("Se = Sf", Sf)):
alpha = -(Sf - Se) / (Sn + Se) + 0.0
v = cycles(Se, i_ss(Se) + 0.05)
print(f"{name:9s}: alpha = {alpha:+.3f}, valley error per cycle (mA):",
" ".join(f"{round(1e3*(x - i_ss(Se)), 1) + 0.0:+6.1f}" for x in v))Sn = 0.08 A/us, Sf = 0.12 A/us, D = 0.60
no ramp : alpha = -1.500, valley error per cycle (mA): -75.0 +112.5 -168.7 +253.1 -379.7 +220.3 -330.5 +269.5
Se = Sf/2: alpha = -0.429, valley error per cycle (mA): -21.4 +9.2 -3.9 +1.7 -0.7 +0.3 -0.1 +0.1
Se = Sf : alpha = +0.000, valley error per cycle (mA): +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0
At without a ramp, a disturbance becomes , , and keeps alternating until the duty limit bounds it: a period-two oscillation of several hundred milliamperes, audible as a whine in some designs and seen as alternating wide and narrow pulses on the switch node. With the error shrinks to times its previous value each period and is gone in eight; with it is gone after one.
The current-mode plant
With the inner loop closed, the inductor is a current source controlled by , and the output capacitor with the load gives a single low-frequency pole. Ridley's model, simplified for a buck, keeps what matters for the voltage loop:
The last factor is the sampling double pole at half the switching frequency: the inner loop samples the current once per period. Its is infinite at (the edge of subharmonic oscillation) and negative, i.e. unstable, below; at gives , and . A single-pole plant with an ESR zero needs only a Type II compensator: an integrator, a zero to restore phase, and a pole on the ESR zero.
Interactive: sampling the current ripple
A digital controller samples the inductor current or the output once per period. The lab shows what that does. A sine sampled at stands for a ripple at sampled at : the lab reads an apparent frequency of , so the ripple aliases to DC. At phase every sample hits the zero crossing, the ripple's average: this is why controllers sample in the middle of the on-time (or of the off-time), where a triangular ripple crosses its average. Move the phase to and every sample hits the peak, a fixed error. Set to : the alias is , a slow false oscillation that the loop would try to correct; synchronised sampling avoids it.
Digital control: delay and resolution
A microcontroller or DSP loop samples with an ADC, computes a difference equation, and writes a new duty cycle into a digital PWM (DPWM) counter. Three effects set its limits:
- Delay. Sampling, conversion, computation and the PWM update add a delay of to periods (the update waits for the next period). A delay is a pure phase lag, , that grows with frequency: at for .
- Discretisation. The analogue compensator becomes a difference equation, for example by the bilinear (Tustin) transform (The Bilinear Transform, Discrete PID); its accuracy falls as frequencies approach .
- Resolution. A DPWM clocked at has duty steps, each moving a buck's output by . If that step is larger than one ADC step at the output, no duty value puts the output inside the ADC's zero-error bin and the integrator hunts between two levels: a limit cycle. The DPWM must resolve finer than the ADC, by high-resolution PWM (sub-nanosecond delay lines in many 2026 microcontrollers) or by dithering the last bit.
Worked example: current mode at 20 V input, then digital
Given: the plant of the voltage-mode lesson, run from to (), , (), , , , . Digital version: delay , DPWM clock , 12-bit ADC over behind a divider.
Find: the plant's DC gain and pole, a Type II for and its margin, the margin with the digital delay, and whether the resolutions are compatible.
Solve:
Check: the compensator places its zero at and its pole on the ESR zero; the code gives the margins. The DPWM step is five times the ADC step, so this design would limit-cycle: it needs more than bits of DPWM resolution, an effective clock of about .
import numpy as np
import control as ct
# small-signal model of the peak-current-mode buck (Ridley's simplified form), D = 0.6, Se = Sf/2
Vin, Vo, L, C, RC, R, Ts, Ri = 20.0, 12.0, 100e-6, 470e-6, 0.04, 3.0, 10e-6, 0.25
D = Vo / Vin
Sn, Sf = (Vin - Vo) / L * Ri, Vo / L * Ri # slopes of the sensed voltage, V/s
Se = Sf / 2
mc = 1 + Se / Sn
k = mc * (1 - D) - 0.5
Qp, wn = 1 / (np.pi * k), np.pi / Ts
wp = 1 / (C * R) + Ts * k / (L * C)
s = ct.tf("s")
Gvc = (R / Ri) / (1 + R * Ts / L * k) * (1 + s * C * RC) / (1 + s / wp) / (1 + s / (wn * Qp) + s**2 / wn**2)
print(f"mc = {mc:.2f}, Qp = {Qp:.2f}, low-frequency pole {wp/2/np.pi:.1f} Hz, DC gain {20*np.log10(ct.dcgain(Gvc)):.2f} dB")
# Type II: integrator, zero at 1 kHz, pole on the ESR zero; gain for fc = 10 kHz
fc, fz, fp = 10e3, 1e3, 1 / (2 * np.pi * RC * C)
shape = (1 + s / (2 * np.pi * fz)) / (s * (1 + s / (2 * np.pi * fp)))
wI = 1 / abs(complex((shape * Gvc)(2j * np.pi * fc)))
Gc = wI * shape
T = Gc * Gvc
gm, pm, wpc, wgc = ct.margin(T)
print(f"Type II: wI = {wI:.0f} rad/s, crossover {wgc/2/np.pi/1e3:.2f} kHz, phase margin {pm:.1f} deg (analogue)")
# digital version: sampling + computation + PWM update add a delay Td (0.5 Ts at best, 1.5 Ts typical)
f = np.logspace(2, 4.7, 20001)
Tf = np.array([complex(T(2j * np.pi * x)) for x in f])
for Td, fcx in ((0.5 * Ts, 10e3), (1.5 * Ts, 10e3), (1.5 * Ts, 4e3)):
Tj = Tf * np.exp(-2j * np.pi * f * Td)
Tj = Tj / abs(Tj[int(np.argmin(np.abs(f - fcx)))]) # gain rescaled for crossover at fcx
i = int(np.argmin(np.abs(np.abs(Tj) - 1)))
print(f"delay {Td/Ts:.1f} Ts, crossover {f[i]/1e3:5.2f} kHz: phase margin {180 + np.degrees(np.angle(Tj[i])):5.1f} deg "
f"(delay lag {360 * f[i] * Td:4.1f} deg)")
# the compensator as a difference equation (Tustin, Ts = 10 us)
Gd = ct.sample_system(Gc, Ts, method="tustin")
b, a = Gd.num[0][0] / Gd.den[0][0][0], Gd.den[0][0] / Gd.den[0][0][0]
print("u[n] = " + " ".join(f"{-c:+.5f} u[n-{j}]" for j, c in enumerate(a[1:], 1))
+ " " + " ".join(f"{c:+.4f} e[n-{j}]" if j else f"{c:+.4f} e[n]" for j, c in enumerate(b)))
# resolution: DPWM step on the output against one ADC step
f_clk, n_adc, Vfs, H = 100e6, 12, 3.3, 2.5 / 12
n_pwm = f_clk * Ts
dV_pwm = Vin / n_pwm
dV_adc = Vfs / 2**n_adc / H
print(f"DPWM: {n_pwm:.0f} steps -> {1e3*dV_pwm:.1f} mV at the output; ADC LSB at the output {1e3*dV_adc:.2f} mV")
print(f"DPWM bits needed > {np.log2(Vin / dV_adc):.1f}, i.e. an effective clock of {Vin/dV_adc/Ts/1e6:.0f} MHz")mc = 1.75, Qp = 1.59, low-frequency pole 119.6 Hz, DC gain 21.08 dB
Type II: wI = 44692 rad/s, crossover 10.00 kHz, phase margin 77.5 deg (analogue)
delay 0.5 Ts, crossover 10.00 kHz: phase margin 59.5 deg (delay lag 18.0 deg)
delay 1.5 Ts, crossover 10.00 kHz: phase margin 23.5 deg (delay lag 54.0 deg)
delay 1.5 Ts, crossover 4.00 kHz: phase margin 53.2 deg (delay lag 21.6 deg)
u[n] = +1.57983 u[n-1] -0.57983 u[n-2] +1.5413 e[n] +0.0939 e[n-1] -1.4474 e[n-2]
DPWM: 1000 steps -> 20.0 mV at the output; ADC LSB at the output 3.87 mV
DPWM bits needed > 12.3, i.e. an effective clock of 517 MHz
The analogue Type II reaches at with three parts, against the Type III's five. A half-period delay (sampling right before the update) costs ; the typical periods cost and leave only , a ringing loop. Lowering the crossover to restores . That is the usual price of digital control: either a lower bandwidth, or a faster sampling and update scheme (double-update PWM, sampling just before the update, predictive control). The difference equation has a pole at (the integrator) and one at (the ESR-zero pole).
Guided lab: watching subharmonic oscillation on a 12 V board
Hand calculation. For a current-mode buck board (many controllers let you change the slope-compensation capacitor or resistor), compute , and the internal from the datasheet, and the input voltage at which with the ramp removed or reduced.
Simulation. Enter your values in the first cell and find the duty cycle where the error stops shrinking.
What you would measure. Supply from a bench supply set to to with its current limit set, load with a power resistor, and look at the switch node with a short ground spring. Lower the input slowly (raising ) with the slope compensation reduced: above about the pulses alternate wide and narrow, and the scope's FFT shows a line at . Restore the ramp and the pattern disappears. Expect the onset within of the predicted duty cycle (the internal ramp and sense gain have tolerances of 10 to 20 %).
Hazards and safe setup. Current-limited supply at ; the oscillating converter has larger current peaks than normal, so keep the supply's current limit low and the load connected. An oscillating loop can also make the output overshoot: monitor it. Changing parts on the board only with the power off and the input capacitors discharged; switches and inductor get hot.
Pitfalls
- No slope compensation above 50 % duty. Also check transients: duty cycles beyond the steady state occur during load steps and at low input.
- Too much slope compensation. The loop drifts back to voltage mode, and the current limit falls as grows.
- Sampling the current at a random point of the ripple. Synchronise the ADC with the PWM (centre of the on- or off-time); blank the leading-edge spike in peak current mode.
- DPWM coarser than the ADC. Limit cycles. Check against one ADC step at the output.
Practice
- A buck runs at with , . What minimum ramp (in A/µs, referred to the inductor current) keeps ?
- A digital loop has at . What phase lag does it add at ?
- A DPWM runs from at in a buck. What is the output step per count?
Answer
- , so and ; needs .
- .
- counts per period: .
Test yourself
Without slope compensation, peak current-mode control becomes unstable when…
- the load is light
- the duty cycle exceeds 0.5
- the input voltage is high
- the inductor is large
Why does a current-mode buck usually need only a Type II compensator?
- it has no output capacitor
- the inner current loop turns the LC double pole into a single low-frequency pole
- it runs in DCM
- it has an RHP zero
A digital loop with a delay of 1.5 periods at 100 kHz crosses over at 10 kHz. The delay costs about…
- 5°
- 18°
- 54°
- 180°
What causes limit cycling in a digitally controlled converter?
- too much slope compensation
- a DPWM step at the output larger than one ADC step, so no duty value lands in the zero-error bin
- an analogue compensator
- synchronised sampling