EMRFD Message Archive 13856
Message Date From Subject 13856 2017-05-11 17:19:46 tfr001@myfairpoin... FFT in LTSPICE Hi all,
Has anyone tried using the FFT function in LTSPICE to do IMD testing of circuits? I have tried some very simple test cases, like a two-tone input into a dummy load, and am getting odd results. In the FFT, the two tones show, but also IMD products starting at 40 dB down. I think this is an artifact of the FFT routine - there should be nothing there but the two tones for this simulation. The two signal generators are ideal, so they can't modulate each other.
13857 2017-05-11 17:38:16 Nick Kennedy Re: FFT in LTSPICE Here are some notes I've taken from LTspice group posts concerning accuracy in frequency domain plots:
This one from Jim Miller on EMRFD, 6-26/2013, regarding how to show distortion in the frequency domain:
Found it via google. Also some good options.
.options numdgt=7 ; will force double precision for good low level
.options plotwinsize=0; will disable compression which is lossy
I combined it with 10nsec samples which take a long time but I get a nice
clean input trace which allows me to really see what the output is doing.
FWIW output 2nd harmonic is down 90db and 3rd is down about 84db which
isn't a bad start.
... any time you are doing an FFT, it is advisable to add the following to your simulation:
This line disables LTspice's waveform compression. You don't want it dropping waveform points that are needed to get the best FFT accuracy.
To underscore the above on plotwinsize, this info comes from LTSpice expert Andy:
“However, there is one key thing about LTspice that you might not know yet, and this might be the key thing. To make the output files smaller, LTspice compresses the waveform data, by discarding points when waveforms are not changing much. This can add artifacts to the apparent waveforms when you examine them closely. In the LTspice control panel (hammer icon in the toolbar), the "Compression" tab controls this function. The best way to disable this form of compression is to add the following SPICE Directive to your schematic:
Then it will be remembered every time you run that schematic.
You might want to add that to all your LTspice schematics. It never hurts to do that (it just makes the .RAW files bigger), and it often helps. In fact it is sometimes necessary (say, if you are going to do an FFT of a waveform). There is no global setting to always do that, so you need to remember to add it.”
13858 2017-05-11 23:15:44 Andy Re: FFT in LTSPICE In addition to the essential "plotwinsize" thing....Don't forget to make the simulation interval (the number after the .tran) equal to an exact whole number of cycles of all frequencies present. Well, at least of the two tones you tested it with.It might be useful to add a Minimum Timestep which is suitably small.Andy 13869 2017-05-12 11:54:44 victorkoren Re: FFT in LTSPICE Andy,Shouldn't it be Maximum Timestep?Victor 13870 2017-05-12 13:10:57 xb6zmeyanbsxhnbt2... Re: FFT in LTSPICE Thx for the suggestions. I tried a few of them. The biggest improvement was to set maxtimestep to 1 ns. I played around with that some, and it looks like you should set it to about 1/100th of a cycle for whatever freqs you're looking at, or smaller. Otherwise you get those IMD-like artifacts. I assume this is the timestep for the integrator...?
I then tried this new knowledge on an amplifier model, and got some "well behaved" IMD results, so apparently it works. Before this, it was just a confusing mess of artifacts that never changed very much with drive level.
13876 2017-05-12 19:46:21 Andy Re: FFT in LTSPICE Shouldn't it be Maximum Timestep?Of course it should!The brain slipped a few cogs. Thanks for correcting that.Andy 13877 2017-05-16 14:37:21 Nick Tsakonas Re: FFT in LTSPICE Hi,let me add another piece of info on the suject.I have tried in the past IMD simulations and at the beginning the results were not nice and the spectrum was full for artifacts and noise.I found a very good tutorial years ago (see ref 1, page 30) where it is explained that there is an important relation between simulation time, time step and number of samples to use in the FFT. I will not replicate the info here as it is too long, please read the relevant pages.If you follow the steps described there carefully, the results will be more realistic,you can test it against a well known circuit ( eg. a +7dbm diode DBM) in order to get a feeling of how close you can get.See what happens if you use more/less samples than the calculated, or increase/decrease simulation time etc.If you work on certain regions (eg HF circuits) you can have a set of settings for these parameters that you can always use for FFT simulations.73,Nick, SV1DJGrefs 13878 2017-05-16 15:10:12 Nick Tsakonas Re: FFT in LTSPICE I remembered another tutorial that targets IMD/IP3 simulations and I managed to find it online.I think that will help you a lot, it explains all the details for simulating a whole receiver.this is the linkhttp://www.gunthard-kraus.de/LTSwitcherCAD/SwitcherCAD-Tutorial_English/pdf-File/RF_English_01_final.pdf73,Nick SV1DJG 13879 2017-05-16 18:32:45 xb6zmeyanbsxhnbt2... Re: FFT in LTSPICE Thanks Nick. Those are quite comprehensive. The 2nd one especially has a few tricks I never thought of.