# Worked example: a 48 V to 12 V buck converter

The `buckIdeal` example (the textbook buck: an ideal switch and diode) steps 48 V down to 12 V at a fixed duty cycle of 0.25 and 100 kHz, into a 2.4 Ω load (5 A). By hand, the output is 12 V, the inductor ripple 0.90 A and the output ripple 11.25 mV. The run gives 11.99 V, 0.90 A and 11.2 mV.

## Open it

In the app: **File › Open Example › DC-DC › Buck converter, textbook**, then press **F5**. From the command line:

```sh
powercraft-cli run --cmd file.openExample --params '{"name": "buckIdeal"}' \
  --cmd simulation.run \
  --cmd scope.measure --params '{"signals": ["v(out)", "i(L1)"], "t0": 0.0039, "t1": 0.004}'
```

![The buck example: a 48 V source, switch S1, freewheeling diode D1, L1 = 100 µH, C1 = 100 µF and a 2.4 Ω load, with a constant duty of 0.25 driving a 100 kHz sawtooth PWM.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/buck-converter-48v-to-12v/schematic.svg)

| Part | Value |
| --- | --- |
| Input $V_{in}$ | 48 V |
| Duty cycle $D$ | 0.25 (open loop) |
| Switching frequency $f_{sw}$ | 100 kHz |
| Inductor $L_1$ | 100 µH |
| Output capacitor $C_1$ | 100 µF, starts at 12 V |
| Load $R_1$ | 2.4 Ω |

## The hand calculation

In continuous conduction the switch node is $V_{in}$ for a fraction $D$ of each period and 0 V for the rest, and the inductor passes its average:

$$V_{out} = D\,V_{in} = 0.25 \times 48 = 12\ \text{V}, \qquad I_{out} = \frac{12}{2.4} = 5\ \text{A}$$

While the switch is on, $V_{in} - V_{out}$ across the inductor ramps its current up by

$$\Delta I = \frac{(V_{in} - V_{out})\,D}{f_{sw}\,L} = \frac{36 \times 0.25}{100\ \text{kHz} \times 100\ \mu\text{H}} = 0.90\ \text{A}$$

The capacitor takes the triangular part of that current. The charge in one half of the triangle gives the output ripple:

$$\Delta V = \frac{\Delta I}{8\,f_{sw}\,C} = \frac{0.90}{8 \times 100\ \text{kHz} \times 100\ \mu\text{F}} = 11.25\ \text{mV}$$

## The run

The example runs for 4 ms. The capacitor starts at 12 V, so the start-up is short. Measure the last ten periods (3.9 to 4.0 ms):

| Quantity | Hand | Run |
| --- | --- | --- |
| Mean output voltage | 12 V | 11.99 V |
| Mean inductor current | 5 A | 5.00 A |
| Inductor ripple (peak to peak) | 0.90 A | 0.90 A |
| Output ripple (last two periods) | 11.25 mV | 11.2 mV |

![Two periods at the end of the run: the switch node v(sw) toggling between 48 V and 0 V, the inductor current i(L1) as a 0.90 A triangle around 5 A, and the output v(out) with its 11 mV ripple.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/buck-converter-48v-to-12v/steady-state.svg)

The output sits 6 mV under 12 V: the switch and the diode each have 1 mΩ of on-resistance, and the formula has none. Over ten periods the output ripple reads about 0.4 mV more than over two, because the slow tail of the LC start-up is still in the window.

## Try next

- Change `D` in the circuit variables to 0.5 and check $V_{out} = 24$ V.
- Halve L1 to 50 µH: the inductor ripple doubles to 1.8 A and the output ripple to about 22 mV.
- Raise R1 until the current triangle touches zero. Past that point the buck runs in discontinuous conduction and $V_{out} = D\,V_{in}$ no longer holds.
- Close the loop: the [closed-loop buck](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/buck-closed-loop-pi) holds 12 V with a PI controller.

Every number on this page comes from a run that a test repeats (`auto::tests_worked_examples`), so the page changes when the simulator does.
