I advise anyone to read the following post/posts beforehand: Switch Circuits and Functions for context on the types of switches and how they function. If anyone does not have experience with the program, please refer to my first post and/or my sub-circuit post.
There are four main types of mechanical switch types: SPST, SPDT, DPDT, and DPST. Two of these switch types have different default forms: The SPST can either be SPST-NC or SPST-NO where NC is normally closed and NO is normally open. The DPST switches also have the same type of forms (DPST-NO; DPST-NC). SPDT and DPDT do not typically call this out because of how they are designed. LTSpice has the capability of modeling these switches using something called a “Voltage Controlled Switch”. This one of the software’s implementation of a basic switch because one cannot physically “press” a switch in this software. Click the component symbol and search for “switch”.
This device is almost equivalent to a very simple relay where a voltage source controls whether the switch is open or closed. These built-in switches require a spice command to operate. First, I recommend naming the switch by right-clicking the text “SW” and giving it a unique name. I have a set of preferences when setting up switches for experimenting that work well. Press the “S” key and type the following:
“.model SW yourModelName(Roff=1G Ron=25u Vt=0.1 Vh=0.1)” These values represent the resistance seen by the circuit when off, when on, trigger voltage for activating the switch, and some hysteresis on the trigger voltage (basically tolerance on that voltage). The default values can be used if one types “.model SW yourModelName()” in the SPICE command box instead. The default values can be found if Help is clicked (or F1) and search for “switch”.
Double click Voltage Controlled Switch to get some information on using the part as well as the default values.
Let’s start with the normally closed version of the SPST switch (default is comparable to a normally open version). I wanted to make the switches consistent with how the default SPST switch is set up, here is the circuit:
The item connected to the + pin is the logic inverter that comes pre-installed, click the components symbol and search for “inv”. The default logic gates in LTSpice are set to 1V instead of 5 or 3.3, I set up the inverters to 5V by right-clicking the part:
The “Value” will be blank the first time, I set the value to td=10n and Vhigh=5. Td is the rise time for the logic inverter while Vhigh is the voltage at which it will trigger/output. 5V is common for many integrated circuits. This post will have a few inverters in the design of the switches (use the same settings) and will all have the base switch: use “.model SW yourModelName(Roff=1G Ron=25u Vt=0.1 Vh=0.1)” for each switch model when I have them in a circuit. Click “Hierarchy” and Create a New Symbol. Make something similar to this:
For the block method, remember that the pin names need to be the same, but do not require netlist order. Pressing “L” will draw lines, pressing “C” will draw circles, and pressing “P” will draw pins. Remember that text placement for pins kind of behaves opposite in direction (left appears to the right and right appears to the left, this is because it assumes one is making an IC chip). Finally, remember to name the schematic and the symbol the same. They schematic will have a “.asc” extension while a symbol will have a “.asy” extension. The sub-circuit will not work if they do not have the same name and are not in the same working directory.
The next model with a single pole is an SPDT type switch. This type of switch consists of one connection point on one side and two separate connection points on the other. This usually provides a way to control two separate circuits by toggling between the two. Here is the circuit diagram:
Save the schematic and name it. Then, make the associated symbol:
To get different line styles like the dotted line, click the “Draw” menu next to “Hierarchy” and click “Line Style”. There are a few options to pick in the drop down.
Remember to change this back if solid lines or other styles are wanted. It will keep the last style used until changed manually. I used a dotted line to represent the alternate switch position since there is no animation between states. The schematic is set up so that the default position has a connection between 1 and 2 when no source voltage is present on “+”.
The DPDT switch contains two SPDT switches that are both activated at the same time. I used a shortcut to make this schematic:
You can use your own sub-circuits in a sub-circuit design due to the hierarchy design. The diagram is a little confusing because there are multiple references to “1”, “2”, “3” and “+”, “-”. When we use the SPDT model we made earlier, LTSpice only makes a reference of what pins 1, 2, 3, +, and - connect to in the sub-circuit of that component. Placing connection points with the same name in the new schematic make new references that only apply to anything being connected in that schematic. Here is the symbol I made:
I used regular dashes to represent the alternate paths for the switch while a dash with two dots represents the mechanical connection between the two SPDT switches.
DPST-NO switches are simply SPST-NO switches that are mechanically connected to turn on and off at the same time. So the schematic equivalent would be to connect the plus ports of two SPST switches.
Here is the symbol:
Finally, a DPST-NC is just the inverse of a DPST-NO. I used the DPST schematic in this new schematic and added an inverter on the “+” port.
Here is the symbol: