==================================================================== Newsgroups: sci.electronics.cad Subject: Re: Use of FFT in LTspice From: "Helmut Sennewald" Date: Mon, 18 Nov 2002 18:34:38 +0100 -------- When you do Fourier Transform (DFT or FFT), you only take a snapshot from a signal. The Fourier transform then delivers the Fourier coefficients of a signal which is equivalent to an infinity number of concatenated snapshots. What do we learn from that? If your snapshot does not contain exactly full periods of all your frequencies (signal), there will be a big discontinuity in the assumed concatenated signal from one snapshot (window) to the next. As a result, your FFT gives you very broad peaks. That's where the FFT windows come into play. They force the signal and their derivatives to zero at the ends of your snapshot (window). This helps, but is by far not as good as a well chosen time frame which contains only full periods of your signal. FFT versus DFT -------------- The result from the FFT is the same as from the DFT. The only difference is the faster calculation with the FFT. This is especially true when the number of data points is a power of 2. Then a lot of similar calculations can be avoided by the clever FFT algorithm. Resolution and maximum frequency -------------------------------- The frequency resolution of the DFT is 1/time. Example: A transient analysis time of 100ms will give 10Hz resolution. The maximum frequency you get is fmax = 0.5*FFT_data_points/time. Example: A transient analysis time of 100ms, with 16384 data points -> fmax about 800kHz. Best Result of FFT with LTspice -------------------------------------- 1. Select .TRAN for exactly a full number of periods of your lowest frequency in the signal. 2. All compression modes off in the menu Tools -> Control Panel -> Compression [Also LTspice command '.options plotwinsize=0' on schematic] 3. FFT Settings Number of data point samples in time: 16384 points or more, depending on up to what frequency you want to look. Windowing function: none You will reach sidebands below than -120dB and often they are below -150dB which is more than adequate for your ears. :-) ==================================================================== Newsgroups: sci.electronics.cad Subject: Re: Use of FFT in LTspice From: "fred bartoli" Date: Mon, 18 Nov 2002 18:59:30 +0100 -------- Just one minor adjustment: The signal must *not* contain full periods but full periods *minus* one sample time (see what happens at boundaries when connecting the samples). Using full periods leads to some still significant leakages that might hide useful details. One way to deal with that is to apply windowing to ensure both extremity of the curve will nicely join but this still leads to some leakages. This also applies only in the case you can post process the waveform, and I don't know whether LTspice can do that or not. The other way is, provided you anticipate the FFT number of points, to set the total simulation time to N*SigPeriod*(1-1/(2*FFTDataPoints)) Example: N*SigPeriod - 1 sample time Also let enough time for the transients to settle i.e. provide a non null start recording time to the .TRAN ==================================================================== Newsgroups: sci.electronics.cad Subject: Re: Use of FFT in LTspice From: "Helmut Sennewald" Date: Mon, 18 Nov 2002 19:39:20 +0100 -------- Thank you very much for this correction. It is really important as you said that the last data point in the taken window is not the one which is the first data point of the next window. This is as more important as less data points we use. Example with a proper window of one period and 8 data points: o o o o o | | o o o | | | | o o o o | | | | | | o o | | | | | | | | ------------------------------------------------------ 0 1 2 3 4 5 6 7 The whole thing is a bit more complicated due to the .TRAN analysis, which is normally set to another timestep then used by the FFT. LTspice then has to interpolate the data points used for the FFT. Hey, a great idea came into my mind. Select the time step for simulation to span/16384 for an FFT with 16384 data points. The time step looked very odd, but the result has been impressive. Now I have achieved -180dB spurious signal level for a pure sine source. Thanks Mike, too, for the high numerical precision. ==================================================================== From: "f5r5e5d" Date: Tue Mar 21, 2006 3:52 pm Subject: Re: FFT? Binomial smoothing is a filter, your FFT response will roll off at high frequencies when this number is large. Make a 1 kHz square wave PWL source: PULSE(-1 1 0 1n 1n 1m 2m) (with a parallel 1 Ohm R to ground so LTspice has a circuit) Always use the LTspice directive: .option plotwinsize=0 Run exact integer 10x length simulation: .tran 0 10m 0 1u From the waveform output window select View>FFT using the FFT with the default settings (length 5 smoothing filter) can be seen to droop below the 1/f expected harmonic curve beyond 100 kHz. Change smoothing filter length to 1 and the harmonic peaks trace a straight line. The windowing function tapers the ends of the waveform when you don't have an exact integer frequency*time simulation, change simulation time above: .tran 0 9.87m 0 1u Now the FFT's "empty" bins between the squarewave's harmonics have a much higher noise floor (-30 dB versus -70 dB) from the non-integer spectral "splatter" and the harmonic amplitude peaks are modulated keeping the non-integer simulation time. Change the 'Windowing function' from "none" to "Blackman" Now the FFT should have good noise floor, the "empty" bins are ~ -70dB, the tradeoff is that the harmonic peaks are now +/- 2 bins wide rather than the single point you get with none - but if you use sample time > ~ 4 cycles of your lowest frequency you can still resolve all components Uses for a manual time range selection are to allow startup transients to die out and get an integral frequency*time relation when the simulation time length and frequency don't match up Now set FFT data points to 131072 and 'Time Range To Include' to a 1ms start, 9ms stop. With the Blackman window you get <-270 dB in the empty even harmonic bins - because of the integer sample ratio and the additional spreading of "noise" over more frequency bins with the higher number of FFT points My transient simulation defaults for FFT analysis are: Have >> 100K points in the simulation (.tran stop time / min time step) More than 4x integer periods of lowest frequency source (usually 10x) Always include LTspice directive: .option plotwinsize=0 Use in FFT: Number of data point samples in time: 131072 Binomial Smoothing - Number of Points: 5 Windowing Function: Blackman