the harmonics did disappear. What is the reason

So for instance this signal is not periodic due to some RC time constant:
View attachment 1034081

So its straight FFT sees a discontinuity at the wrap-around, leading to lots of broadband energy:
View attachment 1034082
But with a Hann window the discontinuity is removed allowing the actual useful spectral data to be visible:
View attachment 1034083
Note that the harmonic peaks were mainly masked without a window and the floor is no longer suspiciously smooth.

The actual circuit was an RC filter:

View attachment 1034085

The simulation allowed 2ms for the circuit to reach DC stability, but that's only 2 time-constants and not enough.

The issue is that the discrete Fourier transform is only defined for exactly infinitely repeating waveforms - which never exist in
reality, and often not in simulation either, so we have to apply a windowing function to make it more meaningful (its basically a hack,
but an extremely useful one).

All spectrally useful windows taper the response to zero at either end of the waveform to remove discontinuities - there's an
art to choosing the right window (for instance for measurements only flattop windows give accurate signal peak values, and
when you are interested in the noise floor simpler windows like the Hann window give more information).

Many tools have a paucity of good flattop windows - this paper is an invaluable resource about FFT in general and is by far the
best discussion of windowing functions out there: https://holometer.fnal.gov/GH_FFT.pdf
I ignored the significance of time constant in simulation software. Thank you for pointing out the way for me. I will study hard
 
One thing to note is that before doing a transient analysis LTSpice does a DC analysis to pre-charge all the capacitors to their steady-state value precisely to reduce this problem, but its not a panacea as the signal itself starting can set some charging time constants going. I always look for DC drift in the signals on a transient analysis before worrying about getting a spectrum.

With most audio circuits 1ms is enough for things to be stable as the bandwidths are usually a lot larger than 20kHz at the high end
and ~ 1Hz at the low end, so a 1kHz test signal is usually stable after the first cycle, but things like DC servos may not behave so well.
 
  • Like
Reactions: jacksl520s
Very impressive performance for a nfb free circuit. What is the origin? Has anyone built it?
Only impressive due to "perfect" simulation. Might not have the same view if you did the sim from .25W to rated and did full thermal analysis. Look at the other forms of distortion etc. If I remember, that input was discussed in the SOP books and does not actually work very well. Parts are not perfect.

On a side note, I can't find the papers comparing diodes to red and green LEDs for the constant current sources. I did a big simulation comparing about 20 topologies ( FET-BJY cascode the stiffest) but I lost the details of the temperate and current drifts. I thought there was a rwason for green LEDs over two regular signal diodes.

As far as performance, by adjusting the FFT size, sample rate and minimum step, you can get about any result you want, none of them real. I found a "workable" set of parameters that seem to be consistent 10 times better than I measure, so it gives me a solid baseline to use optimizing. Spice is a tool and we have to understand it, not just believe it.

Mark, which windowing do you find most informative?
 
Mark, which windowing do you find most informative?
Only flattop gives accurate measurements, so that's what all spectrum analyzers use.
For noise floor Hann is probably the simplest. Note noise and spectrum measurements are different and not
commensurate in an FFT - read the link I gave about spectral noise density v. spectral line measurement.

one thing to consider is the sine source that starts at peak amplitude, and creates the initial offset. if you start the sine at 90 degrees the problem is gone.
No need to consider a falsehood. Sine starts at zero. That's why signal sources offer sine and not cosine.
 
Why does your RC filter distort?
Because its time constant is of the same order as the period of the waveform, so when it starts there is a large transient exponential component due to the first 1/2 cycle all being in one direction and charging the cap significantly. Only after many cycles has the cap seen positive and negative half-cycles equally and averages out to zero.

This is simply a boundary condition effect, same issue occurs with transformers if you happen to switch on the mains at zero-crossing.

Or in mathematical terms if f(x) is 0 for x<0 and sin(x) for x>=0, then its integral is
0 for x < 0 and 1-cos(x) for x > 0. (which is a combination of a step function and a gated cosine)
 
sorry, my comments were not correct. this stemmed from a simulation with resonant high Q LC charging circuits, where I wanted the inductor current to start at zero. by manipulating the start phase of the sine source I could get that result.
1647179722094.png


if you put startphase of 0 you get a decaying envelope:

1647179825068.png
 
It often helps a bit to use the sum of a step and a cosine, such that you have zero until t = 0, then a jump, and then a cosine centred around zero. For frequencies well above the cut-off frequency, the voltage across a DC blocking capacitor is essentially the time integral of the input waveform divided by RC, and that then becomes a sine wave centred around zero.
 
Because its time constant is of the same order as the period of the waveform, so when it starts there is a large transient exponential component due to the first 1/2 cycle all being in one direction and charging the cap significantly. Only after many cycles has the cap seen positive and negative half-cycles equally and averages out to zero.

This is simply a boundary condition effect, same issue occurs with transformers if you happen to switch on the mains at zero-crossing.

Or in mathematical terms if f(x) is 0 for x<0 and sin(x) for x>=0, then its integral is
0 for x < 0 and 1-cos(x) for x > 0. (which is a combination of a step function and a gated cosine)
The question was related to this picture:

hann_window_fft.png


It doesn't look like settling to me, settling usually just gives a high and sloped floor, but like actual odd harmonic distortion and like harmonics of 50 kHz. Why does your RC circuit produce those?
 
Given there's a transient, you see the spectrum of the transient summed with the tone, and if the sampling frequency of the FFT samples isn't in step with the simulation sampling rate(s) you get artifacts from that.

As I said if the thing you put into a DFT/FFT isn't perfectly periodic, or isn't sampled precisely in time, you won't get what you might expect. I believe that LTSpice has some interpolation algorithm for the FFT that's not perfectly band-limited, so you expect artifacts from this unless you take care to synchronize perfectly. And such artifacts can intermodulate with the actual signal (they are time-domain like jitter so are not linear).
 
Thank goodness I can use Spectre and Mica at work, that can just calculate the time points you like to have (strobeperiod command), and as many in between as are needed for convergence without outputting those. They also don't have LTSpice's awful data compression.
 
But with a Hann window the discontinuity is removed allowing the actual useful spectral data to be visible:
View attachment 1034083
Note that the harmonic peaks were mainly masked without a window and the floor is no longer suspiciously smooth.
What still makes no sense to me is that you call this "useful spectral data". As you just explained, even with Hann window, the picture only shows artefacts due to inadequate settling, insufficient sampling rates and unusable interpolation algorithms. Why is that "useful spectral data"? I'd call it something the forum rules don't allow.
 
The whole point I was making is that with no window you can't see the spectrum at all... Whether that spectrum data itself is useful is the next step to consider, but if you can't even see it you've little information at all other than "Whoops! There's a discontinuity at wrap-around"....

I was endevouring to answer the question posed in the subject.