Documentation

12 V to 5 V buck converter

Step down 12 V with a PWM switch and explore inductor current, startup, and output ripple.

Power

Editor showing the 12 V to 5 V buck converter SPICE example as an unsaved schematic.
12 V to 5 V buck converter opens as an editable, unsaved schematic.

Open and run

  1. Open Examples from the Home ribbon.
  2. Choose 12 V to 5 V buck converter.
  3. Open Simulate and choose Setup to review the analyses.
  4. Choose Run for one analysis or Run All for the complete configured set.
  5. Select a matching Scope view after the run. Use Save as sheet to keep the example or Discard to close it.

Sheets, analyses, and Scope

12 V to 5 V buck converter

#

Setup: Startup

AnalysisConfiguration
Transient
  • Step 100n
  • Stop 4m
  • Maximum step 100n
  • Initial conditions Enabled

Scope views and expected results

Startup

Analysis: Transient

5 V output startup
  • OutputV(vout)
Inductor current
  • I(L1)
Switching detail

Analysis: Transient

Output ripple
  • OutputV(vout)
Switch node and gate drive
  • Switch nodeV(sw)
  • Gate-source voltageV(gate) - V(sw)
Inductor current
  • I(L1)

Python scripts

These scripts are included with the example. Review trusted project code before choosing Run.

Load regulation sweep.py

Default sheet: 12 V to 5 V buck converter

loads = ["2.5", "5", "10"]
sheet = get_sheet("12 V to 5 V buck converter")
runs = sheet.sweep(R1=loads).tran("16m", start="15m", step="100n", max_step="100n", uic=True, save="V(vout)")

fig, ax = subplots(1, 1, title="Buck converter load regulation")
ax.set(xlabel="Time", xformat="time", ylabel="Output voltage (V)")

measurements = []

# Compare the final millisecond after the soft start has settled.
for load, result in zip(loads, runs):
    output = result.v("vout").window(start="15m")
    ax.plot(output, label=f"{load} Ω")
    measurements.append([f"{load} Ω", f"{output.mean():.3f} V", f"{1000 * output.pkpk():.1f} mV"])
    print(f"Load={load} ohm: {output.mean():.3f} V average, {1000 * output.pkpk():.1f} mV peak-to-peak ripple")

ax.table(columns=["Load", "Average", "Ripple p-p"], rows=measurements, loc="upper right")
fig.show()