1P3T switch model in ltspice

Thread Starter


Joined Jan 17, 2007

Thread Starter


Joined Jan 17, 2007
View attachment 96056 If you're interested in another tool for this, here is the same example using a new free, online tool for analog, digital, mixed-signal, and mixed-domain modeling and simulation.
go to https://www.systemvision.com/design/single-pole-triple-throw-switch/ to play with it (with a free account you can copy/edit the schematic and simulate)
The models are open-source.
You seem to be an important contributor to that site. Let me say then that you're very welcome to this site, I hope to hear from you more often, and your participation will be thoroughly appreciated. Thanks again for your recommendation.
@cmartinez Thanks for the welcome! This seems like a very useful site.

I am indeed very involved with systemvision.com, as a member of the team developing the site. It's new and we are still trying to get the word out that it's available. I would be happy to answer any questions that anyone has regarding what it's all about.
You can see the source code for any model on any www.systemvision.com schematic by using a right-mouse-button and selecting 'View/Copy Model'

For example, you can see the code behind the 1P3T switch or the controller (finger) on this schematic

The modeling language is IEEE standard 1076.1 -- VHDL-AMS
This is a superset of the VHDL digital language and includes analog and mixed-signal modeling constructs. The systemvision.com environment allows you to copy/modify any of these models.

Here is the VHDL-AMS code for the 1P3T switch.

library IEEE;
use IEEE.std_logic_1164.all;
-- Use IEEE natures and packages
use IEEE.electrical_systems.all;

entity SW_1P3T is
generic (r_open : resistance := 1.0e6; -- Open (off) resistances [Ohm]
r_closed : resistance := 1.0e-3; -- Closed (on) resistances [Ohm]
td_make : real := 1.0e-9; -- time to "make" contacts [Sec]
td_break : real := 1.1e-9); -- time to "break" contacts [Sec]

port (signal ctrl : in integer;
terminal com, p1, p2, p3 : electrical);

end entity SW_1P3T;

architecture ideal of SW_1P3T is

signal r_sig1 : resistance := r_closed; -- sets default to position 1
signal r_sig2 : resistance := r_open;
signal r_sig3 : resistance := r_open;
quantity v1 across i1 through com to p1; -- branch quantities
quantity v2 across i2 through com to p2;
quantity v3 across i3 through com to p3;
quantity r1 : resistance; -- free quantities
quantity r2 : resistance;
quantity r3 : resistance;


-- purpose: Detect Switch position and assign resistance value to r_sig
-- type : combinational
-- inputs : ctrl
-- outputs: r_sig
DetectPosition : process (ctrl)
-- position 1 (default) connects com to p1
if (ctrl = 1) then
r_sig1 <= r_closed; -- signal assignments
r_sig2 <= r_open;
r_sig3 <= r_open;
-- position 2 connects com to p2
elsif (ctrl = 2) then
r_sig1 <= r_open;
r_sig2 <= r_closed;
r_sig3 <= r_open;
-- position 2 connects com to p3
elsif (ctrl = 3) then
r_sig1 <= r_open;
r_sig2 <= r_open;
r_sig3 <= r_closed;
-- undefined positions set all resistances to r_open
r_sig1 <= r_open;
r_sig2 <= r_open;
r_sig3 <= r_open;
end if;
end process DetectPosition;

r1 == r_sig1'RAMP(td_break, td_make); -- use 'ramp attribute for linear
r2 == r_sig2'RAMP(td_break, td_make); -- transition between values
r3 == r_sig3'RAMP(td_break, td_make);
v1 == r1*i1;
v2 == r2*i2;
v3 == r3*i3;

end architecture ideal;​


Joined May 20, 2015
Here is my version of the switch. This option allows you to switch when calculating the transient characteristics (Tran analysis). For this purpose, an additional pin. By submitting this pin dressing right, you set the switch to the desired position.Test1P3T.png