---
title: "Resonant lab: SRC, LLC and zero-voltage switching"
heading: The series resonant converter's first-harmonic gain and its inverse, an exact simulation that tests the approximation, LLC gain curves and their peak, and the resonant swing that makes zero-voltage switching possible
eyebrow: S11 · Lesson 42 · Resonant lab
xp: 60
---

::: hook
Lesson 40 designed resonant converters with the first-harmonic approximation: pretend the bridge's square wave is a sine and the rectifier is a resistor, and the converter becomes an AC voltage divider. It's the method every LLC design note uses, and it's sometimes badly wrong. In this lab you'll write the approximation, then an exact simulation of the series resonant converter that follows the tank's piecewise sinusoids from one rectifier switching to the next, and compare them. Then you'll turn to lesson 41's zero-voltage transitions and time them.
:::

::: play
- The solid curve is the series resonant converter's first-harmonic gain against normalized frequency F, for the Q on the slider; the dashed curve is an LLC converter's, with $L_m = 5L_r$.
- Both pass through 1 at F = 1. Below resonance the LLC's magnetizing inductance lifts its gain above 1, peaking near its lower resonance at $F = 1/\sqrt{1 + L_n}$ = 0.41 for light loads.
- Heavier loads (higher Q) flatten both curves, which is why resonant converters must sweep frequency widely at light load.
:::

```sim plot
view: graph
x: F = 0.3..3
y: M = 0..1.5
slider: Q = 0.1..2 = 0.5
plot: 1/sqrt(1 + Q^2*(F - 1/F)^2) | label: SRC
plot: 5*F^2/sqrt(((5 + 1)*F^2 - 1)^2 + (Q*5*F*(F^2 - 1))^2) | dashed | label: LLC, Lₙ = 5
```

::: predict
## The first-harmonic approximation gives lesson 40's series resonant converter ($L_r$ = 20 µH, $C_r$ = 50 nF, R = 50 Ω, Q = 0.49) a gain of 0.804 at twice its resonant frequency. What does an exact simulation give?

- [ ] 0.804: the approximation is exact
- [x] About 0.71
- [ ] About 0.90
- [ ] 1.0

::: reveal
The exact steady state, found in task 2, gives 0.710. At this low Q the tank filters poorly, so far above resonance its current is closer to a triangle than a sine and the rectifier is far from a resistor. The real converter reaches a gain of 0.8 at F = 1.66 (264 kHz), not the 2.02 that the approximation predicts. Near resonance the two agree well, which is where LLC converters are designed to run.
:::
:::

::: nameit
## What the lab computes

- **First-harmonic gains**: for the SRC, $M = 1/\sqrt{1 + Q^2(F - 1/F)^2}$, and solving for F above resonance with $k = \sqrt{1/M^2 - 1}/Q$ gives $F = \frac{k + \sqrt{k^2 + 4}}{2}$. For the LLC, with $L_n = L_m/L_r$, the divider of $j(F - 1/F)$ against $jL_nF \parallel 1/Q$ (all in units of $R_0$) gives
$$M = \frac{L_nF^2}{\sqrt{\left[(L_n + 1)F^2 - 1\right]^2 + Q^2L_n^2F^2(F^2 - 1)^2}}$$
- **The exact SRC**: the bridge applies ±$V_g$, and the rectifier applies $\mp V_o$ opposing the tank current. Between switchings the applied voltage u is constant, so the tank moves exactly along
$$i(t) = i_0\cos\omega_0t + \frac{u - v_{C0}}{R_0}\sin\omega_0t, \qquad v_C(t) = u - (u - v_{C0})\cos\omega_0t + R_0i_0\sin\omega_0t$$
until the current crosses zero or the bridge switches. For a trial $V_o$, run to steady state and average |i| over a period; the right $V_o$ makes that average equal $V_o/R$.
- **Resonant transitions**: a current $I_0$ swinging a switch node with total capacitance $2C_{oss}$ through L follows $v(t) = I_0Z\sin\omega t$ with $Z = \sqrt{L/2C_{oss}}$ and $\omega = 1/\sqrt{2LC_{oss}}$; it reaches the rail only if $I_0Z \ge V$, in a time $\arcsin(V/I_0Z)/\omega$.
:::

::: check
kind: python

## Write `src_fha(F, Q)` and `src_frequency(M, Q)`: the normalized frequency above resonance that gives gain M.

```python starter
def src_fha(F, Q):
    return 1.0

def src_frequency(M, Q):
    return 1.0
```

```python solution
import math

def src_fha(F, Q):
    return 1 / math.sqrt(1 + Q * Q * (F - 1 / F) ** 2)

def src_frequency(M, Q):
    k = math.sqrt(1 / M ** 2 - 1) / Q
    return (k + math.sqrt(k * k + 4)) / 2
```

```python tests
import math
Q = 20 / (8 / math.pi ** 2 * 50)
assert abs(src_fha(1.2, Q) - 0.984) < 5e-4 and abs(src_fha(1.5, Q) - 0.925) < 5e-4 and abs(src_fha(2, Q) - 0.804) < 5e-4, "Lesson 40's gains."
assert abs(src_frequency(0.8, Q) - 2.02) < 0.005, "F = 2.02 for a gain of 0.8."
for M in (0.3, 0.6, 0.95):
    assert abs(src_fha(src_frequency(M, Q), Q) - M) < 1e-12, "The inverse undoes the gain."
```

::: right
Right. The approximation inverts in closed form, which is part of its appeal for design.
:::
:::

::: check
kind: python

## Write `src_exact(Lr, Cr, R, fs)`: the exact steady-state gain $V_o/V_g$ of a series resonant converter (full bridge, ideal rectifier with a large output capacitor, load R), by piecewise-exact simulation and bisection on $V_o$.

```python starter
import math

def src_exact(Lr, Cr, R, fs):
    Q = math.sqrt(Lr / Cr) / (8 / math.pi ** 2 * R)
    F = fs * 2 * math.pi * math.sqrt(Lr * Cr)
    return 1 / math.sqrt(1 + Q * Q * (F - 1 / F) ** 2)
```

```python solution
import math

def src_exact(Lr, Cr, R, fs, periods=400):
    w0 = 1 / math.sqrt(Lr * Cr)
    R0 = math.sqrt(Lr / Cr)

    def rectified_current(Vo):
        i = vc = 0.0
        for p in range(periods):
            q = 0.0
            for vs in (1.0, -1.0):
                left = 0.5 / fs
                while left > 1e-15 / fs:
                    sgn = 1.0 if i > 0 else -1.0 if i < 0 else (1.0 if vs > vc else -1.0)
                    u = vs - sgn * Vo
                    a = (u - vc) / R0
                    A, phi = math.hypot(i, a), math.atan2(i, a)
                    tz = ((math.pi - phi) % math.pi) / w0 or math.pi / w0
                    t = min(tz, left)
                    q += sgn * A * (math.cos(phi) - math.cos(w0 * t + phi)) / w0
                    c, s = math.cos(w0 * t), math.sin(w0 * t)
                    i, vc = i * c + a * s, u - (u - vc) * c + R0 * i * s
                    if t == tz:
                        i = 0.0
                    left -= t
        return q * fs

    lo, hi = 0.0, 1.0
    for _ in range(40):
        Vo = (lo + hi) / 2
        if rectified_current(Vo) > Vo / R:
            lo = Vo
        else:
            hi = Vo
    return (lo + hi) / 2
```

```python tests
import math
f0 = 1 / (2 * math.pi * math.sqrt(20e-6 * 50e-9))
assert abs(src_exact(20e-6, 50e-9, 50, f0) - 1) < 1e-3, "At resonance the gain is exactly 1."
assert abs(src_exact(20e-6, 50e-9, 50, 1.5 * f0) - 0.8490) < 2e-3, "F = 1.5: 0.849 against the approximation's 0.925."
assert abs(src_exact(20e-6, 50e-9, 50, 2 * f0) - 0.7100) < 2e-3, "F = 2: 0.710 against 0.804."
```

::: right
Right. The approximation is excellent at resonance and drifts as the converter moves away from it, faster at low Q.
:::
:::

::: check
kind: python

## Write `llc_gain(F, Q, Ln)` by the first-harmonic approximation, and `llc_peak(Q, Ln)`: the largest gain and the F where it occurs, searching F from 0.2 to 1.

```python starter
def llc_gain(F, Q, Ln):
    return 1.0

def llc_peak(Q, Ln):
    return 1.0, 1.0
```

```python solution
def llc_gain(F, Q, Ln):
    Zs = 1j * (F - 1 / F)
    Zp = 1 / (1 / (1j * Ln * F) + Q)
    return abs(Zp / (Zs + Zp))

def llc_peak(Q, Ln):
    best = (0.0, 0.0)
    for k in range(80001):
        F = 0.2 + k * 1e-5
        g = llc_gain(F, Q, Ln)
        if g > best[0]:
            best = (g, F)
    return best
```

```python tests
import math
for Q in (0.1, 0.5, 2):
    assert abs(llc_gain(1, Q, 5) - 1) < 1e-12, "At F = 1 the gain is 1 at any load."
M, F = llc_peak(0.5, 5)
assert abs(M - 1.2024) < 1e-3 and abs(F - 0.5605) < 1e-3, "Q = 0.5: a peak of 1.20 at F = 0.56."
M2, F2 = llc_peak(0.2, 5)
assert M2 > 2.4 and abs(F2 - 1 / math.sqrt(6)) < 0.03, "Light load: a tall peak near 1/√(1 + Lₙ)."
assert abs(llc_gain(0.6, 0.5, 5) - 5 * 0.36 / math.sqrt((6 * 0.36 - 1) ** 2 + (0.5 * 5 * 0.6 * (0.36 - 1)) ** 2)) < 1e-12, "It matches the closed form."
```

::: right
Right. The usable boost shrinks as the load grows, which sets how far below its nominal input an LLC converter can still regulate at full power.
:::
:::

::: check
kind: python

## Write `zvs_current(V, Coss, L)`: the least current that can swing a half bridge's node rail to rail through L, and `zvs_time(V, Coss, L, I0)`: the transition time, or None if the node never reaches the rail.

```python starter
def zvs_current(V, Coss, L):
    return 0.0

def zvs_time(V, Coss, L, I0):
    return 0.0
```

```python solution
import math

def zvs_current(V, Coss, L):
    return V * math.sqrt(2 * Coss / L)

def zvs_time(V, Coss, L, I0):
    Z = math.sqrt(L / (2 * Coss))
    w = 1 / math.sqrt(2 * L * Coss)
    if I0 * Z < V:
        return None
    return math.asin(V / (I0 * Z)) / w
```

```python tests
import math
assert abs(zvs_current(400, 200e-12, 10e-6) - 2.530) < 1e-3, "Lesson 41's example: 2.53 A."
t = zvs_time(400, 200e-12, 10e-6, 3)
assert t is not None and abs(t - 63.46e-9) < 0.05e-9, "3 A swings the node in 63.5 ns."
assert zvs_time(400, 200e-12, 10e-6, 2) is None, "2 A from the inductor alone falls short."
t2 = zvs_time(400, 200e-12, 10e-6, zvs_current(400, 200e-12, 10e-6))
assert abs(t2 - math.pi / 2 * math.sqrt(2 * 10e-6 * 200e-12)) < 1e-12, "At the threshold it takes a quarter period, 99.3 ns."
```

::: right
Right. More current than the minimum shortens the transition, so the dead time must be set for the lightest load that has to stay soft.
:::
:::

::: explain
## Why does the first-harmonic approximation work well near resonance but poorly far above it at light load?

::: model
The approximation keeps only the fundamental of the bridge's square wave and treats the rectifier as a resistor, which is valid when the tank current is nearly sinusoidal. Near resonance the tank's impedance is small at the fundamental and large at the harmonics, so it filters strongly and the current really is close to a sine. Far above resonance, and especially when Q is low, the tank's impedance at the fundamental is large and not much smaller than at the harmonics, so the harmonics pass too and the current becomes more triangular. Then the rectifier's input no longer looks like a resistor carrying a sinusoid, and the predicted gain can be off by ten percent or more.
:::
:::
