# The Test Bench: run one case and see it against its limits

`spec.verify` checks every corner of a spec at once and answers with a table. The Test Bench runs the same checks one case at a time and keeps each run's waveforms, with the limits drawn on them. You run a load-step case on the closed-loop buck, watch it fail, fix the loop, run it again and lay the two runs over each other. About 15 minutes.

Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Simulation › Test Bench` a menu path.

## 1. Open the Test Bench

Choose `File › Open Example › DC-DC › Buck converter, closed loop` (the circuit of [tutorial 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/02-closed-loop-buck/)), then open the `Simulation` menu.

![The Simulation menu with Test Bench marked, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/01-menu.png)

1. `Simulation`.
2. `Test Bench`, then `Open Test Bench`.

## 2. List the cases

Fill in the spec in the `Spec` section at the top, the same rows as the Auto Design form. `Use spec from Auto Design` fills it with the spec Auto Design would open with (here the circuit's 48 V, 12 V and 5 A). For this tutorial, paste the whole spec instead: `Paste JSON` (in the top row), paste the text below, `Apply`, then click `List Cases`:

```json
{"vin":{"min":44,"nom":48,"max":52},"vout":{"nom":12,"tolPct":2},"iout":{"min":2.5,"max":5},"loadStep":{"from":2.5,"to":5,"maxDroopPct":5,"maxSettle":"2m"}}
```

48 V (44 to 52 V) in, 12 V ±2 % out, 2.5 to 5 A, and a load step from 2.5 to 5 A that may pull the output down by at most 5 % and must recover within 2 ms.

![The cases: six corners and three load steps, none run yet, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/02-cases.png)

1. The `Spec` section, filled from the pasted JSON (the same spec `spec.verify` and `design.auto` take). It closes once the cases are listed; click it to open it again.
2. `List Cases`. Listing simulates nothing.
3. A corner case: one input and one load, run until the output settles, checked against the regulation band.
4. A load-step case at 48 V: the load steps from 2.5 to 5 A after the first run and back to 2.5 A after the second, checked for the largest swing after each edge and the recovery time. The list also has `preBias`, a start-up into an output already charged to half its voltage.

## 3. Run the load step

Click `Load step 2.5 A to 5 A, Vin 48 V`. It runs at once.

![The load-step case failed: the dip crosses the dashed limit, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/03-fail.png)

1. `Fail`, `Test run tb1`. The plots show `v(out)` and `i(L1)`. The dashed horizontal line is the dip limit (11.4 V, 5 % under 12 V); the two dashed vertical lines are the recovery window, 2 ms from the step at 10 ms.
2. `Undershoot or overshoot after the load step`: 16.03 % against 5 %. The output falls to about 10 V and rings past 12 V; the note gives both in millivolts. The next row, `Overshoot or undershoot after the load release`, reads the load going back to 2.5 A.
3. `Recovery after the load step`: 5.588 ms against 2 ms, the slower of the two edges. The PI loop is too slow, as tutorial 2 found.

## 4. Fix the loop

Close the window and choose `Design › Design Steps › Voltage Loop`.

![The Design page: Voltage Loop with Type III, Design again and Apply, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/04-type3.png)

1. `Controller`: `Auto picked Type III.`, a Type III network crossing at 5.78 kHz with 60° of margin.
2. `[Design again]`.
3. `[Apply]` writes the network into the circuit.
4. `✔ Verified`. On the schematic, `PI` is now a transfer function block, `B(s)/A(s)`.

## 5. Open the stale case

Choose `Simulation › Test Bench › Open Test Bench` again. The spec and the cases are still there.

![The case marked out of date: the circuit changed after its run, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/05-stale.png)

1. `⟳` after the case title: the circuit changed after this run, so the result is out of date.
2. `[Run Case]` runs the selected case again.

## 6. Run again and compare

Click `[Run Case]`, then pick `tb1 · loadStep-48V` in `Compare with:`.

![Run tb2 passes; tb1 drawn dashed on the same plots, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/06-overlay.png)

1. `Pass`, `Test run tb2`.
2. `Compare with:`: `tb1`, the first run.
3. The overlay is drawn dashed: `v(out) (tb1)` rings and dips; the new `v(out)` barely moves at the step.
4. The table adds the overlay's values and the difference: the dip falls from 16.03 % to 4.62 %, and the recovery from 5.588 ms to 122 µs. `Difference` is in the limit's unit: −11.4 % for the dip and −5.47 ms for the recovery. The plots' y axes name their signal and unit, `v(out)` in V and `i(L1)` in A.

`Run All Cases` runs every case in parallel, `Re-run Failed` only those that failed, `Export CSV` writes one row per limit of every case, and `Copy JSON` copies the cases and runs.

## The same steps from a script

```sh
SPEC='{"vin":{"min":44,"nom":48,"max":52},"vout":{"nom":12,"tolPct":2},"iout":{"min":2.5,"max":5},"loadStep":{"from":2.5,"to":5,"maxDroopPct":5,"maxSettle":"2m"}}'
powercraft-cli run \
    --cmd file.openExample    --params '{"name":"buckClosedLoop"}' \
    --cmd testbench.run       --params "{\"case\":\"loadStep-48V\",\"spec\":$SPEC}" \
    --cmd design.voltageLoop  --params '{"controller":"typeIII","apply":true}' \
    --cmd testbench.run       --params "{\"case\":\"loadStep-48V\",\"spec\":$SPEC}" \
    --cmd testbench.compare   --params '{"a":"tb1","b":"tb2"}'
```

Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/).
