Circuit with multiple modes

Hi! I’m new to Qspice and not going back. I have a question that may turn into a feature request.

I often have a circuit that can be configured in multiple modes meaning that a few parts are either DNI or with different values. I’d like to be able to run the sim for each mode.

Seems like what is needed is a rudimentary scripting ability. Maybe just the equivalent to a C switch statement that evaluates before each run.

Simplified example:
param state=0
switch(state)
{
case 0:
R1=1K;
C1=1n;
state=1;
break;
case 1:
R1=10K;
C1=1p;
state=2;
break;
default;
}

This would allow for multiple states of the circuit. Any thoughts?
Or, is there a way to do this using a C++ block?

Regards,
Ken

This example from my article and its raw material. I think this is very close to what you want to do.

image

Using the .step and .param commands with a table is a common method employed in spice simulations.

Excellent! Thank you both.

Looks like it can be made a bit more readable. I tried using text but that didn’t work.

Didn’t work? What error message you received?
Replicate your setup and work properly in Qspice.
table.qsch (2.7 KB)

What I showed does work using params, no problem. I tried using text for STATE and that doesn’t seem to work but I probably shouldn’t expect it to.

Fatal error: Trouble parsing “STATE LIST PROTO TEST PRODUCTION”

StateMachine text Example.qsch (2.5 KB)

In your example, you haven’t defined proto, test, production parameters.

.param

  • proto=0
  • test=1
  • production=2

Also, in step function you need to write it correctly like: .step param STATE list proto test production.

.step param STATE list proto test production

Best regards

Yeah, I was just seeing if that worked also. Thanks