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