Simscuit

How circuit simulation works

A circuit simulator does not draw anything clever: it writes down the physical rules every node in the circuit must obey, solves them as a system of equations, and repeats that for each moment in time. This guide explains those steps with a worked example, describes how SPICE does it, and then says honestly how Simscuit’s simulator works and where it stops.

Open Circuit Studio free

The two rules: Kirchhoff’s laws

Kirchhoff’s current law (KCL): the currents into any node add up to zero. Charge does not pile up in a wire junction, so whatever flows in flows out.

Kirchhoff’s voltage law (KVL): the voltages around any closed loop add up to zero. Going round a loop and back to where you started, you end at the same potential.

Add each component’s own law (Ohm’s law, V = IR, for a resistor; a fixed voltage for a source; an exponential for a diode) and you have enough equations to find every voltage and current.

Nodal analysis, worked through

Simulators almost always use nodal analysis: pick one node as ground (0 V), make every other node voltage an unknown, and write KCL at each one with currents expressed through those voltages.

Take a 9 V source driving R1 = 1 kΩ into a node V, with R2 = 2 kΩ from V to ground. KCL at V: the current arriving through R1, (9 − V) ÷ 1000, equals the current leaving through R2, V ÷ 2000. Multiply by 2000: 18 − 2V = V, so V = 6 V, and the current is 3 mA. That is the voltage divider formula, 9 × 2k ÷ (1k + 2k), found by a method that scales to thousands of nodes.

For a large circuit the same equations are written as a matrix, G·v = i: G holds the conductances (1/R) between nodes, v the unknown node voltages and i the currents injected by sources. Solving it is ordinary linear algebra, usually Gaussian elimination or LU factorisation. Modified nodal analysis (MNA) extends this with an extra unknown for the current in each voltage source, which is how SPICE handles ideal sources.

Non-linear parts: diodes and Newton’s method

A resistor’s current is proportional to its voltage, so the equations stay linear. A diode’s is not. The Shockley equation gives I = Is × (e^(V ÷ (n × VT)) − 1), where Is is a tiny saturation current, n an ideality factor of about 1 to 2 and VT about 25.9 mV at 300 K. Transistors are built from similar exponentials or, for MOSFETs, square laws.

Simulators solve this with Newton-Raphson iteration. Guess the voltages; at each non-linear part, replace the curve with its tangent at the guess (a conductance plus a current source, called a companion model); solve the now-linear equations; use the answer as the next guess. Near the solution each step roughly doubles the number of correct digits, so a few iterations usually suffice.

Exponentials can overshoot wildly from a poor guess, so practical simulators limit how far a junction voltage may move between iterations and add a tiny conductance (GMIN) from each node to ground so the matrix never becomes singular. When the change between iterations falls below a tolerance, the solution has converged.

Time: transient simulation

Capacitors and inductors depend on how things change: i = C dv/dt and v = L di/dt. A transient simulation divides time into steps of length h and approximates the derivative. With the backward Euler method, a capacitor’s current at the new step is C × (v_new − v_old) ÷ h, which behaves like a conductance C ÷ h in parallel with a current source set by the old voltage. So each time step becomes another DC problem, solved with Newton’s method as above.

Smaller steps are more accurate and slower. A step must be well below the fastest time constant of interest: an RC network with R = 1 kΩ and C = 1 µF has a time constant of 1 ms, so it needs steps of tens of microseconds to draw its curve well. SPICE chooses the step automatically, shrinking it where signals change fast, and by default uses the trapezoidal method, which is more accurate than backward Euler for the same step.

SPICE

SPICE (Simulation Program with Integrated Circuit Emphasis) was developed at the University of California, Berkeley, and first released in the early 1970s. Its descendants, including the open-source ngspice and commercial tools such as LTspice, PSpice and the engines inside Multisim and Proteus, share its ideas: a text netlist of parts and nodes, MNA, Newton iteration, and analyses such as the DC operating point (.op), DC sweeps, small-signal AC (frequency response) and transient (.tran).

SPICE’s accuracy comes from its device models. A transistor model can have dozens of parameters fitted to measurements, and manufacturers publish SPICE models of their parts. That is why SPICE is the tool for analogue design, and also why it needs care: wrong models, missing ground, or circuits that oscillate can stop it converging.

How Simscuit simulates a circuit

Simscuit’s Circuit Studio does not expose a SPICE engine, but it is built on the same principles. When you press Run Simulation it derives the nets from your wires and each part’s internal connections, then writes the circuit as nodal equations with ground as the reference. Every source in Simscuit has a series resistance, so sources are written as their Norton equivalents and the unknowns are node voltages only. The equations are solved by Gaussian elimination with partial pivoting.

Diodes and LEDs use the Shockley equation, bipolar transistors the Ebers-Moll transport model and MOSFETs the square-law (SPICE level 1) model, with parameters from each part’s record. These are solved by Newton iteration with SPICE-style junction voltage limiting and a GMIN of 10⁻⁹ siemens on every node, stopping when voltages change by less than 0.1 µV.

Parts that change with time step forward in fixed 1 ms steps: capacitors and inductors use backward Euler companion models, and motors spin up, timers run and capacitors charge. An Arduino sketch runs in Simscuit’s interpreter alongside, and when it writes a pin the circuit is solved again, so an LED driven from D13 responds to the code.

What that means in practice, and the limits

For learning, breadboard projects and Arduino work this is the right trade: it runs live in a browser and lets you turn a potentiometer while it runs. For analogue design, use a SPICE tool as well.

  • DC levels, LED currents, dividers, transistor switches and logic levels are worked out from the circuit, not looked up, so wrong wiring gives wrong answers.
  • The 1 ms step is too coarse for fast waveforms: a time constant below a few milliseconds, switching regulators or audio-frequency signals will not be shown accurately.
  • There is no AC, noise or frequency-response analysis to run, and no way to load your own SPICE models.
  • Device models are simpler than full SPICE models (Ebers-Moll, not Gummel-Poon, for transistors), which is fine for switching and biasing, not for precise amplifier design.
  • Parts without a simulation model are marked Visual only and left out of the simulation; Simscuit never presents them as simulated.
  • Sketches run in an Arduino interpreter, not a cycle-accurate chip emulator, so instruction timing is not modelled.

Sources

Questions

Is Simscuit a SPICE simulator?

No. It works out the voltages and currents with nodal analysis and Newton iteration, as SPICE does, but with simpler device models, fixed 1 ms time steps and no SPICE netlist or AC analysis.

Why does a simulation fail to converge?

Usually a node with no path to ground, an ideal source shorted by a wire, or a strongly non-linear circuit started from a poor guess. Check the wiring first.

Loading Simscuit