TExcelTAD
Home › Power Electronics & Motor Drives › Peak Current-Mode Control and Digital Control

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

t ic - Se t iL SnSf TsTs perturbed: error alternates sample at DTs/2computenew duty applied delay about 1.5 Ts

A clock turns the switch on at the start of each period. The sensed inductor current, Ri iLR_i\,i_L (a shunt or a sense FET with gain RiR_i in volts per ampere), rises with slope SnS_n; a comparator turns the switch off when it reaches the control voltage vcv_c minus a compensation ramp of slope SeS_e. For a buck, with the slopes in amperes per second:

Sn=Vin−VoutL,Sf=VoutLS_n = \frac{V_\text{in} - V_\text{out}}{L}, \qquad S_f = \frac{V_\text{out}}{L}

Subharmonic oscillation. Suppose the valley current starts one period too high by Δi0\Delta i_0. 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:

Δi1=−Sf−SeSn+Se Δi0=α Δi0\Delta i_1 = -\frac{S_f - S_e}{S_n + S_e}\,\Delta i_0 = \alpha\,\Delta i_0

Without a ramp, α=−Sf/Sn=−D/(1−D)\alpha = -S_f/S_n = -D/(1 - D) in steady state: below D=0.5D = 0.5 the error shrinks and alternates; above D=0.5D = 0.5 it grows, alternating every period, and the converter oscillates at fsw/2f_{sw}/2. A ramp with Se>12(Sf−Sn)S_e > \frac{1}{2}(S_f - S_n) makes ∣α∣<1\lvert \alpha \rvert < 1 at the operating duty cycle; Se≥Sf/2S_e \ge S_f/2 (half the downslope) covers a buck at every duty cycle up to D=1D = 1 and is the usual choice, and Se=SfS_e = S_f 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 vcv_c) now depends on DD.

python · try it yourself
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 D=0.6D = 0.6 without a ramp, a 50 mA50\ \text{mA} disturbance becomes −75-75, +112.5+112.5, −168.7 mA-168.7\ \text{mA} and keeps alternating until the 90 %90\ \% 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 Se=Sf/2S_e = S_f/2 the error shrinks to 0.4290.429 times its previous value each period and is gone in eight; with Se=SfS_e = S_f it is gone after one.

The current-mode plant

With the inner loop closed, the inductor is a current source controlled by vcv_c, 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:

Gvc(s)=RRi⋅11+RTsL k⋅1+sCRC1+s/ωp⋅11+sωnQp+s2ωn2,k=mc(1−D)−12ωp=1CR+Ts kLC,mc=1+SeSn,ωn=πTs,Qp=1πk\begin{aligned} G_{vc}(s) &= \frac{R}{R_i}\cdot\frac{1}{1 + \frac{R T_s}{L}\,k}\cdot\frac{1 + s C R_C}{1 + s/\omega_p}\cdot\frac{1}{1 + \frac{s}{\omega_n Q_p} + \frac{s^2}{\omega_n^2}}, \qquad k = m_c(1 - D) - \tfrac{1}{2} \\ \omega_p &= \frac{1}{CR} + \frac{T_s\, k}{L C}, \qquad m_c = 1 + \frac{S_e}{S_n}, \qquad \omega_n = \frac{\pi}{T_s}, \qquad Q_p = \frac{1}{\pi k} \end{aligned}

The last factor is the sampling double pole at half the switching frequency: the inner loop samples the current once per period. Its QpQ_p is infinite at k=0k = 0 (the edge of subharmonic oscillation) and negative, i.e. unstable, below; Se=Sf/2S_e = S_f/2 at D=0.6D = 0.6 gives mc=1.75m_c = 1.75, k=0.2k = 0.2 and Qp=1.59Q_p = 1.59. 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 10 Hz10\ \text{Hz} sine sampled at 10 Hz10\ \text{Hz} stands for a ripple at fswf_{sw} sampled at fswf_{sw}: the lab reads an apparent frequency of 0 Hz0\ \text{Hz}, so the ripple aliases to DC. At phase 0∘0^\circ 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 90∘90^\circ and every sample hits the peak, a fixed error. Set fsf_s to 9.5 Hz9.5\ \text{Hz}: the alias is 500 mHz500\ \text{mHz}, a slow false oscillation that the loop would try to correct; synchronised sampling avoids it.

-A0+A0.0 s0.2 s0.4 s0.6 s0.8 s1.0 sx (V)input 10.0 Hzreconstructed 0.00 Hzsamples, fs = 10.0 Hz0A0102030405060708090100f (Hz)fs/2faliasaliased: f > fs/2 = 5.00 Hz

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 TdT_d of 0.50.5 to 1.51.5 periods (the update waits for the next period). A delay is a pure phase lag, 360∘fTd360^\circ f T_d, that grows with frequency: 54∘54^\circ at 10 kHz10\ \text{kHz} for Td=15 μsT_d = 15\ \mu\text{s}.
  • Discretisation. The analogue compensator becomes a difference equation, for example by the bilinear (Tustin) transform s→2Tsz−1z+1s \to \frac{2}{T_s}\frac{z - 1}{z + 1} (The Bilinear Transform, Discrete PID); its accuracy falls as frequencies approach fs/2f_s/2.
  • Resolution. A DPWM clocked at fclkf_\text{clk} has fclk/fswf_\text{clk}/f_{sw} duty steps, each moving a buck's output by Vinfsw/fclkV_\text{in} f_{sw}/f_\text{clk}. 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 20 V20\ \text{V} to 12 V12\ \text{V} (D=0.6D = 0.6), L=100 μHL = 100\ \mu\text{H}, C=470 μFC = 470\ \mu\text{F} (RC=40 mΩR_C = 40\ \text{m}\Omega), R=3 ΩR = 3\ \Omega, fsw=100 kHzf_{sw} = 100\ \text{kHz}, Ri=0.25 V/AR_i = 0.25\ \text{V/A}, Se=Sf/2S_e = S_f/2. Digital version: delay 1.5 Ts1.5\,T_s, DPWM clock 100 MHz100\ \text{MHz}, 12-bit ADC over 3.3 V3.3\ \text{V} behind a 2.5/122.5/12 divider.

Find: the plant's DC gain and pole, a Type II for fc=10 kHzf_c = 10\ \text{kHz} and its margin, the margin with the digital delay, and whether the resolutions are compatible.

Solve:

Gvc(0)=3 Ω0.25 Ω⋅11+3⋅10 μs100 μH⋅0.2=121.06=11.32=21.08 dBfp=12π(1470 μF⋅3 Ω+10 μs⋅0.2100 μH⋅470 μF)=709.2+42.62π Hz=119.6 HzΔVDPWM=20 V1000=20.0 mV,ΔVADC=3.3 V4096⋅122.5=3.87 mV\begin{aligned} G_{vc}(0) &= \frac{3\ \Omega}{0.25\ \Omega} \cdot \frac{1}{1 + \frac{3 \cdot 10\ \mu\text{s}}{100\ \mu\text{H}} \cdot 0.2} = \frac{12}{1.06} = 11.32 = 21.08\ \text{dB} \\ f_p &= \frac{1}{2\pi}\left(\frac{1}{470\ \mu\text{F} \cdot 3\ \Omega} + \frac{10\ \mu\text{s} \cdot 0.2}{100\ \mu\text{H} \cdot 470\ \mu\text{F}}\right) = \frac{709.2 + 42.6}{2\pi}\ \text{Hz} = 119.6\ \text{Hz} \\ \Delta V_\text{DPWM} &= \frac{20\ \text{V}}{1000} = 20.0\ \text{mV}, \qquad \Delta V_\text{ADC} = \frac{3.3\ \text{V}}{4096} \cdot \frac{12}{2.5} = 3.87\ \text{mV} \end{aligned}

Check: the compensator places its zero at 1 kHz1\ \text{kHz} 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 12.312.3 bits of DPWM resolution, an effective clock of about 517 MHz517\ \text{MHz}.

python · try it yourself
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 77.5∘77.5^\circ at 10 kHz10\ \text{kHz} with three parts, against the Type III's five. A half-period delay (sampling right before the update) costs 18∘18^\circ; the typical 1.51.5 periods cost 54∘54^\circ and leave only 23.5∘23.5^\circ, a ringing loop. Lowering the crossover to 4 kHz4\ \text{kHz} restores 53.2∘53.2^\circ. 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 z=1z = 1 (the integrator) and one at z=0.580z = 0.580 (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 SnS_n, SfS_f and the internal SeS_e from the datasheet, and the input voltage at which ∣α∣=1\lvert \alpha \rvert = 1 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 1212 to 24 V24\ \text{V} 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 DD) with the slope compensation reduced: above about D=0.5D = 0.5 the pulses alternate wide and narrow, and the scope's FFT shows a line at fsw/2f_{sw}/2. Restore the ramp and the pattern disappears. Expect the onset within ±0.05\pm 0.05 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 ≤24 V\le 24\ \text{V}; 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 DD 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 Vinfsw/fclkV_\text{in} f_{sw}/f_\text{clk} against one ADC step at the output.

Practice

  1. A buck runs at D=0.7D = 0.7 with L=22 μHL = 22\ \mu\text{H}, Vout=3.3 VV_\text{out} = 3.3\ \text{V}. What minimum ramp SeS_e (in A/µs, referred to the inductor current) keeps ∣α∣<1\lvert \alpha \rvert < 1?
  2. A digital loop has Td=1.5 TsT_d = 1.5\,T_s at fsw=200 kHzf_{sw} = 200\ \text{kHz}. What phase lag does it add at fc=15 kHzf_c = 15\ \text{kHz}?
  3. A DPWM runs from 150 MHz150\ \text{MHz} at 250 kHz250\ \text{kHz} in a 12 V12\ \text{V} buck. What is the output step per count?
Answer
  1. Vin=3.3/0.7=4.71 VV_\text{in} = 3.3/0.7 = 4.71\ \text{V}, so Sn=(4.71−3.3) V/22 μH=0.064 A/µsS_n = (4.71 - 3.3)\ \text{V}/22\ \mu\text{H} = 0.064\ \text{A/µs} and Sf=3.3 V/22 μH=0.150 A/µsS_f = 3.3\ \text{V}/22\ \mu\text{H} = 0.150\ \text{A/µs}; ∣α∣<1\lvert \alpha \rvert < 1 needs Se>12(Sf−Sn)=0.043 A/µsS_e > \frac{1}{2}(S_f - S_n) = 0.043\ \text{A/µs}.
  2. 360∘⋅15 kHz⋅7.5 μs=40.5∘360^\circ \cdot 15\ \text{kHz} \cdot 7.5\ \mu\text{s} = 40.5^\circ.
  3. 600600 counts per period: 12 V/600=20 mV12\ \text{V}/600 = 20\ \text{mV}.

Test yourself

Without slope compensation, peak current-mode control becomes unstable when…

  1. the load is light
  2. the duty cycle exceeds 0.5
  3. the input voltage is high
  4. the inductor is large

Why does a current-mode buck usually need only a Type II compensator?

  1. it has no output capacitor
  2. the inner current loop turns the LC double pole into a single low-frequency pole
  3. it runs in DCM
  4. 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…

  1. 5°
  2. 18°
  3. 54°
  4. 180°

What causes limit cycling in a digitally controlled converter?

  1. too much slope compensation
  2. a DPWM step at the output larger than one ADC step, so no duty value lands in the zero-error bin
  3. an analogue compensator
  4. synchronised sampling