10
\$\begingroup\$

I need to do three transient simulations with different values of certain resistors (conveniently called R1 and R2) in each. What I mean to do exactly is this:

  • Sim. 1: R1 = 1 k\$\Omega\$, R2 = 10 k\$\Omega\$
  • Sim. 2: R1 = 1 M\$\Omega\$, R2 = 10 M\$\Omega\$
  • Sim. 3: R1 = 1 k\$\Omega\$, R2 = 1 M\$\Omega\$

If there were just one resistor whose resistance to vary, then I would just set its resistance to "{r1}" (I use lower case letters to make it a different variable/parameter than R1) and use a command such as:

.step param r1 list 1k 1meg 1k

However, since I have to change two parameters (together) two times each, I have read here that (at least on LTSpiceIV) that a workaround to my problem could be using something like this:

.step param X list 1 2 3

.param r1 = table(X, 1k, 1meg, 1k)

.param r2 = table(X, 10k, 1meg, 10meg)

Upon doing the simulation, I get the following warnings:

WARNING: Can´t resolve .param r2 = table(X, 10k, 1meg, 10meg)
Select OK to continue the simulation with the default model or Cancel to quit now.

The same applies for r1.

For some reason, the simulation doesn´t "break" if I add one extra element to the table. In that case, the simulation takes too long, advancing more slowly every time, as it would never end. I have tried setting X to 0 1 2 instead of 1 2 3, but that does not work either.

Here are some pictures:

Circuit + commands

Error message

Your help would be much appreciated.

\$\endgroup\$
  • \$\begingroup\$ I'm confused, do you want to simulate 3 situations or more? If you just want to simulate the 3 scenarios I wouldn't bother doing it with spice. \$\endgroup\$ – ACD Aug 26 '14 at 20:32
  • \$\begingroup\$ And what do you want the X axis to be? \$\endgroup\$ – ACD Aug 26 '14 at 21:02
  • \$\begingroup\$ I would like to simulate those three situations and plot them together. I know I could just export a CSV file and plot them with Octave or Excel, but it would be so much more useful to do it directly on LTSpice. In this post (electronics.stackexchange.com/questions/20811/…) someone said how to do it but it doesn't work for me. In this example I put three scenarios but I might need to put more. \$\endgroup\$ – sebascarra Aug 28 '14 at 13:28
  • \$\begingroup\$ As regards your second question, X would be the different indexes that let me access the table's values. Since (apparently) LT will only allow me to sweep through one variable at a time, I sweep through X and then I try to access the table's values according to the value that X has taken in that step. I hope I'm being clear. Thank you. \$\endgroup\$ – sebascarra Aug 28 '14 at 13:31
  • \$\begingroup\$ Well for one the table command wants an index, which is X, then a set of xy pairs. Each param should have 3 pairs in it, not three values. \$\endgroup\$ – ACD Aug 28 '14 at 13:53
14
\$\begingroup\$

In LTSpice the table command really creates a kind of dictionary where you have to specify key value pairs. The proper directive for your case would then be:

.step param Rx list 1 2 3
.param R1 table(Rx,1,1k,2,1Meg,3,1k)
.param R2 table(Rx,1,10k,2,1Meg,3,10Meg)

and set the value of the resistors to {R1} and {R2} respectively.

If you want to have the values of a resistor near to it, you can also enter (instead of value, when right clicking onto it)

R=table(Rx,1,10k,2,1Meg,3,10Meg)

into the resistor value field. This works the same way for all kinds of components and with an external script to create .asc files it can be used as a crutch for LTspices missing monte carlo functonality.

\$\endgroup\$
4
\$\begingroup\$

One parameter sweep/step can control multiple component values through expressions.

Your control variable you are stepping could be a phase angle or time delay or similar that you input in one or more formulas/expressions to obtain resulting component values or parameters to be applied in the design as {parameter}

This is useful if you want to maintain a relation or control some indirect physical property of the design like a current or filter property.

In the "op" command editor you can enter something like this:

.STEP param Imax 0.1 0.3 0.1 
.PARAM Uin= 5
.PARAM R = (Uin-0.84954605)/Imax

It steps Imax from 0.1 to 0.3 in steps of 0.1 and computes a resistor value R using parameter Imax, Uin, some assumed voltage drop 0.85.. of a diode.

The PARAM R can be referenced in a component value usng {R} notation. Notice Uin could be used as {Uin} in a voltage source or similar and so on.

For multiple lines in the "op" editor window use CTRL+M to keep all params in same textbox.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.