TExcelTAD
Home › Power Electronics & Motor Drives › The Ideal Switch, the Switching Cell and PWM Averaging

The Ideal Switch, the Switching Cell and PWM Averaging

Every converter in this course, from a phone charger to a traction inverter, is built from the same small circuit: two switches that connect one node alternately to two rails, and an inductor that carries a nearly constant current out of that node. Engineers call it the switching cell or commutation cell. Understand what it does to voltages, currents and power, and you can derive the buck, the boost and the inverter leg on a napkin. This lesson builds the cell, shows that a low-pass filter recovers the average of the switched voltage, and introduces the two balance laws that every later lesson uses.

The switching cell

+ Vin12 V S1 (on D Ts)S2 (on (1-D) Ts) sw L 100 uHiL C 100 uFR 10 Ohm out v_sw: Vin, then 0; average D Vin

Two rules make the cell safe. Never close both switches at once: that shorts the voltage source (shoot-through). Never open both while the inductor carries current: the inductor's v=L di/dtv = L\,di/dt would drive the node voltage as high as needed to keep its current flowing, which destroys the switches. In practice S2S_2 is often a diode, which turns on by itself when S1S_1 opens and the inductor pulls the node below ground; a second transistor in its place (a synchronous switch) conducts with less drop but needs a short dead time with both off, during which its body diode carries the current (Gate Drivers).

The average and the ripple

With S1S_1 on for DTsDT_s of each period Ts=1/fswT_s = 1/f_{sw}, the switch-node voltage is a pulse train with average

⟨vsw⟩=1Ts∫0Tsvsw dt=D Vin\langle v_{sw} \rangle = \frac{1}{T_s}\int_0^{T_s} v_{sw}\,dt = D\,V_\text{in}

and a Fourier series with components only at multiples of fswf_{sw} (Fourier Series):

vsw(t)=DVin+∑n=1∞2Vinnπsin⁡(nπD)cos⁡ ⁣(nωswt−nπD)v_{sw}(t) = D V_\text{in} + \sum_{n=1}^{\infty} \frac{2 V_\text{in}}{n\pi}\sin(n\pi D)\cos\!\left(n\omega_{sw} t - n\pi D\right)

The LCLC filter is a second-order low-pass with corner f0=1/(2πLC)f_0 = 1/(2\pi\sqrt{LC}). Choose f0≪fswf_0 \ll f_{sw} and it passes the DC term untouched while every harmonic is attenuated by about (f0/nfsw)2(f_0/nf_{sw})^2. The output is the average plus a small ripple: PWM is a way to make an adjustable DC voltage with no loss, by moving DD.

The two balance laws

In periodic steady state every waveform repeats each period. Two consequences follow from the element laws:

vL=LdiLdt⇒ iL(Ts)−iL(0)=1L∫0TsvL dt=0 ⇒ ⟨vL⟩=0inductor volt-second balanceiC=CdvCdt⇒ ⟨iC⟩=0capacitor charge balance\begin{aligned} v_L = L\frac{di_L}{dt} &\Rightarrow\ i_L(T_s) - i_L(0) = \frac{1}{L}\int_0^{T_s} v_L\,dt = 0 \ \Rightarrow\ \langle v_L \rangle = 0 && \text{inductor volt-second balance} \\ i_C = C\frac{dv_C}{dt} &\Rightarrow\ \langle i_C \rangle = 0 && \text{capacitor charge balance} \end{aligned}

For the cell above: vL=vsw−voutv_L = v_{sw} - v_\text{out}, so ⟨vL⟩=0\langle v_L \rangle = 0 gives Vout=DVinV_\text{out} = D V_\text{in}, and ⟨iC⟩=0\langle i_C \rangle = 0 gives ⟨iL⟩=Vout/R\langle i_L \rangle = V_\text{out}/R. These two lines replace a page of circuit analysis for every converter in the course (The Buck Converter uses them first). Because the ideal cell is lossless, power balance holds too: Vin⟨iin⟩=Vout⟨iL⟩V_\text{in}\langle i_\text{in} \rangle = V_\text{out}\langle i_L \rangle, so the average input current is DD times the inductor current. A DC-DC converter is a DC transformer with an electronically adjustable ratio.

The same cell works in reverse: put a voltage source on the right and a load on the left, and power flows from the low-voltage side to the high-voltage side. That is the boost converter, and with both switches active the cell is bidirectional (a battery charger and discharger in one, or one leg of an inverter).

Worked example: averaging a 100 kHz switch node

Given: Vin=12 VV_\text{in} = 12\ \text{V}, D=0.5D = 0.5, fsw=100 kHzf_{sw} = 100\ \text{kHz}, L=100 μHL = 100\ \mu\text{H}, C=100 μFC = 100\ \mu\text{F}, R=10 ΩR = 10\ \Omega; ideal switches.

Find: VoutV_\text{out}, the filter corner, the first-harmonic amplitude at the switch node and its estimated amplitude at the output.

Solve:

Vout=0.5⋅12 V=6 V,f0=12π100 μH⋅100 μF=1.592 kHzV1=2⋅12 Vπsin⁡(0.5π)=7.639 VV1,out≈V1(f0fsw)2=7.639 V⋅(1.592100)2=1.936 mV\begin{aligned} V_\text{out} &= 0.5 \cdot 12\ \text{V} = 6\ \text{V}, \qquad f_0 = \frac{1}{2\pi\sqrt{100\ \mu\text{H} \cdot 100\ \mu\text{F}}} = 1.592\ \text{kHz} \\ V_1 &= \frac{2 \cdot 12\ \text{V}}{\pi}\sin(0.5\pi) = 7.639\ \text{V} \\ V_{1,\text{out}} &\approx V_1 \left(\frac{f_0}{f_{sw}}\right)^2 = 7.639\ \text{V} \cdot \left(\frac{1.592}{100}\right)^2 = 1.936\ \text{mV} \end{aligned}

Check: a peak-to-peak ripple of about 2⋅1.936=3.87 mV2 \cdot 1.936 = 3.87\ \text{mV}. The exact triangle-integral result from The Buck Converter is ΔIL/(8Cfsw)=3.75 mV\Delta I_L/(8Cf_{sw}) = 3.75\ \text{mV}, the value the converter lab in the introduction showed; the first harmonic carries almost all of it.

python · try it yourself
import numpy as np

Vin, D, fsw, L, C, R = 12.0, 0.5, 100e3, 100e-6, 100e-6, 10.0
f0 = 1 / (2 * np.pi * np.sqrt(L * C))
print(f"average D*Vin = {D*Vin:.3f} V, filter corner f0 = {f0/1e3:.3f} kHz")

# switch-node harmonics and the exact LC-R filter response at each one
def H(f):
    s = 2j * np.pi * f
    return 1 / (1 + s * L / R + s**2 * L * C)    # Vout/Vsw for L in series, C || R

total = 0.0
for n in range(1, 6):
    Vn = 2 * Vin / (n * np.pi) * abs(np.sin(n * np.pi * D))
    out = Vn * abs(H(n * fsw))
    total += out**2 / 2
    print(f"n = {n}: {n*fsw/1e3:5.0f} kHz  at sw {Vn:6.3f} V   at out {out*1e3:7.4f} mV")
print(f"output ripple rms (n = 1..5) = {np.sqrt(total)*1e3:.4f} mV")

# brute force: build v_sw on a fine grid and filter it in the frequency domain
N = 4096
t = np.arange(N) / (N * fsw)                         # one period
vsw = np.where(t < D / fsw, Vin, 0.0)
X = np.fft.rfft(vsw) / N
f = np.fft.rfftfreq(N, 1 / (N * fsw))
Y = X * np.array([1.0] + [H(fk) for fk in f[1:]])
vout = np.fft.irfft(Y * N, N)
print(f"periodic steady state: mean {vout.mean():.4f} V, ripple p-p {np.ptp(vout)*1e3:.4f} mV")
average D*Vin = 6.000 V, filter corner f0 = 1.592 kHz
n = 1:   100 kHz  at sw  7.639 V   at out  1.9356 mV
n = 2:   200 kHz  at sw  0.000 V   at out  0.0000 mV
n = 3:   300 kHz  at sw  2.546 V   at out  0.0717 mV
n = 4:   400 kHz  at sw  0.000 V   at out  0.0000 mV
n = 5:   500 kHz  at sw  1.528 V   at out  0.0155 mV
output ripple rms (n = 1..5) = 1.3696 mV
periodic steady state: mean 6.0000 V, ripple p-p 3.7510 mV

At D=0.5D = 0.5 the even harmonics vanish, and the third is attenuated nine times more than the first in the filter ((1/3)2(1/3)^2 in amplitude, already reduced by 1/31/3 at the source). The full periodic solution gives 3.751 mV3.751\ \text{mV} peak-to-peak, matching the triangle formula.

Interactive: the cell as a netlist

The netlist lab has no switch element, so here the switch node is a PULSE voltage source (an ideal cell: the node is forced to 12 V12\ \text{V} or 0 V0\ \text{V} whatever the inductor current does). The filter starts from zero state, so you see the start-up as well: the LCLC rings at f0=1.59 kHzf_0 = 1.59\ \text{kHz} with Q=RC/L=10Q = R\sqrt{C/L} = 10, overshooting towards 12 V12\ \text{V} before settling to 6 V6\ \text{V}.

05100.00.51.01.52.0t (ms)V0 A2.0 A4.0 A6.0 AI (A)V(out)I(L1)at t = 2.000 msV(sw)260 pVV(out)5.00 VI(VSW)-2.37 AI(L1)2.37 AI(C1)1.87 AI(R1)500 mA

At t=0.31 mst = 0.31\ \text{ms}, near the first peak, the lab reads vout=11.13 Vv_\text{out} = 11.13\ \text{V}, almost twice the final value. At the end of the run (2 ms2\ \text{ms}) it reads 4.998 V4.998\ \text{V} with iL=2.368 Ai_L = 2.368\ \text{A} (the steady value is 0.6 A0.6\ \text{A}): the ringing decays only as e−t/2RCe^{-t/2RC}, with a time constant 2RC=2 ms2RC = 2\ \text{ms}. That overshoot is why real converters soft-start, ramping DD from zero (Protection and Reliability). Lower RR to 2 Ω2\ \Omega and the ringing is damped much faster (Q=2Q = 2).

Guided lab: averaging a PWM signal

Hand calculation. A function generator makes a 00 to 5 V5\ \text{V} square wave at 10 kHz10\ \text{kHz}, duty cycle 30 %30\ \%. Into an RC low-pass with R=10 kΩR = 10\ \text{k}\Omega and C=1 μFC = 1\ \mu\text{F} (fc=15.9 Hzf_c = 15.9\ \text{Hz}) the average is 1.5 V1.5\ \text{V}. A first-order filter attenuates the first harmonic, 2⋅5πsin⁡(0.3π)=2.575 V\frac{2 \cdot 5}{\pi}\sin(0.3\pi) = 2.575\ \text{V} in amplitude, by about fc/f=1.59×10−3f_c/f = 1.59 \times 10^{-3}: about 4.1 mV4.1\ \text{mV} amplitude. A first-order filter attenuates the higher harmonics only as 1/n1/n, so they add noticeably: the full ripple is a triangle of D(1−D)V Ts/RC=0.3⋅0.7⋅5 V⋅100 μs/10 ms=10.5 mVD(1-D)V\,T_s/RC = 0.3 \cdot 0.7 \cdot 5\ \text{V} \cdot 100\ \mu\text{s}/10\ \text{ms} = 10.5\ \text{mV} peak-to-peak (the first harmonic alone would give 8.2 mV8.2\ \text{mV}).

Simulation. The netlist below is that RC filter. Its capacitor starts at 1.495 V1.495\ \text{V} (IC=), the bottom of the steady-state ripple, so the 10 ms10\ \text{ms} start-up is skipped and the plot shows the periodic steady state at once: the lab reads a ripple from about 1.495 V1.495\ \text{V} to 1.505 V1.505\ \text{V} (10.5 mV10.5\ \text{mV} peak-to-peak) around 1.500 V1.500\ \text{V}.

0.00.51.01.50.00.20.40.60.81.0t (ms)VV(out)at t = 1.000 msV(pwm)54.2 pVV(out)1.49 VI(VPWM)149 uAI(R1)-149 uAI(C1)-149 uA

What you would measure. A DMM on DC reads 1.50 V1.50\ \text{V} (±1 %\pm 1\ \% from the generator's duty-cycle accuracy and level, plus the DMM's own 0.5 %0.5\ \%). A scope, AC-coupled at 10 mV/div10\ \text{mV/div}, shows a small triangle of about 10 mV10\ \text{mV} peak-to-peak. Change the duty cycle to 70 %70\ \%: 3.50 V3.50\ \text{V}.

Hazards and safe setup. Signal-level only (5 V, milliamperes): none beyond ordinary bench care. With a power stage the same measurement needs a current-limited supply, and the switch node's fast edges need a short probe ground (Loss Budgets and Measuring Efficiency).

Pitfalls

  • Applying the balance laws during a transient. They hold only in periodic steady state; the start-up above violates them for milliseconds.
  • Opening every path of an inductor. Its current must always have somewhere to go: a diode, a second switch, a snubber or a clamp.
  • Placing f0f_0 close to fswf_{sw}. The filter then passes the ripple; keep f0f_0 at least a decade below fswf_{sw}.
  • Forgetting that the input current is pulsed. The source sees current only while S1S_1 is on; an input capacitor must supply those pulses.

Practice

  1. A cell switches 48 V48\ \text{V} with D=0.25D = 0.25. Find the average switch-node voltage and the first-harmonic amplitude.
  2. For the worked example, what DD gives Vout=9 VV_\text{out} = 9\ \text{V}, and what average input current flows at that point with R=10 ΩR = 10\ \Omega?
  3. Why do the even harmonics vanish at D=0.5D = 0.5?
Answer
  1. ⟨vsw⟩=12 V\langle v_{sw} \rangle = 12\ \text{V}; V1=2⋅48πsin⁡(0.25π)=21.6 VV_1 = \frac{2 \cdot 48}{\pi}\sin(0.25\pi) = 21.6\ \text{V}.
  2. D=0.75D = 0.75; Iout=0.9 AI_\text{out} = 0.9\ \text{A}, so ⟨iin⟩=DIout=0.675 A\langle i_\text{in} \rangle = D I_\text{out} = 0.675\ \text{A} (check: 12⋅0.675=8.1 W=9⋅0.912 \cdot 0.675 = 8.1\ \text{W} = 9 \cdot 0.9).
  3. sin⁡(nπ/2)=0\sin(n\pi/2) = 0 for even nn: a 50 % square wave has half-wave symmetry.

Test yourself

In periodic steady state the average voltage across an ideal inductor is…

  1. equal to the input voltage
  2. zero
  3. equal to the output voltage
  4. L di/dtL\,di/dt at the switching instant

A switching cell has Vin=24 VV_\text{in} = 24\ \text{V} and D=0.4D = 0.4. With an ideal LC filter, VoutV_\text{out} is…

  1. 4.8 V4.8\ \text{V}
  2. 9.6 V9.6\ \text{V}
  3. 14.4 V14.4\ \text{V}
  4. 40 V40\ \text{V}

What happens if both switches of the cell open while the inductor carries current (and there is no diode)?

  1. The current stops gently
  2. The output doubles
  3. The inductor drives the switch-node voltage up until something breaks down
  4. Nothing; the capacitor takes over

Doubling fswf_{sw} with the same LL and CC changes the output ripple from the first harmonic by roughly…

  1. ×2
  2. ×1/2
  3. ×1/4
  4. no change