Switches (or switching functions) and Spice

LT spice, Curve Captor, PSUDII and whatever other sims you can think of.

Post Reply
Posts: 296
Joined: Fri Jan 28, 2005 3:45 pm

Switches (or switching functions) and Spice

Post by sbench »

Hi All,
One of the more interesting but not very well known things you can do with Spice is the ability to switch things around. This would be useful, for instance, if you're modeling tone controls.... you can switch different components in and out of the circuit, and display a family of curves depicting possible outputs for several settings. Similar, for a switched inductive attenuator, you can switch in various settings of the attenuator and plot a family of frequency response curves for each "tap".

To do this, we simply use the various tricks already shown here; namely, the "param" command, the "step" command, and the use of variables for circuit elements.

In the attached example, I have set up a parameter "swch" that I adjust during the simulation. I have several switch settings... all resistors, that heve either have a arbitrarily high value or an arbitrarily low value, depending on what the "swch" param is set by STEP.

This is a rather "tricky" example... During some of the steps, I want one of the switch elements (R11) to be on during several STEPS, so I used a "sine" function which is periodically zero... so any time I want R11 on, the "value" of that variable is a multiple of pi. (thus making the resistance zero).

Note that the switches are either about 1 ohm (not zero... Spice don't like resistanceless elements) or about 10e8 ohms. (also don't like infinities).

Note the nice set of curves it produces.

sw_test.gif (29.58 KiB) Viewed 6198 times
Post Reply