switch - pepaslabs/LTSpice-parts GitHub Wiki

switch

LTspice comes with a symbol for a voltage-controlled switch, but it doesn't come with a model.

parts/switch/switch.mod supplies a basic model for this symbol.

How to use switch in LTSpice

LTSpice's voltage-controlled switch component is called sw.

Turning the switch on

The switch is controlled by voltage. To simulate the switch being turned on, we will control the switch with a PULSE voltage source.

The switch.mod model has a threshold voltage of 0.5 Volts, so we can turn it on by sending it 1 Volt.

Create the following circuit:

Save your LTSpice circuit. Copy parts/switch/switch.mod into the same directory where you saved your LTSpice circuit. Add the following .lib directive:

Simulate the circuit for 50 milliseconds:

Measure the voltage across the capacitor.

Turning the switch off

To turn the switch off, we specify a Ton time. Here, we will have the switch turn on at 10ms and turn off at 20ms.

LTSpice schematic

Here is the schematic used in this example: switch.asc.

See also