Tutorial
Buck converter simulation: 12 V to 5 V, live
A buck converter is a switch, a diode, an inductor and a capacitor. The switch chops the input with duty D, ideally Vout / Vin, and the inductor and capacitor average it. In BetterSPICE it runs live, so you see the triangle inductor current and can change the duty while it runs. This tutorial uses the 12 V to 5 V, 1 A example.
28 Nov 2026 · Arwid Vasilev
Steps
- Size the stage with the buck calculator (manual chapter 58). For 12 V in, 5 V out, 100 kHz and 47 µH, the ideal duty is 5 / 12 = 0.417 and the ripple current is 0.62 A. The worked numbers are on that page.
- Open the example Buck converter, 12 V to 5 V, 1 A (Examples, Switching converters). It is already loaded in the viewer below.
- Run it (Space in the viewer, Ctrl+R in the app). Watch V SW: a square wave between 0 V and 12 V, while V out stays nearly flat near 5 V.
- Read I L1. It is a triangle about 0.65 A peak to peak around 1 A, close to the 0.62 A you calculated. I D1 flows only while the switch M1 is off.
- Check the duty. VG1 is on for 4.35 µs of every 10 µs, which is 43.5 %. That is above the ideal 41.7 % because the switch and diode lose some voltage, so the output settles at 5.04 V.
- Click VG1 and widen the pulse to 6 µs. V out rises to about 7 V. Duty sets the output.
- For measured values instead of the live picture, press F5 to run Simulate on the same circuit (chapter 28).
Questions people ask
Is there a free online buck converter simulator?
Yes. The viewer on this page runs the 12 V to 5 V example in your browser, and the full app at app.bspicesim.com lets you change the circuit while it runs. To size the stage first, use the buck converter calculator.
What duty cycle does a buck converter need?
Ideally D = Vout / Vin, so 5 / 12 = 0.417 for 12 V to 5 V. Real parts drop some voltage, so the example runs at 43.5 % and settles at 5.04 V.
How do I choose the inductor?
The ripple current is (Vin − Vout) × D / (fs × L). With 47 µH at 100 kHz that is 0.62 A. A larger L gives less ripple. Below half the ripple current, 0.31 A here, the converter goes discontinuous.
Can I try it without installing anything?
Yes. The viewer above runs in your browser, and the full app runs at app.bspicesim.com. The manual chapter on live simulation is chapter 26.
Try it yourself
The viewer and the full app run in your browser. The desktop app adds the vendor model library and ngspice.