LTspice: Plotting a Parameter Against Something Other Than Time (e.g. Resistance)

A common use for LTspice® is to run a time domain transient analysis where a parameter (e.g. voltage or current) can be plotted against time. Occasionally, you may wish to know the behavior of a circuit versus another parameter such as resistance. This can be done by using the “.measure” and “.step” SPICE directives along with the SPICE Error Log.

Output Voltage of a Programmable Current Source vs. Load Resistance

The LT3092 is an easy to use programmable current source. It is chosen for this example due to its easy to understand operation and quick simulation time.

Adjustable Two Terminal 200mA Current Source

LT3092 - 200mA 2-Terminal Programmable Current Source

With ROUT = 5Ω and RSET = 20kΩ the LT3092 produces a temperature stable 40mA current source with a wide compliance range. Imagine a case where this current source drops across a variable resistor and we wish to plot the load voltage vs. the changing resistor. A link is provided on the right panel to an LTSpice file, which illustrates the process. The following are the basic steps to achieve the desired results.

1. Open a new schematic in LTspice, insert LT3092 symbol by pressing the ‘F2’ function key and finish drawing the schematic and labeling the nets as follows.

LT3092 Schematic

LT3092 Schematic

2. Right click on the schematic and edit the simulation command to the following.

.tran 0 510m 500m

Above we mentioned that it would be nice to plot a parameter against resistance. To be exact, what we want to do is to plot the voltage at node ‘LOAD’ once the simulation has reached steady state. In this circuit, we know that the LT3092 reaches steady state long before 500ms. So we run the simulation for a given resistor for 500ms, then start saving data for the next 10ms.

3. Insert the following SPICE directives into the schematic by selecting 'S' on your keyboard.

.save V(load)
.step param X 10 30 1
.measure VLoadAvg avg V(load)
.option plotwinsize=0 numdgt=15

The .save statment only saves voltage data for node 'LOAD' which can help speed up large simulations.

The .step command steps the paramater 'X', in this case a load resistor, from 10Ω to 30Ω in 1Ω increments. This means the simulation must run 21 times. So take care that more complex simulations make take some time to complete.

The .measure calculated the average voltage of node 'LOAD' and store it into the variable 'VLoadAvg'.

Lastly, the .options statment sets plotwinsize = 0 which disables compression and numdgt is used to set significant figures used for output data. If numdgt > 6, double precision is used.

LT3092 Schematic with .MEASURE Statement

LT3092 Schematic with .MEASURE Statement

4. Run the simulation.

When the simulation runs, the .measure statement output is put in the .log file which can be viewed in the SPICE Error Log. If the simulation includes a .step command, the .measure statements are executed for each step and the results are printed as tables in the .log file. These tables for .measure results can then be plotted like normal waveforms by the following.

5. To view the resulting data in the waveform viewer, use CTRL-L to open the SPICE Error Log and right-click on the log to select “Plot .step’ed .meas data”.

LT3092 Vload vs Rload

LT3092 Vload vs Rload

In this example, the axis are not labeled. But we know that the x-axis is the load resistance and the y-axis is the load voltage.

Another approach is using the .op simulation to perform a DC operating point solution with capacitances open circuited and inductances short circuited. It provides direct results as show above.

LT3092 Schematic with .OP Simulation

LT3092 Schematic with .OP Simulation

By referring to the above example, you can use LTSpice to visualize a parameter as a function of several items. Here we showed resistance. But it is also possible to record and plot a measurement versus such things as temperature, capacitance or inductance values. The .measure statement and .op simulation are quite flexible, allowing you measure much more than just a simple average. You could even measure and plot a regulator’s transient response versus a varying compensation component.


Joseph Spencer

Joseph Spencer

Joseph Spencer has been a field applications engineer with Linear Technology (now part of Analog Devices) since 2013. Joseph supports customers in Utah and Idaho, focusing on high performance analog and RF solutions. Prior to being an FAE, Joseph worked at L3 Communications, where he designed and managed the design of hardware for software-defined radios. Joseph started his career at Maxim Integrated where he worked in both applications and test engineering roles. Joseph holds both a bachelor’s and master’s degree in electrical engineering from the University of Utah.


Gabino Alonso

Gabino Alonso is currently the director of strategic marketing for the Power by Linear™ Group. Prior to joining ADI, Gabino held various positions in marketing, engineering, operations, and education at Linear Technology, Texas Instruments, and California Polytechnic State University. He holds a Master of Science degree in electrical and computer engineering from University of California, Santa Barbara.