LTSPICE FFT from transient analysis and input sinewave - diyAudio
Go Back   Home > Forums > Design & Build > Software Tools

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
Reply
 
Thread Tools Search this Thread
Old 14th June 2012, 05:10 AM   #1
rjm is offline rjm  Japan
Richard Murdey
diyAudio Member
 
rjm's Avatar
 
Join Date: May 2004
Location: Kyoto
Blog Entries: 100
Default 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.)
Attached Images
File Type: png temp.png (64.5 KB, 171 views)
Attached Files
File Type: zip temp.zip (751 Bytes, 6 views)
__________________
RJM Audio (phonoclone.com / G+)
  Reply With Quote
Old 14th June 2012, 06:27 AM   #2
jcx is offline jcx  United States
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.
  Reply With Quote
Old 14th June 2012, 08:39 AM   #3
rjm is offline rjm  Japan
Richard Murdey
diyAudio Member
 
rjm's Avatar
 
Join Date: May 2004
Location: Kyoto
Blog Entries: 100
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 0-10 ms, independent of the total simulation time.

Thanks jcx, that saved me a bundle of trouble!
__________________
RJM Audio (phonoclone.com / G+)
  Reply With Quote
Old 14th June 2012, 12:06 PM   #4
IG81 is offline IG81  Canada
diyAudio Member
 
IG81's Avatar
 
Join Date: Feb 2008
Doing a similar thing in AIM-Spice, 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
  Reply With Quote
Old 14th June 2012, 02:46 PM   #5
macboy is offline macboy  Canada
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)
The Input and output nodes of the amp are labelled INPUT and OUTPUT respectively.
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.
  Reply With Quote
Old 15th June 2012, 12:07 AM   #6
rjm is offline rjm  Japan
Richard Murdey
diyAudio Member
 
rjm's Avatar
 
Join Date: May 2004
Location: Kyoto
Blog Entries: 100
@macboy

I believe that applying a window (Hamming, etc) to the data before proceeding with the FFT achieves the same result.
__________________
RJM Audio (phonoclone.com / G+)
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


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 analysis-Truth 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?

All times are GMT. The time now is 06:15 PM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2