# Electronic – What’s the junk at the end of the FFT in LTSPICE

fftltspice

Why do FFTs have junk on the high frequency end? Suppose I go to simulate this circuit in LTSPICE:

simulate this circuit – Schematic created using CircuitLab

Where the LTSPICE sine and simulation parameters are:

SINE(0 1 1K 0 0 0 1000)
.tran 1 startup


Then I ask LTSPICE to give me an FFT with no window and 1,000,000 points:

What's all the junk at the end for? I would expect only one spike at 1KHz, not an additional one at 3KHz, etc. Does this happen to all FFTs? What controls the spikes that you get after your fundamental?

@D.Brown's answer is already a very good one, so I'll only add a few minor things. LTspice's algorithm is custom and accepts a non-power-of-two number of points. This doesn't mean that the resolution is not important. Still, 1kHz over 1s means an integer number of periods, so there is no need for windowing or binomial smoothing to reduce noise (settings in the FFT window). What is, though, is what @mkeith mentioned, and that is, by default, LTspice uses a waveform compression (300 points per display, IIRC), which means that any other points get reduced and the waveform's resolution suffers. The solution for this is either a tighter timestep, or .option plotwinsize=0, the last one eliminating waveform compression. Here's what happens when this option is added, but no timestep is imposed:

This is probably what you see, more or less, so what's the option for? You are simulating a 1kHz waveform over a time period of 1s. The circuit, if it can be called that, is a simple source and load, and the source is s harmonic one, a measily task for the matrix solver, so LTspice, like all SPICE engines, if it feels the derivative is smooth, it will double its timestep to not slow down the simulation, and it will keep on doubling it until some internal limit it hit, at which point it will fly over the simulation. The result is a coarse waveform, which not even plotwinsize can improve too much.

The other cure, the imposed timestep, is now needed in order to improve the resolution. Here's the result with a 1\$\mu\$s timestep:

It's better, but you are performing a 1 million points FFT, which requires, perhaps not surprisingly, 1 million time points, so the maximum timestep should be set to 1\$\mu\$s. In addition, the option numdgt is set to a value >7 which, by the book, enables double precision:

There is still a slightly wobbly noise floor, but the level is now less than -250dB. This is close to machine precision. Making the timestep 1/1048576 (2^-20) doesn't improve the results (you can check for yourself).

In the end, it depends on just how much noise floor are you willing to accept. @Tony Stewart's comment is of a practical sensibility, below 100~120dB means less than 1~10\$\mu\$V to 1V, which is quite an achievement.