SPICE Simulation Tutorial: How to Use Circuit Simulation

SPICE (Simulation Program with Integrated Circuit Emphasis) is the standard for circuit simulation. It lets you test a circuit design on your computer before building it physically -- saving time, components, and potentially expensive mistakes. This tutorial covers what SPICE simulation is, the three main analysis types, and how to use browser-based SPICE simulation in CircuitDiagramMaker.

What Is SPICE Simulation?

SPICE was developed at the University of California, Berkeley in the 1970s and has become the universal standard for analog circuit simulation. It solves the mathematical equations that describe circuit behavior -- Kirchhoff's laws, Ohm's law, and semiconductor device models -- numerically.

What SPICE Can Do

What SPICE Cannot Do

The Three Main Analysis Types

1. DC Operating Point Analysis

DC analysis finds the steady-state voltages and currents in a circuit with all capacitors fully charged and all inductors carrying constant current. It answers: "What are the voltages and currents right now, after everything has settled?"

When to use DC analysis:

Example: Voltage Divider

A simple voltage divider with a 12V source, R1 = 10k ohms, R2 = 5k ohms:

This seems trivial for a voltage divider, but DC analysis becomes essential for complex circuits with multiple sources, nonlinear devices, and feedback loops.

2. Transient Analysis (Time-Domain)

Transient analysis simulates the circuit over time, showing how voltages and currents change from moment to moment. It answers: "What happens when I turn this circuit on, apply a signal, or change a load?"

When to use transient analysis:

Key settings:

Example: RC Circuit Charging

A 10 microfarad capacitor charging through a 1k-ohm resistor from a 5V source:

Transient analysis plots the voltage versus time curve, showing the exponential charging characteristic.

3. AC Analysis (Frequency Sweep)

AC analysis sweeps a range of frequencies and calculates the circuit's gain (magnitude) and phase shift at each frequency. The results are typically displayed as Bode plots. It answers: "How does this circuit respond to different frequencies?"

When to use AC analysis:

Key settings:

Example: Low-Pass RC Filter

A simple RC low-pass filter with R = 1k ohms, C = 100nF:

The Bode plot from AC analysis visually confirms the filter's frequency response.

Step-by-Step SPICE Tutorial

Step 1: Draw the Circuit

Start by drawing your circuit schematic. Place components, set their values, and connect them with wires. Every circuit needs:

Step 2: Set Component Values

SPICE uses standard engineering notation:

Suffix Multiplier Example
T 10^12 1T = 1 tera
G 10^9 1G = 1 giga
Meg 10^6 1Meg = 1 mega
k 10^3 10k = 10,000
m 10^-3 100m = 0.1
u 10^-6 10u = 10 micro
n 10^-9 100n = 100 nano
p 10^-12 22p = 22 pico

Step 3: Choose Your Analysis Type

Based on what you want to learn about the circuit:

Step 4: Run the Simulation

Click the simulate button. The SPICE engine:

  1. Builds the circuit matrix (nodes and branches)
  2. Solves the equations iteratively (Newton-Raphson for nonlinear circuits)
  3. Generates results for each node and branch

Step 5: View Results

Results are displayed as:

Step 6: Iterate

If the results are not what you expected:

  1. Check component values and connections
  2. Verify the ground reference is connected
  3. Adjust component values and re-simulate
  4. Compare simulation results to hand calculations

Common SPICE Components

Passive Components

Sources

Semiconductors

Practical Simulation Examples

Example 1: LED Current-Limiting Resistor

Verify the correct resistor value for an LED:

DC simulation confirms: LED current = 21.2mA (acceptable)

Example 2: 555 Timer Astable

Simulate a 555 timer generating a 1 kHz square wave:

Example 3: Audio Amplifier Frequency Response

Test a common-emitter amplifier's bandwidth:

Example 4: Power Supply Ripple

Simulate a full-wave rectifier with filter capacitor:

Tips for Better Simulations

  1. Always add a ground node: Every SPICE circuit needs a ground reference (node 0). Missing ground causes convergence errors.
  2. Start simple: If a complex circuit fails to converge, simulate subsections separately first.
  3. Check component values: A missing decimal point (10 ohms vs 10k ohms) gives wildly wrong results.
  4. Use realistic models: Ideal op-amps work for basic checks, but real models reveal bandwidth limits and offset voltages.
  5. Watch for convergence errors: These usually mean a circuit condition that SPICE cannot solve (e.g., voltage source directly across a voltage source). Add small series resistance.
  6. Verify with hand calculations: Simulation should confirm your calculations, not replace them. If the results disagree, find out why.

SPICE Simulation in CircuitDiagramMaker

CircuitDiagramMaker includes a full SPICE simulation engine directly in the browser -- no separate software needed:

  1. Draw your circuit in the editor with drag-and-drop components
  2. Set component values by double-clicking each component
  3. Click Simulate and choose DC, transient, or AC analysis
  4. View results overlaid on the schematic or in the waveform viewer
  5. Iterate on the design without switching between applications

The AI circuit generator can create simulation-ready circuits -- describe your circuit and it generates a complete schematic with correct component values, ready to simulate.

Common SPICE Simulation Errors and How to Fix Them

Even correctly designed circuits can fail to simulate if the netlist has an issue SPICE cannot resolve numerically. These errors are not bugs in the simulator -- they mean the circuit as described does not have a well-defined solution, or the solver could not find one within its iteration limits.

Error Typical Cause Fix
"No DC path to ground" / floating node A node (often a capacitor-only branch or an unconnected component pin) has no resistive path to the ground reference Add a large resistor (1M ohm or more) from the floating node to ground, or check for a missing wire
Convergence failure in DC or transient analysis Two voltage sources connected directly in parallel, a voltage source directly across a capacitor, or aggressive nonlinear device models Add a small series resistance (0.01-1 ohm) between conflicting sources; loosen convergence tolerances only as a last resort
Singular matrix error A node has no connection at all, or a component value is set to zero (e.g., a 0-ohm resistor used where a wire was intended) Check for unconnected pins; replace 0-ohm components with a small nonzero value or an actual wire
Simulation runs but results look wrong Missing or incorrect ground node (node 0), wrong component value (decimal point or unit suffix error) Confirm every circuit has one node designated as ground/reference; recheck component value suffixes (m vs Meg, u vs n)
Transient analysis "timestep too small" The solver is struggling with a fast transition (sharp edge, switching event) and keeps shrinking the timestep Set a maximum timestep manually, simplify very fast edges in source definitions, or add a touch of parasitic capacitance to soften transitions

Every SPICE circuit needs exactly one node identified as ground (node 0), and every other node needs at least one DC-connected path back to it -- even circuits built entirely from capacitors and inductors, which have no DC resistance path unless you add one.

Setting Simulation Step Size and Initial Conditions

For transient analysis, the time step controls both accuracy and simulation speed. As a working rule, set the maximum time step to somewhere between 1/10 and 1/100 of the fastest time constant or signal period in the circuit. A circuit with a 10ms RC time constant simulated with a 5ms step will produce a jagged, inaccurate charging curve; the same circuit stepped at 0.1ms or smaller resolves the exponential curve clearly.

Circuits with feedback, multiple stable states, or oscillators that need a "kick" to start (astable multivibrators, ring oscillators, flip-flops) may settle into an unrealistic or symmetric state if simulated from a cold start with all nodes at 0V. Two tools handle this:

Choosing the right device model also affects realism. An ideal op-amp model simulates fast and is fine for verifying gain and basic topology, but it will not show slew-rate limiting, input offset voltage, or bandwidth roll-off. A manufacturer's SPICE model (LM358, TL072, and similar) captures those real-world limits at the cost of a slower, more complex simulation.

Popular SPICE Simulators Compared

Several SPICE-based tools are in common use, each suited to different workflows:

Simulator Cost Platform Typical Use
LTspice Free Windows, macOS General analog design, power supplies; large built-in model library from Analog Devices
ngspice Free, open-source Windows, macOS, Linux Command-line and scriptable simulation; used as the simulation backend in some open-source EDA tools
PSpice Commercial (free student edition) Windows Integrated with Cadence OrCAD schematic capture; common in university engineering curricula

All three implement the same underlying SPICE analysis engine (DC, transient, AC) and read variations of the same netlist syntax, so a circuit built and understood in one tool transfers conceptually to the others -- the differences are mostly in the schematic editor, model libraries, and integration with other design software.

Conclusion

SPICE simulation is an invaluable tool for circuit design. It catches errors before you build, lets you experiment with component values instantly, and provides insight into circuit behavior that is difficult to measure physically. Start with simple circuits (voltage dividers, RC filters) to build confidence, then tackle more complex designs.


Simulate circuits in your browser with CircuitDiagramMaker -- the only online wiring diagram tool with built-in SPICE simulation (DC, transient, AC analysis).

Frequently asked questions

What is Monte Carlo analysis in SPICE, and when do I need it?

Monte Carlo analysis runs a simulation many times, randomly varying component values within their tolerance range each run, to see how manufacturing variation affects circuit performance. It's used when you need to know whether a design still works reliably with real-world component tolerances, not just with exact nominal values.

How long does a SPICE simulation typically take to run?

Simple circuits with a handful of components and a DC or basic transient analysis usually complete in under a second. Runtime grows with circuit complexity, the number of nonlinear devices (transistors, diodes), a long stop time paired with a small time step, and tight convergence requirements -- large circuits can take from several seconds to minutes.

Do I need to learn SPICE netlist syntax to use a graphical circuit simulator?

No. Graphical SPICE tools, including browser-based ones, generate the netlist automatically from the schematic you draw. Understanding basic netlist concepts (nodes, component references, the ground node) helps you interpret error messages, but you can build and run simulations entirely through the schematic editor without writing netlist code by hand.

Can SPICE simulate circuits with dual power supply rails, like +/-15V?

Yes. Dual-rail circuits are common in op-amp designs and are simulated by placing two DC voltage sources -- one for the positive rail, one for the negative rail -- both referenced to the same ground node. SPICE has no special mode for dual supplies; it simply solves both sources as part of the same circuit.

Does SPICE account for temperature effects on components?

SPICE device models include temperature-dependent parameters, and most simulators let you set a simulation temperature (default is typically 27°C/300K) or sweep across a temperature range. This affects semiconductor behavior noticeably -- diode forward voltage and transistor gain both shift with temperature -- but has little effect on ideal passive components.

Can I import a manufacturer's SPICE model for a specific real-world component?

Many SPICE tools support importing a manufacturer-supplied .MODEL or .SUBCKT file for a specific part number, letting you simulate with that exact component's characteristics instead of a generic device model. Availability depends on the simulator -- check whether your tool supports custom model or subcircuit import before relying on manufacturer-specific behavior.

Related guides