2
\$\begingroup\$

Is there a way to store a signal in LT spice and then plot it on the next simulation run?

I find myself either plotting two runs in an external program all too often, or even using a screen capture to compare different signals.

My tek scope does this, I can store a signal and then compare it with another signal from a different capture, is there a way to get LT spice to do this?

\$\endgroup\$
2
  • \$\begingroup\$ Does LTspice have the ability to dump an output transient waveform to file then, by using a "user defined" input waveform-generator (that extracts from the file) simultaneously generate the old waveform and run a new plot together. Micro-cap 11 does FAI. \$\endgroup\$
    – Andy aka
    Jan 30, 2018 at 18:25
  • 1
    \$\begingroup\$ If your signal is <=1V, or can be attenuated without fear of repercussions, then you can use the .wave command: .wave path/to/file.wav 13 2964 v(out) 7 (13 bits resolution, 2964Hz sampling rate, can be anything up until a limit -- don't remember, but it's in the manual --, 7 is the channel). \$\endgroup\$ Jan 31, 2018 at 6:40

2 Answers 2

4
\$\begingroup\$

This should work. Use this type of generator V2: -

enter image description here

PWL means piecewise linear function. In other words it generates a signal based on data in a file but, first you must export the data. This site says: -

To export waveform data to an ACSII text file:

    Click to select the waveform viewer
    Choose Export from the File menu.
    Select the traces you want exported.

And...

To import waveform data into LTspice IV you must attach a text file as a piecewise linear (PWL) function in a voltage or current source.

EDITed so that Ali Chen can remove his upvote. There's a point here about not being too hasty with upvotes especially when I advised "read the link".

\$\endgroup\$
7
  • \$\begingroup\$ I sincerely hope that the exported file has the same format as needed for import... Is it true? \$\endgroup\$ Jan 30, 2018 at 18:42
  • \$\begingroup\$ @AliChen read the link. Same type of thing works in micro cap 11. \$\endgroup\$
    – Andy aka
    Jan 30, 2018 at 18:48
  • \$\begingroup\$ The method works, but it takes some work, you have to edit the txt file, which is easier then pulling both signals into python or matlab and plotting, but still a pain in the neck. (see attached answer) I'm going to submit a feature request for something more workable, I hope the LT spice gods will take it into consideration. \$\endgroup\$
    – Voltage Spike
    Jan 30, 2018 at 19:09
  • \$\begingroup\$ So, "your method" doesn't work then, if it needs a massive editing. Please do some edit to your answer, so I can remove my upvote :-( \$\endgroup\$ Jan 30, 2018 at 19:40
  • \$\begingroup\$ @AliChen edited just for you. \$\endgroup\$
    – Andy aka
    Jan 30, 2018 at 20:12
0
\$\begingroup\$

The method proposed by Andy aka works:

However, this only works to some extent. You need to export the net as a txt file (only one net), remove the first 'header' line and add the character 's' (for seconds) to all of the items in the first column and the character 'v' (for voltage) or 'a' (for current) in the second column.

Edit: it does work, but you have to remove the first header line and only two columns will work without labeling the columns, which is easy.

The other caveat is there is some smoothing that goes on, shown below is the original signal Vres, and a signal Vimport that has been imported an exported with the method described above and a diff of the two signals (in pink) so they are not exactly the same but this method does work.

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ There is a little discrepancy here. You say you need to add "s" and "v", while the LTspice link says you just need a pair of numbers and "LF". Which one? I am sure the LTspice accepts several PWL formats, but the usual struggle is to find which one works. More, the PWL seems to accept some procedural statements, loops, scaling etc. I wonder how one can find the correct syntax for this stuff in this particular case. For reference, ibm.com/support/knowledgecenter/en/SSSA5P_12.7.1/… \$\endgroup\$ Jan 30, 2018 at 20:44
  • \$\begingroup\$ It does work with Just the LF. Mine did not work with just importing the file so I read up on PWL files and it says you have to have the 's' and the 'v' after the column. But just barely tried it and it does work with just removing the header line, which is easy and less intensive than I thought. All you'd have to do is export the file and remove the first line. \$\endgroup\$
    – Voltage Spike
    Jan 30, 2018 at 21:29

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.