<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.
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
| Property | Description | Example |
|---|---|---|
duration | Total simulation time. Accepts numbers or time strings. | "10ms" |
timePerStep | Time interval between simulation steps. | "0.1ms" |
spiceEngine | SPICE engine to use. Typically "ngspice" or "spicey". | "ngspice" |
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
Simulation graphs can show multiple voltage and current channels on separate
colored value axes. Set graph display props on each <voltageprobe /> or
<ammeter /> channel:
graphDisplayNamesets the channel label.graphCentersets the measured voltage or current value at the channel center.graphOffsetDivsmoves that center up or down by graph divisions.graphUnitsPerDivsets the channel scale. Voltage probes use volts per division. Ammeters use amps per division.
export default () => (
<board routingDisabled>
<voltagesource name="V1" voltage="5V" schX={-4} />
<ammeter
name="IIN"
color="#e05a00"
graphDisplayName="IIN"
graphCenter={0.005}
graphOffsetDivs={1}
graphUnitsPerDiv={0.001}
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"
graphDisplayName="VIN"
graphCenter={5}
graphOffsetDivs={-1}
graphUnitsPerDiv={0.5}
/>
<analogsimulation
duration="4ms"
timePerStep="1ms"
spiceEngine="ngspice"
/>
</board>
)
For more end-to-end examples and best practices, we recommend reviewing the SPICE simulation guide.