Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/guides/spice-simulation/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ Example:
| `amplitude` | string or number | Amplitude of the AC signal. For square waves, this is the peak voltage. |
| `offset` | string or number | DC offset of the waveform. |
| `dutyCycle` | number | For square waves, the fraction of the period the signal is high (0 to 1). |

### {"<switch />"}
<p>
For simulations, a {"<switch />"} can be configured to toggle at a
specific frequency.
</p>
| Property | Type | Description |
| :--- | :--- | :--- |
| `simSwitchFrequency` | string or number | Frequency at which the switch toggles (e.g., `"1kHz"` or `1000`). |
44 changes: 44 additions & 0 deletions docs/guides/spice-simulation/switch-example.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: Switch Example
sidebar_label: Switch
sidebar_position: 4
description: An example of using a switch in a SPICE simulation.
---
import CircuitPreview from "@site/src/components/CircuitPreview"

<p>
This example demonstrates how to use a switch in a SPICE simulation. When
the <code>simSwitchFrequency</code> property is set, an ideal switch will
toggle at the specified frequency. A voltage probe is placed after the switch
to observe the output.
</p>
<CircuitPreview
defaultView="schematic"
showSimulationGraph={true}
code={`
export default () => (
<board schMaxTraceDistance={10} routingDisabled>
<voltagesource name="V1" voltage="5V" />
<switch name="SW1" spst simSwitchFrequency="1kHz" />
<trace from=".V1 > .terminal1" to=".SW1 > .pin1" />
<resistor
name="R1"
resistance="1k"
footprint="0402"
connections={{ pin1: ".SW1 > .pin2", pin2: ".V1 > .terminal2" }}
/>
<voltageprobe connectsTo={".R1 > .pin1"} />
<analogsimulation
duration="4ms"
timePerStep="10us"
spiceEngine="ngspice"
/>
</board>
)
`}
/>
<p>
The simulation shows the voltage at the node after the switch. Since the
switch is toggling at 1kHz, the voltage probe will show a 1kHz square
wave going between approximately 0V and 5V.
</p>