The converters in LTspice
Intent
Section titled “Intent”- Open and run the SPICE library’s LTspice schematics, and plot what their READMEs list.
- Work out how long a simulation from rest must run before its last periods show the steady state.
- Know which directives the schematics carry, and why.
Theory
Section titled “Theory”The library in LTspice
Section titled “The library in LTspice”The repository’s sim/ltspice/ folder has the five basic converters as
LTspice schematics [Analog Devices, LTspice simulator], one folder per converter with a
README that says what to plot and what to expect. Each schematic is the same
circuit as the ngspice netlist of the same name in sim/ngspice/: the
library’s script reads every schematic back into a netlist and compares it
part by part and node by node, and the nets carry the netlist’s node names.
Open a schematic and press Run: its directives come with it.
.paramsets the values of the synthetic example that the simulator’s preset of the same name uses..modelgives the near-ideal switch and diode..tranruns from rest, with every capacitor empty and every inductor without current, for 400 to 2500 periods depending on the case, with a time step no longer than a two-hundredth of a period..options method=gear reltol=1e-4chooses the integration method and the tolerance. The ngspice page explains why.
The ngspice netlists also carry .meas statements that average each quantity
and find its extremes over the last period. In LTspice, zoom in on the last
period, or add the same statements to the schematic.
How long to run
Section titled “How long to run”A run from rest has to pass through the whole start-up before its last period shows the steady state. While the converter stays in CCM, its output filter and the load ring after the start, and with ideal parts the ring’s envelope decays with a time constant set by the load and the capacitance alone:
- envelope time constant
- capacitance (output capacitor)
- load resistance
Assumptions, convention and source
- Assumptions
- ideal (lossless) switches and passive components
- continuous conduction mode (CCM)
- fixed duty ratio, no feedback loop (open loop)
- the output filter rings: its quality factor Q is above 1/2
- resistive load R
- Notes
- with ideal parts and the buck's source at rest, the filter is the inductance, the capacitance and the load in parallel: a parallel RLC circuit, whose ring decays as whatever the inductance. A lighter load (a larger ) rings for longer. The averaged models of the boost and the buck-boost give the same decay rate, . Real parts change the decay: the winding's and the switch's resistances always make the ring decay faster, the capacitor's series resistance does when Q is above 1, and the inductance then matters too. This is how an open-loop converter's output settles in CCM after a start-up or a step; a feedback loop sets its own settling, and in DCM, where the inductance carries no energy from one period to the next, the output settles near its steady state with a single time constant instead
- Source
- Alexander & Sadiku 2017, Ch. 8 (Second-Order Circuits: the source-free parallel RLC circuit); derived here; Erickson & Maksimović 2020, Ch. 8 (Converter Transfer Functions: the boost and buck-boost resonances, whose omega_0/(2Q) is also 1/(2RC)); Erickson & Maksimović 2020, Ch. 15 (AC and DC Equivalent Circuit Modeling of the Discontinuous Conduction Mode: a single low-frequency pole)
- Derivation
- step-by-step sympy derivation
- Equation id
filter.tau_env· equations.yaml entry
The error left after the start-up shrinks by the same factor in every envelope time constant. To bring it down to a fraction of what it was at the start takes:
- periods to settle
- switching period
- start-up error left (fraction)
- envelope time constant
Assumptions, convention and source
- Assumptions
- the start-up error decays with a single time constant, the slowest mode's
- Notes
- an error that decays as falls to the fraction after , and dividing by counts the periods. Each factor of ten in accuracy costs , about 2.3 envelope time constants more. A transient simulation from rest must run at least this long before its last periods show the steady state
- Source
- Alexander & Sadiku 2017, Ch. 8 (Second-Order Circuits: the natural response decays as the exponential of minus the neper frequency times t); derived here
- Derivation
- step-by-step sympy derivation
- Equation id
sim.periods_settle· equations.yaml entry
A light load rings longer, and each factor of ten in accuracy adds the same number of periods. Real parts damp the ring a little more: the winding’s and the switch’s resistances always, and the capacitor’s series resistance when the quality factor is above one. A start-up can also leave CCM for a while: in the library’s buck, the inductor current falls to zero in several of its first twenty periods, after the output’s first overshoot. The formula is then an estimate, not an exact count. In DCM the inductor current returns to zero in every period, so the inductor carries nothing from one period to the next: the filter no longer rings as an L-C pair, and near its steady state the output settles with a single time constant instead [Erickson & Maksimović 2020, Ch. 15].
The library runs each case for many times its slowest time constant, and its script checks each run at the end: the output’s average over the last period must lie within one part in ten thousand of its average over the period before, or the case fails as not settled. The check only catches a run far too short. In one period a decaying error shrinks only by a fraction of itself about equal to the period over the time constant, so with a time constant of a hundred periods, as in the library’s DCM flyback, a change of one part in ten thousand still allows an error of about a percent. Where the output rings, near a crest of the ring, where the output’s average stops rising and starts to fall, two consecutive averages can agree while the ring is still large. SPICE’s own accuracy sets a floor, too: in the library’s ngspice runs, the average jumps by up to one or two parts in a thousand long after the start-up has died away.
Integration settings
Section titled “Integration settings”With LTspice’s default settings the library’s DCM flyback shows a dip of the
drain voltage tens of volts below zero that the circuit does not have: about
as deep as the one ngspice draws with Gear’s method at its default
tolerance, not the kilovolt of ngspice’s trapezoidal ringing. The .options
line removes it, as it does in ngspice. The library records a one-time check
with LTspice 26.1.1, in which LTspice’s own netlists matched the library’s
and its results agreed with ngspice’s within 0.3 % of each quantity’s
largest magnitude. The ngspice page describes both effects:
the factor by which each step multiplies a fast mode
(the trapezoidal rule's factor), and a
diode’s current overshooting through zero at a loose tolerance.
Worked example
Section titled “Worked example”The buck example’s filter, load and switching frequency, run from rest until a thousandth of the start-up error is left:
| Symbol | Value | How it is obtained |
|---|---|---|
| switching frequency | 100 kHz | given |
| inductance | 100 µH | given |
| capacitance (output capacitor) | 10 µF | given |
| load resistance | 10 Ω | given |
| start-up error left (fraction) | 0.001 | given |
| switching period | 10 µs | Switching period |
| quality factor | 3.16 | Buck: quality factor of the LC poles |
| envelope time constant | 200 µs | Time constant of the envelope of an L-C filter's ring with a resistive load |
| periods to settle | 138 | Switching periods until the start-up error has decayed |
Its quality factor, 3.16, is well above one half, so the filter rings. The envelope time constant is 200 µs, twenty periods, and the output needs 138 periods to settle to a thousandth, well inside the library’s one percent and about as fine as its ngspice runs resolve. The library’s buck case runs 400 periods before it measures the last one.
Try it
Section titled “Try it”▶ Open in the equation explorer: Switching periods until the start-up error has decayed
Preset from the example sim-settle
Sweep the fraction left: each factor of ten costs the same number of periods.
▶ Open in the equation explorer: Time constant of the envelope of an L-C filter's ring with a resistive load
Preset from the example sim-settle
Sweep the load: a lighter load rings longer. The site’s simulator finds the steady state without a start-up:
▶ Open in the simulator: Buck
Preset from the example buck-basic
Bench exercise
Section titled “Bench exercise”Start a buck at a fixed duty ratio, without a feedback loop, into a resistor, and capture its output from the moment it starts switching. Measure the envelope’s decay from two peaks of the ring a known time apart, after the inductor current has stopped touching zero if it does in the first periods, and compare the time constant with twice the load resistance times the output capacitance: the winding’s and the switch’s resistances damp the ring further, and so does the capacitor’s series resistance when the quality factor is above one, so expect a somewhat shorter one. Count the periods until the output stays within one percent of its final value, and compare with the formula for one percent left. Then run the library’s schematic with your values and the same start.
Gotchas
Section titled “Gotchas”- A measurement over a period that has not settled measures the start-up. Run for the periods the formula asks for, then check that the output’s average no longer changes from one period to the next, as the library does: a small change alone does not prove that a slow ring has settled.
- The envelope formula holds in CCM, with a ringing filter, ideal parts and no feedback loop. In DCM, with a filter damped so heavily that it does not ring, or under closed-loop control, the output settles another way (envelope time constant).
- A spike that the circuit cannot make is often numerical: check the
.optionsline before you look for a cause in the circuit.
Go deeper
Section titled “Go deeper”- Video LTspice Basics (video series)
Short videos on a first schematic, transient and AC simulations, and the waveform viewer in LTspice. - Tool LTspice
A free SPICE simulator from Analog Devices.
With ideal parts, a buck's output filter rings with a 10 ohm load and a 10 µF capacitor. What is the time constant of the ring's envelope?
Answer and explanation
Correct answer: B The envelope decays with twice the load resistance times the capacitance, whatever the inductance: 2 times 10 ohm times 10 µF is 200 µs.
The envelope time constant is twenty switching periods. About how many periods does a run from rest need before a hundredth of the start-up error is left?
Answer and explanation
Correct answer: C The error shrinks by a factor e in every envelope time constant. A hundredth takes ln 100, about 4.6 time constants, so about 92 periods.
Going on from a hundredth to a ten-thousandth of the start-up error costs how much more?
Answer and explanation
Correct answer: A Each factor of ten costs the same, ln 10 or about 2.3 envelope time constants, so two more factors of ten cost as much as the first two.
Why does the envelope formula not say how long a DCM case must run?
Answer and explanation
Correct answer: D The inductor current returns to zero in every period, so the ringing L-C pair that sets the envelope is gone; near its steady state the output settles with a single time constant instead.
What does the library's check require before it accepts a run as settled?
Answer and explanation
Correct answer: C A run that is still settling changes from one period to the next, and the check compares the last two periods' averages. It only catches a run far too short, since a slow ring changes little per period, so the library also runs each case for many time constants.
A DCM flyback run shows the drain dipping far below zero, which the circuit cannot do. What do you check first?
Answer and explanation
Correct answer: A At their default settings both ngspice and LTspice draw such dips on the library's DCM flyback; Gear's method with a tighter tolerance removes them.
The numbers in the examples, presets and exercises on this site are synthetic: round teaching values, not data from any real design.