Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Use of FFT in SPICE (LTspice)

2,041 views
Skip to first unread message

Piercarlo Boletti

unread,
Nov 18, 2002, 7:05:21 AM11/18/02
to
Hi!

I need a little help to understand use of FFT in spice, but particularly
focused on SwitcherCad-LTspice.

I use that simulator to esteem intrinsic distortion of a certain number
of basic circuit use in low-frequency or audio application. FFT appear
to be optimal to get a quick glimpse of the overall distortive impact of
the topologies under testing

BUT

There is a litte problem with the - or simply my - use of FFT itself.

More closely: disturbed from costantly too high values of distortion
i've tried a junk meausure of a pure sine generator driving a pure load
resistor. The output expected, a pure fundamental, was not obtained; on
i'ts place was displayed a nastly distorted signal - very distorted
indeed.

What is wrong?

Misbehaving data were obtained from either mode of FFT function in LT
spice - graphical and textual.

Thanks for any aid to understand this matter.

Piercarlo

PS - The problem may be intrinsinc to FFT alghorithm; i don't know
enough to judge. Simply I ask: if that is the case, there is a
workaround to overcome the problem?

Thanks!

Mike Engelhardt

unread,
Nov 18, 2002, 11:44:43 AM11/18/02
to
You might need to make sure the stimulation runs accurately
enough to allow distortion products to be computed from
spectral analysis. You might need to stipulate a maximum
timestep with .options maxstep=<value>. Also, you might
need to turn off waveform compression as the FFT is
computed off the re-expanded data.

--Mike

"Piercarlo Boletti" <piercarl...@tiscalinet.it> wrote in message
news:1flugn4.1vu8bay1lzya00N%piercarl...@tiscalinet.it...

Helmut Sennewald

unread,
Nov 18, 2002, 12:34:38 PM11/18/02
to

"Piercarlo Boletti" <piercarl...@tiscalinet.it> schrieb im Newsbeitrag
news:1flugn4.1vu8bay1lzya00N%piercarl...@tiscalinet.it...

> Hi!
>
> I need a little help to understand use of FFT in spice, but particularly
> focused on SwitcherCad-LTspice.
>
> I use that simulator to esteem intrinsic distortion of a certain number
> of basic circuit use in low-frequency or audio application. FFT appear
> to be optimal to get a quick glimpse of the overall distortive impact of
> the topologies under testing
>
> BUT
>
> There is a litte problem with the - or simply my - use of FFT itself.
>
> More closely: disturbed from costantly too high values of distortion
> i've tried a junk meausure of a pure sine generator driving a pure load
> resistor. The output expected, a pure fundamental, was not obtained; on
> i'ts place was displayed a nastly distorted signal - very distorted
> indeed.
>
> What is wrong?

Hello Pierecarlo,

when you do discrete Fourier Transform(DFT,FFT), you only take a
snapshot from a signal. The discrete Fourier transform then
delivers the fourier coeffients 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
concatenuated signal from one snapshot(window) to the next.
As a result, your FFT gives you very broad peaks.

That's were the FFT-windows come into play. They force the signal
and there derivatives to zero at the ends of your snapshot(window).
This helps but is by far not as good as a well choosen 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 max. frequency
-----------------------------
The frequency resolution of the DFT is 1/time.
If you have a FFT-time of 100ms, you get 10Hz resolution.

The max. frquency you get is fmax = 0.5*FFT_data_points/time .
Example: time=100ms, data points=16384 -> fmax about 800kHz.

Best Result of FFT with SwitcherCADIII
--------------------------------------
1. Select .TRAN for exactly a full number of periods of your
lowest freuency in the signal.
2. All compression modes off in the menue
Tools -> Control Panel -> Compression
3. FFT Settings: Window none
Data points; 16384 points or more, depends on up to what
frequency you want to look.


You will reach sidebands below than -120dB and often they are
below -150dB which is more than adequate for your ears. :-)


Best Regards
Helmut


fred bartoli

unread,
Nov 18, 2002, 12:59:30 PM11/18/02
to

Helmut Sennewald <HelmutS...@t-online.de> a écrit dans le message :
arb8bm$gl156$1...@ID-60775.news.dfncis.de...


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
apply only in the case you can post process the waveform, and I don't know
whether SWCad 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)) i.e. 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

regards,
Fred.


Piercarlo Boletti

unread,
Nov 18, 2002, 1:06:52 PM11/18/02
to
Mike Engelhardt <pm...@concentric.net> wrote:

> You might need to make sure the stimulation runs accurately
> enough to allow distortion products to be computed from
> spectral analysis. You might need to stipulate a maximum
> timestep with .options maxstep=<value>. Also, you might
> need to turn off waveform compression as the FFT is
> computed off the re-expanded data.
>
> --Mike

GREAT! Distortion has sinked down at a floor level of -160 dB...
(timestep 1 us, foundamental at 1 kHz)
I think that's enough! ;-).

Thanks!
Piercarlo

Piercarlo Boletti

unread,
Nov 18, 2002, 1:18:42 PM11/18/02
to
Thanks to Helmut and Fred: Your hint it's very precious; it get me a bit
more illumination about what is FFT in practice e also help me to speed
up some simulation (pure sine generators working on pure resistive loads
are not at top of my interesting matters! :-))).

Best regard to all
Piercarlo

Helmut Sennewald

unread,
Nov 18, 2002, 1:39:20 PM11/18/02
to

"fred bartoli" <to...@hotmail.toto> schrieb im Newsbeitrag
news:3dd929e8$0$18267$626a...@news.free.fr...

Hello Fred,
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 the next window.
This is as more important as less data points we use.


Example with a 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.
SwitcherCADIII then has to nterpolate 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 a intended
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.

> 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
> apply only in the case you can post process the waveform, and I don't know
> whether SWCad 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)) i.e. 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
>

I agree, this is the next pitfall, because we always have bandwidth
limiting elements (C, L) which lead to startup transients in the
.TRAN simulation.


Best Regards
Helmut

SwitcherCADIII is a free SPICE program from Linear Technology.
www.linear.com/software


steve

unread,
Nov 18, 2002, 10:14:54 PM11/18/02
to
On Mon, 18 Nov 2002 19:39:20 +0100, "Helmut Sennewald"
<HelmutS...@t-online.de> wrote:

>Hey, a great idea came into my mind.
>Select the time step for simulation to span/16384 for a intended
>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.

Hmmm. I hate to mention this, but you'll be very, very lucky to get
your numerical noise floor more than 90dB down on a nonlinear circuit
doing anything interesting. If, for instance, you let the simulator
choose the timesteps, you'll probably find interpolation injects more
error than this.

--Steve

0 new messages