Closed-loop buck: design the compensator
The buck of the first tutorial runs at a fixed duty, so its output follows the input. Here a feedback loop holds the output at 12 V. You let the Design panel size a PI controller, read why it fails its check on this circuit, and then take the Type III compensator it suggests. About 15 minutes.
Pictures: a numbered red box is what you click or read, Run is a button, Design › Design Steps › Voltage Loop a menu path, F5 a key.
1. Open the closed-loop example
Step 1 of 8 · about 1 minChoose File › Open Example › DC-DC › Buck converter, closed loop. The power stage is the one you know; the control loop is drawn above it.
VMmeasures the output voltage.Refis the set point,Vref= 12 V.Errsubtracts the measurement from the set point.PIturns the error into a duty.PWMdrives the switch with that duty.
2. Open the voltage-loop design
Step 2 of 8 · about 1 min3. Look at the Design panel
Step 3 of 8 · about 1 minThe Design page opens in the editor area, as a tab beside the circuit's. The fields start filled from the circuit, and a first design is shown at once.
Voltage Loopis the task.ControllerisAuto, and the note under it saysAuto picked Type III.: the panel picked a Type III network, because a PI cannot reach the default crossover (a tenth of the 100 kHz switching frequency) on this circuit.
4. Ask for a PI
Step 4 of 8 · about 1 min5. Design the PI
Step 5 of 8 · about 1 minClick Run (it reads Design again until you change a field), then collapse the bottom panel (↓ at its top right) to see more of the result.
Design again: the design is computed; changing a field turns the button back intoRun.Applywrites the design into the circuit.
6. Apply it and read the check
Step 6 of 8 · about 1 minClick Apply. The panel writes kp and ki into the PI block as one undo step, then checks the loop on a copy of the circuit. Fold Corner check and Changes made and scroll down the Verification list.
Recovery overshootfails: 73 % against a 40 % limit. The output rings after a 50 % load step, because a loop that crosses below the resonance cannot damp it.
7. Take the Type III compensator
Step 7 of 8 · about 1 minClick Type III in the Controller row, click Run, then Apply.
ControllerisType III. The crossover is 5.78 kHz with 60° of margin.✔ Verified: the loop passes its checks. On the schematic, thePIblock is now a transfer-function blockB(s)/A(s)with the same name and wires. ⌘Z brings the PI back.
8. Simulate the closed loop
Step 8 of 8 · about 1 minClose the Design page with the × on its tab and open the bottom panel again. Click ▶ Run in the toolbar or press F5, then Maximize at the panel's top right for a larger plot.
v(out): the output sits on the set point. The plot shows the last cycles;Whole runabove it shows the output rising from the start.vref: the 12 V set point.
The same steps from a script
powercraft-cli run \
--cmd file.openExample --params '{"name":"buckClosedLoop"}' \
--cmd design.voltageLoop --params '{"controller":"pi"}' \
--cmd design.voltageLoop --params '{"controller":"typeIII","apply":true}' \
--cmd simulation.run --params '{}' \
--cmd scope.measure --params '{"signals":["v(out)"],"t0":"8m"}'







