Skip to main content
Built-in Elements

<analogsimulation />

Overview

<analogsimulation /> enables SPICE simulation for a <board /> and sets the simulation parameters, such as duration and time step. Place this element inside your board alongside sources and probes to generate simulation results.

If you're new to simulation workflows, check out the SPICE simulation guide for step-by-step examples.

Schematic Circuit Preview
export default () => (
<board routingDisabled>
<voltagesource name="V1" voltage="5V" />
<resistor name="R1" resistance="1k" />

<trace from=".V1 > .pin1" to=".R1 > .pin1" />
<trace from=".V1 > .pin2" to=".R1 > .pin2" />

<voltageprobe name="VP_IN" connectsTo=".V1 > .pin1" />
<voltageprobe name="VP_OUT" connectsTo=".R1 > .pin1" />

<analogsimulation duration="10ms" timePerStep="0.1ms" spiceEngine="ngspice" />
</board>
)

Properties

PropertyDescriptionExample
durationTotal simulation time. Accepts numbers or time strings."10ms"
timePerStepTime interval between simulation steps."0.1ms"
spiceEngineSPICE engine to use. Typically "ngspice" or "spicey"."ngspice"
graphIndependentAxesGive each voltage or current graph channel its own automatically scaled axis.true

Use <analogsimulation /> once per <board /> to define how the simulation runs. Combine it with <voltagesource /> and <voltageprobe /> elements to create and observe waveforms.

Multi-axis scope display

Use graphIndependentAxes when a simulation graph contains signals with different units or very different ranges. tscircuit creates one colored axis per voltage or current channel and automatically chooses the center, offset, and scale from the simulated data.

You can optionally override a channel's display on the probe itself:

  • graphDisplayName sets the channel label.
  • graphCenter sets the measured voltage or current value at the channel center.
  • graphVerticalOffset moves that center up or down in measured units, such as "1V" or "1mA".
  • graphVoltagePerDiv sets volts per division for <voltageprobe />.
  • graphCurrentPerDiv sets amps per division for <ammeter />.
Schematic Circuit Preview
export default () => (
<board routingDisabled>
<voltagesource name="V1" voltage="5V" schX={-4} />
<ammeter
name="IIN"
color="#e05a00"
connections={{
pos: ".V1 > .pin1",
neg: ".R_LOAD > .pin1",
}}
/>
<resistor name="R_LOAD" resistance="1k" schX={2} />

<trace from=".R_LOAD > .pin2" to=".V1 > .pin2" />

<voltageprobe
name="VIN"
color="#315cff"
connectsTo=".IIN > .pos"
referenceTo=".V1 > .pin2"
/>

<analogsimulation
duration="4ms"
timePerStep="1ms"
spiceEngine="ngspice"
graphIndependentAxes
/>
</board>
)

For more end-to-end examples and best practices, we recommend reviewing the SPICE simulation guide.