Monday, May 18, 2015

LTspice Parameter Stepping Example

LTspice is an excellent SPICE circuit simulation and modeling tool provided free by Linear Technology.

One of the nice features that LTspice provides is the ability to drop SPICE simulation commands right onto your schematic as text - the image after the text illustrates two extremely useful commands: .MEASURE and .STEP

.MEASURE allows you to shortcut the process of using the waveform viewer to painstakingly trace along a waveform for the value you want. The command lets you evaluate a user-customizable expression - key when you want to evaluate the same parameter for a variety of simulation conditions - and will even prepare a table of results if you automate the conditions with .STEP. To see the results (or error messages for malformed commands  ) in LTspice, after simulation open the "SPICE Error Log" (or keyboard shortcut CTRL-L).

LTspice Wiki (unofficial) is a great LTspice resource and includes documentation for the .MEASURE syntax copied from the in-program help (see link for more details):  

Syntax: .MEAS[SURE] [AC|DC|OP|TRAN|TF|NOISE] <name>
 + [<FIND|DERIV|PARAM> <expr>]
 + [WHEN <expr> | AT=<expr>]]
 + [TD=<val1>] [<RISE|FALL|CROSS>=[<count1>|LAST]]

.STEP allows you to automate multiple simulations across a parameter. You can define a generic parameter using .PARAM <name> which can be used as a component value by de-referencing it using {name} and then calculate multiple simulation results/waveforms by sweeping or stepping the parameter. Other things you can "step" include temperature (to look at the temperature effect on your circuit) via parameter temp, model parameters such as transistor width or on-resistance, and even entire part models/subcircuits!

The syntax for .STEP is a little confusing so check out the LT Wiki copy of the in-program help for some examples - 

Syntax: .STEP [OCT|DEC] [<model>|PARAM] <parameter>|<source instance> [LIST] <<start value> <stop value> <steps>>|<list of values>

SPICE commands are activated in LTspice by placing them using the .op tool onto the schematic (Keyboard shortcut 'S').

Below is an example schematic with commands and resulting table of values in the SPICE Error Log. Two different parameters are stepped - temperature and load resistance - and the peak-to-peak difference across the temperature range as well as the average operating point across the temperature range is displayed in the error log. The step numbers correspond to the order specified in the command.


No comments:

Post a Comment