Boost-PFC simulator
An active rectifier (diode bridge + boost) you can program. The input is the rectified 230 V / 50 Hz grid, so your control loop must do two things at once: hold the 400 V DC bus steady and shape the grid current into a clean sine. Set L, C, Rload, write the controller in C, and watch the waveforms.
Configure the converter
Write the controller
The grid source lives in the script, not a number box. The input is the
rectified 230 V / 50 Hz grid, fed to the plant as
Vin = abs(325*np.sin(2*np.pi*50*t)). It is the disturbance your control loop
has to ride - so it is defined as an expression, not a tunable scalar. Open the
signals.py tab below to see it and add your own signals (e.g.
Vref, Power). The DC-bus target stays
Vref = 400 V, and L, C, Rload and fsw remain in the
parameter strip above.
Pick what to plot, then run
Parameter sweep vary parameters across a grid, then explore the result
| parameter | start | stop | steps | spacing |
|---|
Real engine: your C controller drives a switched boost (states iL, vC) integrated with symplectic Euler. Long timebases block-average each point; shorten the sim time to see per-cycle ripple. All measured channels (Vout, iL, duty, node voltages, branch currents) are sent to the explorer.
Plotting guidemeasurements, running, sweeps, and the Plot Explorer — everything
1 · What gets plotted
Pressing Run sim → simulates the converter and opens the result in the embedded Plot Explorer below. The simulation is never run automatically — only when you press Run (or Run sweep). Every channel the engine records is made available to the Explorer:
Topology (Step 1): Standard (diode) and Synchronous (low + high MOSFET) are switched models — real PWM, switching ripple, fine timestep. Averaged model replaces the switching network with a (1−d) DC-transformer (switch-node average vA = (1−d)·vout): smooth waveforms, no PWM ripple, and a much faster run — ideal for control/transient studies and sweeps. It assumes continuous conduction (CCM).
- Built-ins —
V_out,i_L,duty, plus node voltages and branch currents you add as measurements (below). - signals.py — every signal you define (e.g.
Vref,Power) is recorded over the run and plottable by its name. - plot(...) channels — any internal controller variable you expose (see §3).
2 · Measurements (under the schematic, Step 1)
The Measurements panel sits beneath the schematic. A relevant default set is preloaded (Vout, i(L), Vin, input/load/cap currents, v(Q1)…). Each is a chip:
- Click a chip to include it as a channel in the Explorer (highlighted = on). It is available to plot, not force-drawn — you pick curves in the Explorer.
- + current → then click a component on the schematic to measure the current through it.
- + voltage → then click two nodes to measure the voltage between them.
- You name each probe on add (Cancel discards it). The ✕ on a chip removes it.
3 · Plotting controller variables — plot()
Expose any internal variable from pi.c / current.c / pwm.c
as a channel:
float i_ref = KP*err + KI*integ;
plot(i_ref); // → channel "i_ref"
plot("err", Vref-Vout); // → channel "err" (named)
The value is sampled at the controller's rate and recorded for the whole run.
4 · The Plot Explorer
Each plot card draws one or more curves. Use + Add standard plot / + Add 3D plot to compare slices side by side.
- Curves — each row is a variable + operation, or switch it to ✎ expression… for a freeform expression. + add curve for more.
- Horizontal axis — usually
t; set it to ✎ expression… for a transform (t*1000) or a parametric plot (X =V_out, Y =i_L). - Subplots — stack 1–4 plots sharing the X axis; assign each curve to a subplot.
- Style — every curve has a colour picker and a line style (solid / dashed / dotted / dash-dot).
- ⊹ cursors — drop A & B lines, drag them to read exact values, Δx, Δy, and add mean / RMS / min / max / pk-pk over the interval.
- Curve expressions — click the ? next to a plot for the full function
reference. Highlights: reductions
RMS(i)/MEAN(i)… (scalar); per-cycle with a frequencyRMS(i_L*V_out, 50)(one value per 1/f cycle); rollingRMS_R(i, w); filtersLPF(i, fc)/HPF(i, fc); element-wiseABS/SQRT/LOG/DERIV…; slicingi[a:b]; arithmetic+ − * / ** %.
5 · Sweeps
Open Parameter sweep. Tick any parameters (circuit values and controller
#define gains) and set start / stop / steps and linear / log spacing.
The combo count and a cap are shown; press Run sweep →.
- Every combination is simulated and the whole set loads at once.
- Sliders appear for the swept dimensions — drag one to morph the waveform. Each
slider has lock/float, a scale dropdown —
lin/log/✎ expr…(pick expr to type a custom monotonic transform like1/Land slide in that space) — and ⬆ to promote it to the global header. - Switch a card to 3D for a heatmap / contour / surface: two swept params as
axes, a reduced metric as the value (e.g.
MEAN(V_out),P2P(i_L)). - Interpolate (smooth curves) renders lines as cubic splines (visual only).
6 · Saving & download
- Your setup — controller C code, signals.py, parameters, probes, sweep config, every setting — is saved in your browser and restored on reload. The simulation waveforms are not saved.
- Download data ↓ exports the waveforms as CSV: a single run gives
t+ all channels (+ signals + plot() channels); a sweep gives the full long-format grid.