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.
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.
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.
.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.
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”.
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.
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.