TExcelTAD
Home › EE Foundations: Units, Measurement, Safety & the Lab Notebook › The EE Software Toolchain and a First SPICE Deck

The EE Software Toolchain and a First SPICE Deck

Electrical engineers spend as much time at a keyboard as at a bench. Before you solder anything, you calculate it, simulate it and draw it; after you measure it, you process the data, compare it with the prediction and keep all of it under version control. This lesson is a map of the free tools the Electrical Engineering track uses, what each one is for and when you will need it, followed by your first circuit simulation: a voltage divider in ngspice, cross-checked by hand and in Python.

The toolchain

The list follows the owner's roadmap (§2.1). Every tool here has a free version; commercial alternatives (MATLAB/Simulink, Altium Designer, Ansys, CST, COMSOL, PLECS) are common in industry but not needed to learn. Platforms and licences below are as of 2026; check each project's site for current versions.

Tool Main use When in the track Notes
Python with NumPy, SciPy, Matplotlib calculations, data processing, plots, small solvers from this course on runs in your browser on this site (Pyodide); see A Python Toolkit for EE Calculations
GNU Octave or MATLAB matrix work, control, signal processing intermediate courses Octave is free and largely MATLAB-compatible; see the MATLAB course
ngspice SPICE circuit simulation, scriptable from the command line from circuits on open source; the SPICE sessions on this site run ngspice 42
LTspice schematic-entry SPICE for analog and power circuits from circuits on free from Analog Devices, Windows and macOS (no Linux build; the Windows version runs under Wine)
KiCad schematics and printed circuit boards from electronics on open source; includes an ngspice-based simulator
Qucs-S circuit and RF simulation with a schematic editor RF courses front end for ngspice and other engines
FEMM 2-D magnetic, electrostatic and thermal field analysis electromagnetics free; Windows (runs under Wine elsewhere)
openEMS 3-D electromagnetic simulation (FDTD) advanced RF open source, scripted from Octave or Python
FreeCAD mechanical parts and enclosures project work open source 3-D CAD
Git version control for code, decks, data and reports from day one see the Git course
Linux command line automation, running simulators in batch from day one see the Linux & Bash course

A typical design loop moves through several of them:

hand calc Python SPICE bench notebook+ Git disagreement? find out why before moving on

Each step checks the previous one. If the hand calculation, the simulation and the measurement agree within their uncertainties, you understand the circuit. If they do not, one of them is wrong, and finding out which one is where most of the learning happens.

What SPICE does

SPICE (Simulation Program with Integrated Circuit Emphasis, first released at UC Berkeley in the 1970s) reads a netlist: a text list of components and the nodes they connect. It writes Kirchhoff's current law at every node, solves the resulting equations (by modified nodal analysis, which the Circuit Theory course builds by hand) and reports node voltages and branch currents. Analyses include op (DC operating point), dc (sweeps), ac (frequency response) and tran (time response).

The circuit for today: a 12 V12\ \text{V} source and a divider of R1=10 kΩR_1 = 10\ \text{k}\Omega and R2=4.7 kΩR_2 = 4.7\ \text{k}\Omega.

+V1 12 V R1 10kR2 4.7k node innode outnode 0 I +-V(out)

Worked example: the divider by hand

Given: V1=12 VV_1 = 12\ \text{V}, R1=10 kΩR_1 = 10\ \text{k}\Omega, R2=4.7 kΩR_2 = 4.7\ \text{k}\Omega, no load on node out.

Find: II, VoutV_\text{out} and the power in each resistor.

Solve:

I=V1R1+R2=12 V14.7 kΩ=0.8163 mAVout=IR2=V1R2R1+R2=12 V×4.714.7=3.837 VP1=I2R1=(0.8163×10−3 A)2×104 Ω=6.66 mW,P2=3.13 mW\begin{aligned} I &= \frac{V_1}{R_1 + R_2} = \frac{12\ \text{V}}{14.7\ \text{k}\Omega} = 0.8163\ \text{mA} \\ V_\text{out} &= I R_2 = V_1 \frac{R_2}{R_1 + R_2} = 12\ \text{V} \times \frac{4.7}{14.7} = 3.837\ \text{V} \\ P_1 &= I^2 R_1 = (0.8163 \times 10^{-3}\ \text{A})^2 \times 10^4\ \Omega = 6.66\ \text{mW}, \quad P_2 = 3.13\ \text{mW} \end{aligned}

Check: VoutV_\text{out} is between 00 and 12 V12\ \text{V} and less than half, because R2<R1R_2 < R_1. The voltages add up: IR1=8.163 VI R_1 = 8.163\ \text{V}, and 8.163+3.837=12.000 V8.163 + 3.837 = 12.000\ \text{V} (Kirchhoff's voltage law).

Your first SPICE deck

bash · try it yourself
cat > divider.cir <<'EOF'
* First deck: a 12 V source and a 10k/4.7k voltage divider
V1 in 0 DC 12
R1 in out 10k
R2 out 0 4.7k
.control
op
print v(in) v(out) i(V1)
.endc
.end
EOF
ngspice -b divider.cir 2>&1 | grep -E '^(v\(|i\()'
v(in) = 1.200000e+01
v(out) = 3.836735e+00
i(v1) = -8.16327e-04

Line by line:

  • The first line is always the title, whatever it says. A real component on line one is silently ignored, a classic first mistake.
  • V1 in 0 DC 12: the element name's first letter is its type (V source, R resistor, C capacitor, L inductor), then the nodes (positive first), then the value. Node 0 is ground and must exist.
  • Values take suffixes: k = 10310^3, meg = 10610^6, u = 10−610^{-6}, n, p. m means milli, so 1m is 1 mΩ1\ \text{m}\Omega, not a megohm: write 1meg.
  • .control … .endc holds commands: op computes the operating point, print shows the values. .end ends the deck.
  • ngspice -b runs in batch mode; grep keeps only the lines we asked for.

SPICE agrees with the hand calculation to every digit shown. The current is negative because SPICE reports the current flowing into the source's positive terminal: a source that delivers power has negative current by this convention.

A Python check, which also asks a design question: how far can VoutV_\text{out} move if both resistors are ±1 %\pm 1\,\% parts?

python · try it yourself
V1, R1, R2 = 12.0, 10e3, 4.7e3
I = V1 / (R1 + R2)
print(f"I = {I * 1e3:.4f} mA, V(out) = {I * R2:.4f} V")
print(f"P(R1) = {I**2 * R1 * 1e3:.2f} mW, P(R2) = {I**2 * R2 * 1e3:.2f} mW")
corners = [V1 * R2 * b / (R1 * a + R2 * b) for a in (0.99, 1.01) for b in (0.99, 1.01)]
print(f"with 1 % resistors: {min(corners):.4f} V to {max(corners):.4f} V")
I = 0.8163 mA, V(out) = 3.8367 V
P(R1) = 6.66 mW, P(R2) = 3.13 mW
with 1 % resistors: 3.7847 V to 3.8891 V

Guided lab: hand, SPICE, bench

Hand calculation. Vout=3.837 VV_\text{out} = 3.837\ \text{V}, I=0.816 mAI = 0.816\ \text{mA}.

Simulation. The deck above. Change R2 to 4.7meg and to 4.7m and explain both results (the second is the milli trap).

What you would measure. Build the divider on a breadboard with 1 %1\,\% resistors, fed from a bench supply at 12.0 V12.0\ \text{V} with a 10 mA10\ \text{mA} current limit. Measure VoutV_\text{out} on a multimeter: expect somewhere between about 3.763.76 and 3.91 V3.91\ \text{V} (the resistor corners above, widened by the example meter's ±0.022 V\pm 0.022\ \text{V} at 3.84 V3.84\ \text{V}); a typical pair of resistors lands much closer to 3.84 V3.84\ \text{V}. Measure the supply voltage too, because VoutV_\text{out} scales with it. Then measure each resistor out of circuit and recompute: the agreement should tighten to the meter's uncertainty. Record the deck, the measurements and the comparison in your notebook and commit the deck to Git (The Lab Notebook and the Lab Report).

Hazards and safe setup.

  • 12 V12\ \text{V} DC from a current-limited bench supply (limit 10 mA10\ \text{mA}); the resistors dissipate milliwatts.
  • Set the supply before connecting and switch the output on last (The Bench Power Supply).
  • No mains-powered circuit is simulated and then built in this course; simulation never makes mains work safe.

Pitfalls

  • A component on the title line, or no node 0.
  • M for mega: SPICE is case-insensitive and reads it as milli.
  • Trusting a simulation without a sanity check: SPICE solves the circuit you typed, not the one you meant.
  • Forgetting the sign convention of source currents.
  • Simulated parts are ideal unless you give them models: a SPICE resistor has no tolerance, temperature drift or power limit.

Practice

  1. Change R2R_2 to 10 kΩ10\ \text{k}\Omega. What does print v(out) show?
  2. Write the element line for a 100 nF100\ \text{nF} capacitor between nodes out and 0.
  3. A deck has R1 in out 1M. What resistance does SPICE use?
Answer
  1. 6 V6\ \text{V}, printed as v(out) = 6.000000e+00.
  2. C1 out 0 100n.
  3. 1 mΩ1\ \text{m}\Omega (milli). Write 1meg for a megohm.

Test yourself

Which tool is meant for drawing schematics and laying out printed circuit boards?

  1. FEMM
  2. KiCad
  3. openEMS
  4. Octave

What does SPICE do with the first line of a deck?

  1. Reads it as the first component
  2. Treats it as the title and ignores it as a circuit line
  3. Uses it as the ground node
  4. Runs it as a command

In SPICE, 2.2M is

  1. 2.2 MΩ2.2\ \text{M}\Omega
  2. 2.2 mΩ2.2\ \text{m}\Omega
  3. 2.2 kΩ2.2\ \text{k}\Omega
  4. an error

The divider deck prints i(v1) = -8.16327e-04. Why negative?

  1. The source is connected backwards
  2. SPICE reports current into the positive terminal, and a delivering source has current flowing out of it
  3. Rounding error
  4. Resistors have negative resistance in SPICE