
Home  Forums  Rules  Articles  diyAudio Store  Gallery  Wiki  Blogs  Register  Donations  FAQ  Calendar  Search  Today's Posts  Mark Forums Read  Search 
Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators 

Please consider donating to help us continue to serve you.
Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving 

Thread Tools  Search this Thread 
14th June 2012, 05:10 AM  #1 
Richard Murdey
diyAudio Member

LTSPICE FFT from transient analysis and input sinewave
I'm simulating various circuits with LTSPICE, attaching a 1kHz sine wave to the input and looking at the FFT of the output voltage wave.
I've been using the default simulation command, "tran 10m", and was using magnitude of the distortion peaks to optimize the circuit. The problem, and as far as I can determine this is a general effect for complimentary stages, is that the "tran 10m" (analyse the first 10 ms of simulation data) result is radically different than "tran 100m 90m" or "tran 1000m 990m" (analyzing 10 ms of data after 90ms and 900ms have elapsed, respectively). The distortion for the later data is markedly higher. I suggest they are too high to be realistic. Any thoughts as to what's going on here? (in image, temp.fft is 90ms, temp[1].fft is 0ms, and temp[2].fft is 900ms delay.) 
14th June 2012, 06:27 AM  #2 
diyAudio Member
Join Date: Feb 2003
Location: ..

the very 1st thing in using fft or .fourier Ltspice is to add the directive
.option plotwinsize=0 to your asc  Ltspice default applies data compression to the waveform that gives poor fft results  the .option statement turns off data compression next it is good to give .tran a t_max_step_size that gives enough points in the sim  the sim time / ( 2 x # fft points ) is good to reduce interpolation artifacts, lots coarser time step/fewer points can be used but suspect the results I like the Blackman window (fft dialog box)  reduces the truncation spectral spreading "noise floor"  of course always use a record time that fits an exact # of the fundamental periods Last edited by jcx; 14th June 2012 at 06:50 AM. 
14th June 2012, 08:39 AM  #3 
Richard Murdey
diyAudio Member

t_max_step_size was indeed the problem. With the longer total simulation times, the step interval was being automatically made coarser, which had a serious negative impact on the FFT quality.
Explicitly setting t_max_step_size to a sufficient small value so as to give ~1000 points in the sampling window made all FFT results look like the one obtained over 010 ms, independent of the total simulation time. Thanks jcx, that saved me a bundle of trouble! 
14th June 2012, 12:06 PM  #4 
diyAudio Member
Join Date: Feb 2008

Doing a similar thing in AIMSpice, I usually go with a measurement window after some time has elapsed on the circuit. As you found out, the trick is indeed to keep similar number of samples in the window, regardless of total simulation duration.
IG 
14th June 2012, 02:46 PM  #5 
diyAudio Member
Join Date: Oct 2003
Location: Ottawa, Canada

It is also important that the plot contains a whole number of sine cycles so that it is DC balanced. Otherwise, the FFT will have a high noise floor that seems to slope down as frequency increases.
In order to easily change the frequency while maintaining the proper sample size and other parameters (like fourier frequency) I use a .param statement for the frequency. So my schematic will have these spice directives: Code:
.option plotwinsize=0 .param Freq=5k .tran 0 {20/freq} {1/freq} {.0001/freq} .fourier {Freq} V(INPUT) .fourier {Freq} V(OUTPUT) By simply changing the Freq parameter, everything else changes automatically, so that the simulation runs for 21 cycles, saving and plotting the last 20 cycles, with a timestep giving 200000 points (why not?), and the fourier is computed for the correct frequency also. 
15th June 2012, 12:07 AM  #6 
Richard Murdey
diyAudio Member

@macboy
I believe that applying a window (Hamming, etc) to the data before proceeding with the FFT achieves the same result. 
Thread Tools  Search this Thread 


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
~$400 oscilloscope FFT for spectrum analysis  perfknee  Equipment & Tools  12  29th September 2011 06:34 AM 
I/O Tech Daqbook 200 for FFT analysis  boywonder  Equipment & Tools  3  18th October 2009 01:09 AM 
How to make sense of LTSpice FFT analysis?  ray_moth  Tubes / Valves  11  12th August 2008 07:43 PM 
FFT analysisTruth or Consequence  audiobot  Tubes / Valves  30  15th June 2005 02:52 PM 
FFT Analysis  RobPhill33  Everything Else  22  19th March 2003 07:01 PM 
New To Site?  Need Help? 