Voltage Switch

Spice Syntax


SXXXXXXX N+ N- NC+ NC- MODEL <ON><OFF>

 

Additional Information

More details can be found in the HyperSpice chapter in Extended Definitions for Advanced Users.

Examples


.MODEL smodel1 RON=100K

Switch1 1 2 10 0 smodel1 

The S- device is an ideal voltage switch. Nodes 1 and 2 are the nodes between which the switch terminals are connected. The model name is mandatory while the initial conditions are optional nodes, 3 and 4 are the positive and negative controlling nodes respectively.

Switch Model

The switch model allows an almost ideal switch to be described in SPICE. The switch is not quite ideal, in that the resistance cannot change from 0 to infinity, but must always have a finite positive value. By proper selection of the on and off resistances, they can be effectively zero and infinity in comparison to other circuit elements. The parameters available are:

name parameter units default
VT threshold voltage Volts 0.0
VH hysteresis voltage Volts 0.0
RON on resistance Ω 1.0
ROFF off resistance Ω *
* (See the .OPTIONS control line for a description of GMIN, its default value results in an off-resistance of 1.0e+12 ohms.)

The use of an ideal element that is highly nonlinear such as a switch can cause large discontinuities to occur in the circuit node voltages. A rapid change such as that associated with a switch changing state can cause numerical roundoff or tolerance problems leading to erroneous results or timestep difficulties.

The user of switches can improve the situation by taking the following steps:

First, it is wise to set ideal switch impedances just high or low enough to be negligible with respect to other circuit elements. Using switch impedances that are close to ``ideal'' in all cases aggravates the problem of discontinuities mentioned above. Of course, when modeling real devices such as MOSFETS, the on resistance should be adjusted to a realistic level depending on the size of the device being modeled.

If a wide range of ON to OFF resistance must be used in the switches (ROFF/RON >1e+12), then the tolerance on errors allowed during transient analysis should be decreased by using the .OPTIONS control line and specifying TRTOL to be less than the default value of 7.0.

When switches are placed around capacitors, then the option CHGTOL should also be reduced. Suggested values for these two options are 1.0 and 1e-16 respectively.

These changes inform SPICE3 to be more careful around the switch points so that no errors are made due to the rapid change in the circuit.