6
\$\begingroup\$

I have a circuit in LTSpice in which I want to measure some differential voltages, currently I'm manually adding the traces using the "Add Trace" menu in the plot view and writing its expressions.

I would like to know if there's a way to do this using a directive so that every time I run the simulations those traces are automatically added.

\$\endgroup\$
6
  • \$\begingroup\$ A good place to ask would be at the LTspice user group. \$\endgroup\$
    – EM Fields
    Commented Oct 24, 2015 at 15:25
  • \$\begingroup\$ Well, it's a bit unclear what you're asking. The plot settings are saved in a separate ".raw" file. This [alas] isn't automatically reopened when you open an ".asc" file, but you can manually open it. Furthermore after you run a simulation and make a plot, the plot doesn't go away if you change some value in the circuit but gets automatically updated when you rerun the simulation. If you alter the circuit in terms of nodes/components however, those plots affected by node/component deletions do go away. \$\endgroup\$ Commented Oct 24, 2015 at 15:41
  • \$\begingroup\$ Actually, the plot data is saved in the ".raw" file (which can also be exported to other formats like csv). The plot settings are saved to a ".plt" file, which you can also save/open. This file is just text, but its format has little in common with SPICE; looks more like yaml. I doubt you can achieve the full functionality of this from SPICE directives. \$\endgroup\$ Commented Oct 24, 2015 at 16:01
  • \$\begingroup\$ Here's a non-trivial example. It has two (split) plot panes and power displayed on one pane (which I suppose you know you can get with Alt+click). The plots look like in this answer. \$\endgroup\$ Commented Oct 24, 2015 at 16:06
  • 1
    \$\begingroup\$ @NathanCompos Did you know you can enter a differential voltage on the schematic by clicking on the first node and then dragging to the second node? Saves entering the formula manually. The comments above explain how to save/open your plot settings. \$\endgroup\$
    – David G
    Commented Jan 8, 2016 at 1:59

2 Answers 2

6
\$\begingroup\$

One method would be to plot the quantity you need, be it a single trace or a mathematical combination of more (maybe also plot whatever other traces you need), then click on the waveform viewer to activate it (if you haven't already) and then click on the Save icon in the toolbar (or in the File menu). This will save the .plt file with the plot settings @Fizz was talking about. This way, whenever you first open up the schematic and run it, or click on the Add trace, the plot window will open up with the saved traces already selected and plotted. The downside is that, once you plot/delete traces, the waveforms will change and, if you need to replot some saved ones, you'll have to manually add them. The minor upside to this is that, if you don't care about the recently added traces, you can close the waveform viewer and click on Add trace, which will, again, open up the previously saved traces and plot them, at the cost of losing the recently plotted ones.

A similar method is to modify the default, global .plt file, but it might not be such a great idea. Still, if you want to, activate the waveform window and then go to the menu in Plot Settings > Edit plot defs file.

Another method is to use behavioural sources, but these, as versatile as they are, come at a cost in that they get slower as the dynamic range gets higher (both frequency-, or time-wise, and value-wise). But, if you have more involved quantities to plot (some bogus example: (V(A)*V(C)+V(B)*V(D))/(I(R1)-I(R2))*sqrt(3)/2), and this doesn't go above hundreds or thousands, in value, or it doesn't have very high frequency components compared to the simulation window, it's safe to use. Then, plotting the formula is as easy as plotting the voltage of the behavioural source.

\$\endgroup\$
2
\$\begingroup\$

Add all of the traces you want manually to the plot window, then click the top bar of the plot window to activate it. Go to "File->Save Plot Settings As" and you can save the current plotting configuration. Next time you open your simulation, run it, then click the top bar of the plot window to activate it. Go to "Plot Settings->Open Plot Settings File", select the file you saved, and your plotting configuration will be restored to the saved configuration.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.