Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Post-Processor for LTspice

Status
Not open for further replies.

tomizett

Active Member
Hi All,
Recently wrote this little script for Octave/Matlab and thought I'd share it here in case it is of any use. I had a look to see if there was a native way to extract the data I wanted (or if someone had already writen a post-processor) but couldn't find anything. If another (better) way exists of doing this, please fee free to let us know here!

This script is intended for situations where you are simulating a time-variant circuit with a .TRAN and would like to see how varying some paramiter using a .STEP affects a circuit output, which may be varying over time.
For instance, you may have designed an SMPS and wish to plot output voltage vs. load. Obviously you'll need to simulate with .TRAN and .STEP the load. While you can read the average output-node voltage with a .MEASURE, I can't see (but this might just be me) a satisfactory way of plotting this relationship.
This script can deal with two independent .STEPs so you could, for instance, plot line regulation for various different load currents.

To use it, first export the results of the simulations to a text file - with the LTspice plot window selected, select "export" from the file menu. Then, in Octave/Matlab, just run the "ltpost" script followed by the name of the text file.

Be warned, it's pretty rough-and-ready code, and won't be at all robust if the export format from LTspice changes!
 

Attachments

  • ltpost.txt
    7.3 KB · Views: 497
Dues to the usual site restricions on filenames, I've uploaded as a .txt. You'll (probably?) need to re-name this to "ltpost.m" in order for Octave or Matlab to find it correctly.

Incedentally, if you're not familiar with it, Gnu Octave is a free open-source high level mathematical language which if compattible with Matlab. Very handy if you're into that kind of thing.

Here's a simple example of the kind of plot that this scrpt produces.
 

Attachments

  • output.png
    output.png
    27.2 KB · Views: 418
...and bug report #1.

When LTspice exports its data, it uses a Greek "mu" for "micro" in the text file, not a Roman "u" as I'd expected... the script doesn't understand this and therefore ignores it, resulting in answers that are a factor of 1^6 too large.

The work around, of course, is to open the file in a text editor and do a "search and replace", replacing "mu" with "u".
If I can work out how to enter this "mu" character in a way that Octave will recogise (must be a unicode thing, don't think it exists in ASCII), it will be trivial to fix the software.
 
Hi

You mean like this...
This is a Simple switcher output plot of Vout vs Rload
 

Attachments

  • PlotVoutvsRLoad.png
    PlotVoutvsRLoad.png
    42.7 KB · Views: 427
Exactly like that. It that a built-in feature of LTspice? As I say, I expected there should be a way to do that kind of thing, but couldn't work out how to do it.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top