Switch
The Switch () feature is used to connect or disconnect the conducting path in a circuit under specific conditions.
Node Connections
Specify two Node names for the connection nodes for the current source. The first node in a pair represents the positive reference terminal from where the current flows through the source to the second node.
Switch Conditions
There are three types of conditions, Voltage controlled, Current controlled, and Custom expressions. For each type of condition there are two conditions, one for turn on and one for turn off. The on condition is true if the On condition expression is larger than zero, while the off condition is true if the Off condition is less than zero.
Note: The state of the switch (on/off) is changed only when a condition goes from false to true and not when going from true to false. Thus, if the state is off and the on condition goes from false to true, the state will shift from off to on. On the other hand, if the state of the switch is on and the on condition goes from true to false, nothing will happen.
The Initial state list has three options, Use on condition, Use off condition, and Boolean expression. The two former options mean that the switch will have an initial state matching to the on or off condition. The third option makes the switch’s initial state match a custom Boolean expression. Separating on, off, and initial states makes the switch more flexible and can support Schmitt-trigger style switches and various latches.
For the Voltage controlled switch, it is necessary to specify two nodes that defines the voltage sens.v that the switch state depends on. The conditions must be written as a function of this variable. Similarly, for the Current controlled switch it is necessary to specify a two-pin device that defines the current sens.i that the switch state depends on.
Switch Parameters
When the switch is in the on state it has a nonzero resistance specified by the On resistance expression. For the off state no current flows through the switch (infinite resistance). There is also a transition time for the switch to turn on and off set by the Switching time expression. The switch triggers an implicit event that updates a discrete state variable (with suffix _state).