How to make a switch whithout any other connections in LTSpice ?

Thread Starter

Marus780

Joined Jan 11, 2023
81
Hi,
I want to have a clean switch on my schematics, without the voltage source that controls it. That I will put it on a side...
I tried to modify the classical switch and pass the nodes for the voltage source that controls it, as parameters, but it does'n work...
Do you have an idea how to do this ?

screenshot.1.png
 

Attachments

ericgibbs

Joined Jan 29, 2010
19,194
hi Marus,
Welcome to AAC
May I ask why this type of control is required, there maybe other ways to achieve the same result.
E
 

Thread Starter

Marus780

Joined Jan 11, 2023
81
Because my schematic look ugly with that voltage sources, that controls every switch, all over the place. I want to put them on a side of the schematics, with no connections to them. I don't necessarily want to do as in my example. I just want a simple switch that I can control it by other means other than adding direct connection to it. It can be controlled in any way, it doesn't matter. As long as it is controlled remotely.
 

Papabravo

Joined Feb 24, 2006
21,345
If the one-time behavior is not what you are looking for in the model for the switch, you could also embed a behavioral source that would be directly controlled by a voltage outside of the subcircuit. The SpiceLine for the switch would contain the expression for the behavioral source.

ETA: The problem is that you can't easily pass an expression to a subcircuit, only parameters which have a numeric value. It should be possible to pass a node name, but the particulars of the method escape me at the moment.
 
Last edited:

Thread Starter

Marus780

Joined Jan 11, 2023
81
Thank you, both !
That's exactly what I did, by taking example from the models attached by @ericgibbs !
And it works perfectly ! Thank you so much !

.SUBCKT SW_PLS sw1 sw2 delay1={delay} width1={width} period1={period} cycles1={cycles}
V1 3 0 pulse(0 1 {delay1} 100n 100n {width1} {period1} {cycles1})
S1 sw1 sw2 3 0 Smod
.model Smod Vswitch(Ron=1u Roff=100G)
.ENDS
 
Last edited:

Thread Starter

Marus780

Joined Jan 11, 2023
81
@ericgibbs This is how I've done:

.SUBCKT SW_PLS sw1 sw2 PARAMS:
+delay=500m
+width=100m
+period=300m
+cycles=0
V1 3 0 PULSE(0 1 {delay} 100n 100n {width} {period} {cycles})
S1 sw1 sw2 3 0 Smod
.model Smod Vswitch(Ron=1u Roff=100G)
.ENDS

.SUBCKT SW_PWL sw1 sw2 PARAMS:
+t1=0
+v1=0
+t2=0
+v2=0
+t3=0
+v3=0
V1 3 0 PWL({t1} {v1} {t2} {v2} {t3} {v3})
S1 sw1 sw2 3 0 Smod
.model Smod Vswitch(Ron=1u Roff=100G)
.ENDS

But it would be nice if I could add parameters with an undefined number to the version controled by PWL...
 

Papabravo

Joined Feb 24, 2006
21,345
@ericgibbs This is how I've done:

.SUBCKT SW_PLS sw1 sw2 PARAMS:
+delay=500m
+width=100m
+period=300m
+cycles=0
V1 3 0 PULSE(0 1 {delay} 100n 100n {width} {period} {cycles})
S1 sw1 sw2 3 0 Smod
.model Smod Vswitch(Ron=1u Roff=100G)
.ENDS

.SUBCKT SW_PWL sw1 sw2 PARAMS:
+t1=0
+v1=0
+t2=0
+v2=0
+t3=0
+v3=0
V1 3 0 PWL({t1} {v1} {t2} {v2} {t3} {v3})
S1 sw1 sw2 3 0 Smod
.model Smod Vswitch(Ron=1u Roff=100G)
.ENDS

But it would be nice if I could add parameters with an undefined number to the version controled by PWL...
Use a PWL statement that refers to a file of time-voltage pairs. and don't forget about using the "repeat forever" clause
 

Thread Starter

Marus780

Joined Jan 11, 2023
81
@ericgibbs Yes, that's it !

@Papabravo If find it complicated to use files for this operation...
But I found a workaround to do this for some points:

.SUBCKT SW_PWL sw1 sw2 PARAMS:
+t1=10001
+t2=10002
+t3=10003
+t4=10004
+t5=10005
+t6=10006
+t7=10007
+t8=10008
+t9=10009
+t10=10010
V1 3 0 PWL(0 0
+{t1-10n} 0 {t1} 1 {t2-10n} 1 {t2} 0
+{t3-10n} 0 {t3} 1 {t4-10n} 1 {t4} 0
+{t5-10n} 0 {t5} 1 {t6-10n} 1 {t6} 0
+{t7-10n} 0 {t7} 1 {t8-10n} 1 {t8} 0
+{t9-10n} 0 {t9} 1 {t10-10n} 1 {t10} 0
+)
S1 sw1 sw2 3 0 Smod
.model Smod Vswitch(Ron=1u Roff=100G)
.ENDS

And the parameter SpiceLine can be like this: t1=0.4 t2=1.2 t3=1.4.... At every time point, it will shich to the other state.
 
Last edited:
Top