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
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 would drive the node voltage as high as needed to keep its current flowing, which destroys the switches. In practice is often a diode, which turns on by itself when 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 on for of each period , the switch-node voltage is a pulse train with average
and a Fourier series with components only at multiples of (Fourier Series):
The filter is a second-order low-pass with corner . Choose and it passes the DC term untouched while every harmonic is attenuated by about . The output is the average plus a small ripple: PWM is a way to make an adjustable DC voltage with no loss, by moving .
The two balance laws
In periodic steady state every waveform repeats each period. Two consequences follow from the element laws:
For the cell above: , so gives , and gives . 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: , so the average input current is 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: , , , , , ; ideal switches.
Find: , the filter corner, the first-harmonic amplitude at the switch node and its estimated amplitude at the output.
Solve:
Check: a peak-to-peak ripple of about . The exact triangle-integral result from The Buck Converter is , the value the converter lab in the introduction showed; the first harmonic carries almost all of it.
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 the even harmonics vanish, and the third is attenuated nine times more than the first in the filter ( in amplitude, already reduced by at the source). The full periodic solution gives 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 or whatever the inductor current does). The filter starts from zero state, so you see the start-up as well: the rings at with , overshooting towards before settling to .
At , near the first peak, the lab reads , almost twice the final value. At the end of the run () it reads with (the steady value is ): the ringing decays only as , with a time constant . That overshoot is why real converters soft-start, ramping from zero (Protection and Reliability). Lower to and the ringing is damped much faster ().
Guided lab: averaging a PWM signal
Hand calculation. A function generator makes a to square wave at , duty cycle . Into an RC low-pass with and () the average is . A first-order filter attenuates the first harmonic, in amplitude, by about : about amplitude. A first-order filter attenuates the higher harmonics only as , so they add noticeably: the full ripple is a triangle of peak-to-peak (the first harmonic alone would give ).
Simulation. The netlist below is that RC filter. Its capacitor starts at (IC=), the bottom of the steady-state ripple, so the start-up is skipped and the plot shows the periodic steady state at once: the lab reads a ripple from about to ( peak-to-peak) around .
What you would measure. A DMM on DC reads ( from the generator's duty-cycle accuracy and level, plus the DMM's own ). A scope, AC-coupled at , shows a small triangle of about peak-to-peak. Change the duty cycle to : .
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 close to . The filter then passes the ripple; keep at least a decade below .
- Forgetting that the input current is pulsed. The source sees current only while is on; an input capacitor must supply those pulses.
Practice
- A cell switches with . Find the average switch-node voltage and the first-harmonic amplitude.
- For the worked example, what gives , and what average input current flows at that point with ?
- Why do the even harmonics vanish at ?
Answer
- ; .
- ; , so (check: ).
- for even : a 50 % square wave has half-wave symmetry.
Test yourself
In periodic steady state the average voltage across an ideal inductor is…
- equal to the input voltage
- zero
- equal to the output voltage
- at the switching instant
A switching cell has and . With an ideal LC filter, is…
What happens if both switches of the cell open while the inductor carries current (and there is no diode)?
- The current stops gently
- The output doubles
- The inductor drives the switch-node voltage up until something breaks down
- Nothing; the capacitor takes over
Doubling with the same and changes the output ripple from the first harmonic by roughly…
- ×2
- ×1/2
- ×1/4
- no change