Sweep Parameter "Switch State" in Time Domain Simulation

I ran into this issue and figured it out, maybe it will be helpful to someone else.

In a simulation you may want to simultaneously simulate circuit behavior with a switch open or closed, or in state A or B, etc.

You might think that you could Sweep Parameter for something like SW1.STATE and set it to "Custom" with "A, B" as the options but nothing like this appears to be supported.

Instead you can accomplish this by replacing your switches with resistors, and assigning them expressions using the "Parameter Element" (under "Unsorted Elements").

For example if you wanted to sweep an SPDT switch in both states, first create a new parameter element called SWITCHSTATE and give it value 0. Then create two resistors, one with R = SWITCHSTATE and the other with R = 1G - SWITCHSTATE.

Then if you Sweep Parameter SWITCHSTATE in your simulation using values 0 and 1G, the two resistors will effectively be 1 short and 1 open, then 1 open and 1 short. From this you can construct an SPDT switch that you can simulate in either state.

by cjpicklesimer
May 04, 2020

Can't seem to make it running.. Can you describe a bit more clearly for a beginner please?

by dannyvl
June 17, 2020

@dannyvl Take a look at this example:

This accomplishes the same thing as described above without the explicit Parameter Element.

by mrobbins
June 17, 2020

@mrobbins : Works like a charm, many thanks!

Danny

by dannyvl
June 17, 2020

Post a Reply

Please sign in or create an account to comment.

Go Ad-Free. Activate your CircuitLab membership. No more ads. Save unlimited circuits. Run unlimited simulations.

About CircuitLab

CircuitLab is an in-browser schematic capture and circuit simulation software tool to help you rapidly design and analyze analog and digital electronics systems.