next up previous contents index
Next: Transmission Lines (General) Up: Passive Element Lines Previous: Switches   Contents   Index


Switch Model

Type Names: csw, sw

The switch model allows an almost ideal switch to be described in WRspice. The switch is not quite ideal, in that the resistance can not change from 0 to infinity, but must always have a finite positive resistance. By proper selection of the on and off resistances, they can be effectively zero and infinity in comparison to other circuit elements. There are two different types of switch devices; current-controlled (keyed by w), and voltage-controlled (keyed by s). Both reference the model described below. The parameters available are:

Switch Model Parameters
name parameter units default switch
vt threshold voltage V 0.0 S
it threshold current A 0.0 W
vh hysteresis voltage V 0.0 S
ih hysteresis current A 0.0 W
ron on resistance $ \Omega$ 1.0 both
roff off resistance $ \Omega$ 1/gmin* both
* The gmin parameter, can be set on the .options line. Its default value results is 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 of all it is wise to set ideal switch impedances only high and low enough to be negligible with respect to other circuit elements. Using switch impedances that are close to ``ideal'' in all cases will aggravate 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 > 1e12), then the tolerance on errors allowed during transient analysis should be decreased by using the .options line and specifying trtol to be less than the default value of 7.0 (options can also be set from the prompt line from within WRspice). 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 WRspice to be more careful around the switch points so that no errors are made due to the rapid change in the circuit.


next up previous contents index
Next: Transmission Lines (General) Up: Passive Element Lines Previous: Switches   Contents   Index
Stephen R. Whiteley 2022-09-18