Skip to main content
SPICE Simulation

SPICE Simulation Introduction

Overview

tscircuit supports SPICE simulation to analyze the analog behavior of your circuits. You can define voltage sources with various waveforms, place probes to measure voltages, and configure the simulation parameters. The results can be visualized to understand how your circuit performs over time.

Simulation Components

<analogsimulation />

This component configures and enables the analog simulation for the board.

PropertyTypeDescription
durationnumberThe total duration of the simulation (e.g., in seconds).
timePerStepnumberThe time interval between simulation steps (e.g., in seconds).
spiceEnginestringThe SPICE engine to use. Can be "spicey" (default) or "ngspice".

Example:

<analogsimulation
duration={0.01}
timePerStep={1e-6}
spiceEngine="ngspice"
/>

Probes

Probes are used to specify which parts of the circuit you want to measure. These do not have a physical representation on the PCB.

<voltageprobe />

Measures the voltage at a specific point in the circuit.

PropertyTypeDescription
connectsTostringA port selector indicating where to place the probe.

Example:

<voltageprobe connectsTo=".R1 > .pin1" />

<voltagesource />

For simulations, <voltagesource /> can be configured to produce various waveforms beyond a simple DC voltage.

PropertyTypeDescription
waveShapestringShape of the voltage wave. Can be "dc", "sine", "square", "triangle".
frequencystring or numberFrequency of the waveform (e.g., "1kHz" or 1000).
amplitudestring or numberAmplitude of the AC signal. For square waves, this is the peak voltage.
offsetstring or numberDC offset of the waveform.
dutyCyclenumberFor square waves, the fraction of the period the signal is high (0 to 1).