Simulation
SPICE simulation with ngspice: analyses, probes, the waveform chart, sweeps and Monte Carlo.
The schematic editor runs SPICE simulations with ngspice (install it from your package manager or
ngspice.sourceforge.io; set softforge.edsnx.ngspicePath when it is not on the PATH). Open the Simulation
panel on the right side of a schematic.
Setting up. Symbols use KiCad’s simulation fields (Sim.Device, Sim.Type, Sim.Params, Sim.Pins,
Sim.Library, Sim.Name, Sim.Enable), so a schematic simulated in KiCad’s simulator works here unchanged.
Resistors, capacitors and inductors whose value is a plain number need no fields. The Simulation models
dialog (the class icon in the panel, or sim:models) edits them per symbol: device and type, a model library
(Browse… stores it as ${KIPRJMOD}/…), the model or subcircuit name read from that library, parameters
with the model’s defaults as placeholders, the pin assignment, whether the symbol is simulated, and a
tolerance (Sim.Tolerance, such as 5%) used by Monte Carlo. Check models loads every model file of
the project in ngspice and reports the ones that fail. Applying is one undoable edit.
Analyses. Pick From the schematic to use the .tran / .ac / .dc / .op text directive on the
sheet, or choose an analysis and its fields in the panel (the panel’s choice replaces the sheet’s directive for
this run only). Run netlists the schematic and starts ngspice; Stop kills it. ngspice errors and warnings
appear in the panel and in the Problems view on the symbol they name; click one to select the symbol.
The netlist comes from kicad-cli sch export netlist --format spice (unsaved changes are written to a
temporary copy first). When kicad-cli is missing, Auto falls back to a built-in netlister. The built-in one
walks the whole hierarchy (sub-sheets through sheet pins and hierarchical labels, power symbols and global labels;
sheets open in an editor are read with their unsaved changes) and writes the same device lines as kicad-cli:
the passive and source devices, .model / .subckt libraries, Sim.Params, and a .model line for each of
KiCad’s built-in device types (diodes, BJTs, MOSFETs, JFETs, switches, lossless lines) and for a library model with
instance parameters (.model Q2.QLIB NPN( … bf=200 )). It does not handle IBIS models, XSPICE code models or
potentiometers, and it drops .control blocks. Choose kicad-cli or Built-in in the Netlist field to force
one.
While a run goes, the panel shows its phase and progress: Netlist, Runs (one step per sweep value or Monte
Carlo run, with ngspice’s own progress) and Post-processing (envelopes, statistics, measurements); the
edsnx sim commands print the same phases.
Operating point. After an OP run, each net shows its voltage on the schematic (at a label, else a pin) and two-terminal parts show their current (and power, if ticked), with SI prefixes and the digits you choose. The panel lists the same values. Editing the schematic marks the result stale and hides the labels until you run again.
Waveforms. TRAN, AC, DC and noise results draw in the panel’s chart: tick traces in the list, or pick the Probe tool (the pulse icon) and click a net for its voltage or a part for its current. AC plots use a log frequency axis with Magnitude (dB), Magnitude or Phase. Click the chart to place cursor A, Shift+click for B (the readout shows both and their difference, with 1/Δt for time); the wheel zooms, dragging pans, double-click resets. CSV saves the visible traces and PNG the chart. A transient result also becomes a time axis on the playback timeline: scrub or play it and every net shows V(t) at the playhead, the chart’s playhead follows, and clicking the chart seeks.
Sweeps and Monte Carlo. Sweep reruns the analysis over a list (1k 2.2k 4.7k) or range (1k..10k/5,
1k..1Meg/7 log) of values of a part (R1) or a .param; each step is one trace of the family. Monte
Carlo runs N times with every toleranced part varied (Gaussian with the tolerance at 3σ, or uniform; parts
without Sim.Tolerance use 1% for resistors and 10% for capacitors and inductors) from a seed, so a run is
reproducible. A source with a Sim.Tolerance varies its DC value (or its amplitude). Also vary adds any other
parameter with its tolerance: V1.dc 5%, V2.ampl 10%, a field such as R1.tc1 20%, a model parameter such as
Q1.bf 30% or Q*.bf 30% for all of them, or a .param gain 2%; Sweep accepts the same targets (Q1.bf). The chart shows the nominal trace, the faint runs and the min–max and 5–95 % band; each
measurement gets a histogram and its mean, σ, extremes and percentiles.
Measurements. Add measurements under the chart: rise and fall time (10–90 %), peak, minimum, peak-to-peak,
average, RMS, value at x, final value, -3 dB frequency, bandwidth, frequency and period, overshoot, settling
time, gain and phase at a frequency. They are computed from the vectors (like .meas), per sweep step, and
over all Monte Carlo runs.
All of this is also available as commands (sim.netlist, sim.run, sim.op, sim.tran, sim.ac, sim.sweep,
sim.montecarlo, sim.measure, sim.models.list, sim.models.set; see commands), for example
edsnx sim ac examples/sim-rc/sim-rc.kicad_sch (the measurement traces are the vector labels such as V(/out)). examples/sim-rc is a ready RC low-pass.