Stepping Component and Model Parameters in LTSPICE

Stepping component and model parameters is essential for many SPICE simulations. Some SPICE simulation programs are offering better capabilities than the other. The most convenient and flexible way of stepping SPICE parameters (that I tried) is offered by Micro-Cap from Spectrum Software. Most times you don’t have to change anything in the schematic. Just check components that you want to step and select the way of stepping. You can also step a lot of different parameters simultaneously. Unfortunatly, I don’t have access to this software any more.

LTSPICE is not offering very convenient and user friendly way to step parameters. However, with LTSPICE you can step more than one parameter simultaneously. This highly influenced my selection of SPICE simulation software, over ORCAD (Cadence) PSPICE. PSPICE was able to step only one parameter at a time. At least I was not able to setup PSPICE to do so.

LTSPICE does not offer any user interface enhancements to support stepping of component values and model parameters. This means that you have to memorize some of this stuff and that’s the reason for this short reference.

The first thing that came to my mind as a good example of stepping function in LTSPICE was RLC filter.

Files, used in this example are included in Stepping_parameters.zip.

Schematic, used in simulations looks like:

Schematic for Parametric Sweep

Schematic for Parametric Sweep

And results of this simulation are:

Stepping parameters - results

Stepping parameters - Results

First step in setting up parametric stepping is assigning a name to the value that you want to step.

Select value of any component that you plan to step and put it’s name in curly braces {}. You are not limited to component values for simple components. You can also step parameters of other parts like sources and etc. In example file I’m stepping AC amplitude of voltage source V1, used for frequency sweep in AC analysis.

Second step is to write .STEP SPICE directive to describe how you want to step this particular value.

There are a couple of ways how you can step (or sweep) parameters.

1. Linear Sweep.

.STEP directive for linear sweep looks like:

.step lin param NameOfParameter LowLimit HighLimit StepSize.

In this case parameter value, referenced as NameOfParameter will be stepped, starting with LowLimit and continuing as (LowLimit+StepSize),  (LowLimit+2*StepSize),…(LowLimit+n*StepSize) until it is <= HighLimit.

Sweep type lin could be omitted.

.step param NameOfParameter LowLimit HighLimit StepSize is also valid and has the same meaning.

Examples:

.step lin param L 1 22 7

means linear step of L from 1 to 23 with increments of 7 (1; 8; 15; 22)

.step param gen_ampl 1 21 10

means linear step of gen_ampl from 1 to 21 with step size of 10 (1; 11; 21)

2. Logarithmic Sweep by Octave.

.step oct param NameOfParameter LowLimit HighLimit Num.

Where NameOfParameter is variable name that would be swept, LowLimit is starting value, HighLimit is end value and Num is amount of stepes per octave.

Example:

.step oct param val1 1uF 20uF 3

means logarithmic sweep of capacitance value referenced as val1 from 1uF to 20uF in 3 logarithmic steps per octave.

3. Logarithmic Sweep by Decade.

.step dec param NameOfParameter LowLimit HighLimit Num.

Where NameOfParameter is variable name that would be swept, LowLimit is starting value, HighLimit is end value and Num is amount of stepes per decade.

Example:

.step dec param R_val 100 10k 2

means logarithmic sweep of resistance value referenced as R_val from 1oo Ohm to 10 KOhm in 2 logarithmic steps per decade.

4. Sweep, using list of values.

.step param NameOfParameter list val1 val2 … valn

Where NameOfParameter is variable name that would be swept, list keyword means that this sweep will use list of values, val1… valn are actual values that would be used in sweep.

Example:

.step param R list  100 300 5k 90k

Third step is not required but I highly recommend to use it. It is setting default values for parameters that you are stepping.

As I mentioned before, LTSPICE allows to step more than one variable at a time. However you are limited to 3 parameters that LTSPICE can step simultaneously. This is quite reasonable because it would be almost impossible to analyze plot with much more variables. I’m usually preparing .STEP commands for all components that I would like to sweep and commenting this directive for parts that I don’t want to sweep for this run of simulation. In this case default value will be used for parameter, that is not stepped in this simulation.

.PARAM directive allows setting up default value.

.param NameOfParameter=DefaultValue

Where NameOfParameter is variable name that default value is assigned to and DefaultValue is default value for that parameter.

Examples:

.param val1=1uF

.param R=100

.param R_val=3k

In this case you don’t have to change {value} of component that you are not stepping in this particular simulation to it’s particular value, because you already defined it with .param directive.

The last thing that I want to mention-try to be reasonable while selecting amount of steps in your simulation. Even fast simulation will take a long time if amount of steps is big. Ad it builds up very fast (multiplies) as soon as more than one parameter is being swept. If you simulation plot is getting very crowded and unreadable, LTSPICE is offering to select only portion of steps on simulation plot by clicking on the plot with right mouse button and pressing  Select Steps option.

 

Comments

9 Responses to Stepping Component and Model Parameters in LTSPICE

  1. Ryan Butler says:

    In your example above.. how would one go about determining which curve corresponds to which set of parameters?

    I have a plot with over 2000 values, and I know which curve I want… but I don’t know which parameters generated that curve.

    Seems a little useless if I can’t determine this.

    Thanks… and please reply to rbutler81@gmail.com

  2. Eugene says:

    In my opinion, this is a big limitation of LTSPICE user interface. What you can do is: right click on the plot or go to plot settings menu and click on “Select Steps”. Then you can select one or a few steps. This way you can browse through all available steps to select which one is the best for your goal.

  3. Sean O'Connor says:

    There is a numerical optimizer for LTSpice that you might say is stepping with a purpose.

  4. Victor Jupin says:

    You can right click on your cursors (whenever the *mouse* cursor changes to the number ‘1’ or ‘2’). That will pop up a little dialog to tell you the step that you are tracing.

    Navigate your cursor with the up/down arrow keys.
    Enjoy!

  5. yohannes says:

    If I want to have plots for
    .STEP PARAM R1 1k 4k 1k. I will have 4 plots for each steps. I can see up to 4 plots on a single plot window if I do SELECT PLOTS from PLOT SETTING drop down menu. But is that possible to to see the 4 plots separately in 4 different plot windows? I appreciate If any on can help me.

  6. Eugene says:

    I think you can if you will select them manually

  7. Bob says:

    If I want to step two variables this way:
    .step param res1 10 100 10
    .step param res2 200 300 10
    But in a way that first sim is for res1=10 and res2 = 200 and then the very next iteration to be for res1=20 and res2=210?
    Usually there will be 100 iterations instead of the 10 I only need. That’s a lot of lost time.

  8. William says:

    Okay, I am at my wit’s end. I’m trying to see the “step values” on the graph, ie., by right clicking the cursor when it shows up as a number.

    Earlier today, I right clicked the number (after the cursor became a number), and the dialog box popped open and told me which step that was. So it worked fine and I said “cool”.

    However, I’m trying to do it again, and it’s not working now!!! I hover over the cursor, it turns into a yellow “1”, and I right click, but then it brings up the context menu for the graph. I’ve tried everything it seems, but I keep getting the context menu when I right click, and NOT the step value!!! What do I do?????

    Also, “Select steps” from that context menu is greyed out.

  9. kensmith says:

    A useful trick
    .step param thing list 1 2 5 10
    .step param other list 0.9 1 1.1
    .param R1Val={thing*other}
    .param R2Val=(thing/other}

    This will run with widely stepped values as the intended value and 10% this way and that way on the accuracy