# LTspice: Voltage Controlled Switches

LTspice includes a large number of excellent FET models, but sometimes you need to simulate a simple switch that opens and closes at specific times or under certain conditions.

To insert and configure a switch in LTspice…

1. Insert the symbol for the voltage-controlled switch in your schematic (press F2 and type “sw” in the search field of the symbol library).
2. Insert a SPICE directive (press S) and define the SW model’s parameters using this example:
.model MYSW SW(Ron=1 Roff=1Meg Vt=.5 Vh=-.4)
where “MYSW” is the unique model name, Ron and Roff are the on and off resistances and Vt and Vh are the trip and hysteresis voltages. The switch trips at (Vt − Vh) and (Vt + Vh).
LTspice Help (press F1) contains more about the SW model parameters.
3. Assign the MYSW model to the switch symbol S1: right-click “SW” and enter the unique model name, “MYSW”.
4. Control the switch with a voltage source connected to the positive terminal of the switch and ground the negative terminal. In this example a PULSE function source is used to generate a 0V–1V triangle waveform with a 1ms period.

The switch has three distinct modes of voltage control, depending on the value of the hysteresis voltage, Vh. If Vh is zero, the switch is always completely on or off depending upon whether the input voltage is above the threshold. If Vh is positive, the switch shows hysteresis, as if it was controlled by a Schmitt trigger with trip points at Vt - Vh and Vt + Vh. Note that Vh is half the voltage between trip points which is different than the common laboratory nomenclature. If Vh is negative, like in this case, the switch will smoothly transition between the on and off impedances. The transition occurs between the control voltages of Vt - Vh and Vt + Vh. The smooth transition follows a low order polynomial fit to the logarithm of the switch's conduction. For more information on voltage-controlled switch please refer to LTspice help file (F1).

One classic application of voltage-controlled switches is simulating open-circuit and short-circuit conditions. In the example shown, two switches simulate a short- and open-circuit condition on an LED string.