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自2013年起成为凌力尔特和ADI公司的现场应用工程师。 Joseph为犹他州和爱达荷州客户提供支持,主要负责高性能模拟和RF解决方案。 在担任现场应用工程师之前,Joseph在L3 Communications公司工作,负责软件定义无线电的硬件设计和管理工作。 Joseph最初就职于Maxim Integrated公司,曾担任应用和测试工程方面的职位。 Joseph拥有犹他大学电气工程学士和硕士学位。


Gabino Alonso

Gabino Alonso目前是Power by Linear™部门的战略营销总监。加入ADI公司之前,Gabino在凌力尔特、德州仪器、加州理工州立大学担任过市场营销、工程、运营和讲师等多个职位。他拥有加州大学圣巴巴拉分校电子和计算机工程硕士学位。