@CG Thanks for taking the time to experiment! You came to the same conclusion as I did: The THD number is very finicky and sensitive to settings like window size and time step. It looks looks like they’re doing some kind of extrapolation into infinity that sometimes works and sometimes gives strange results.
Either way, I’m just going to measure the harmonics up to 50kHz and call that my THD. Because I can! 😀
Extrapolation can blow up in your face is your take it too far. If there are too many "calculated" points between two actual data points the alogrithm will not converge properly and you get invalid numbers.
In '80 we were doing gravity measurements and creating gravity maps. I was using a Fourier algorithm in my calculator and suddenly I discovered positive gravity! Ooops.
Harmonic distortion indicates non-linearity, and non-linearity will lead to intermodulation distortion at frequencies that one can hear.But other than possible oscillation of the amplifier caused by some harmonics introducing something in the feedback.... who cares about harmonics above the bandwidth of the amplifier?
Ed
Maybe this has been said before, but just adding up peaks does not account for complex interactions of harmonics such as cancellations. It definitely is not equal to a rms "sum".the THD is almost an order of magnitude off from what I get from just adding up the first several peaks.
True, I think I sort of put in a caveat in there about the oscillation ( should have been more clear ). The higher order harmonics are of sufficient lower amplitude and the IM likely of high enough frequency that the effects will likely not be noticeable...Harmonic distortion indicates non-linearity, and non-linearity will lead to intermodulation distortion at frequencies that one can hear.
Ed
I guess I should have not been so lazy when initially describe it and should have been more specific. But my wife was calling me for dinner. Mea Culpa... I feel like I stopped rowing the boat on the lake, dropped the oars and got stuck up the creek without a paddle...
As far as I know, you get the total THD by squaring each harmonic level, adding the results and taking the square root.
Not 'just summing the peaks'.
"In order to perform a true THD measurement, energy must be measured separately at harmonics of the input signal. Amplitudes at each harmonic frequency are squared, and then summed. The square root of the sum is the value of THD."
Edit: @stv made a similar point.
Jan
Not 'just summing the peaks'.
"In order to perform a true THD measurement, energy must be measured separately at harmonics of the input signal. Amplitudes at each harmonic frequency are squared, and then summed. The square root of the sum is the value of THD."
Edit: @stv made a similar point.
Jan
I beg to differ. The definition of THD is the RMS sum of all harmonics, divided by the RMS anplitude of the fundamental (or the total power of the signal in some cases). And harmonics don’t cancel as far as I know.Maybe this has been said before, but just adding up peaks does not account for complex interactions of harmonics such as cancellations. It definitely is not equal to a rms "sum".
As far as I know, you get the total THD by squaring each harmonic level, adding the results and taking the square root.
Not 'just summing the peaks'.
I used the term “adding the peaks” loosely. You’re correct. You add the square of the peaks and take the square root. I have a nifty little spreadsheet I use for that.
Either way, I’m just going to measure the harmonics up to 50kHz and call that my THD. Because I can! 😀
Of course, the numbers provided by LTspice are inherently not accurate. Harmonics can easily cancel in a simulated circuit but not as well in a real circuit when the devices are not perfectly matched (which they never are). You still have to build the circuit and measure it.
Thanks for the input! What I can't wrap my head around is that the THD is almost an order of magnitude off from what I get from just adding up the first several peaks. As you can see from the FFT, from the 15th harmonic and up, the peaks are at -90dB, which is over 110dB down from the fundamental. They should have VERY little impact on the THD and are probably at or below the noise floor anyway. (This is the exact same amplifier that gave the SPICE log you see above)
This is where I get stuck and fail to understand how it actually calculates the THD. View attachment 1392655
Looking at the plot, a couple things come to mind.
* The actual analysis data collection begins too early. That rising floor as you go lower in frequency is likely due to some components charging up to the steady state value. AC coupling caps, for example.
* The negative going harmonics suggest that the analysis time isn't really right, at least with the FFT bin size you've chosen.
* You may not be using enough data points for your display.
The "noise floor" is partly due to computational "noise" - errors from interpolation and all that.
My point is not that your circuit design is bad - it could be great. Or, that the analysis is faulty. But, if you want to get more "accurate" results, you should look into adjusting the LTspice transient analysis parameters. Or, just use the graphical plot as a kind of relative measurement that lets you see any goofy anomalies and trends in the design. That last approach sure saves a lot of computational time.
To illustrate my point, I modified the earlier simple circuit to include a DC blocking cap.
This is the DC coupled version:
Now, this is with the cap inserted. (The circuit is attached.) The time constant for the high pass filter is 1 ms. The analyzed data begins right at the first cycle of the generator - zero delay time.
Ick. Bad idea.
Now, I added 1 second of delay time. No circuit changes of any kind.
Better, but not really right.
Here's 5 seconds of delay. For this computer and the LTspice settings I used, this took several minutes to simulate.
Again, aside from the delay time used before collecting data points, nothing else changed.
It seems silly to me to be concerned about distortion products more than maybe 110 or 120 dB below the desired signal level. It's really doubtful that anybody can hear those. Even when summed with identical distortion products, they still can't add up to being audible. If they somehow cancel, so what?
Below about 150 dB is really hard to measure consistently and accurately.
Attachments
Well, that took a hot minute to run this on my amplifier with your 5s of settle time. 🙂
So at least the THD and PHD are kind of in agreement now. THD sits just above 0.003% which is in line with what I was expecting and quite respectable (and WAAAAY below what's audible). The FFT is a lot messier than yours, but I assume that's because I'm looking at a realistic amplifier rather than a simple model of one.
So at least the THD and PHD are kind of in agreement now. THD sits just above 0.003% which is in line with what I was expecting and quite respectable (and WAAAAY below what's audible). The FFT is a lot messier than yours, but I assume that's because I'm looking at a realistic amplifier rather than a simple model of one.
...conclusion: My initial hunch that looking at the first 50kHz worth of fundamentals gives me a reasonable number seems correct. I think that showed 0.0033% while the THD was a factor 10 off...
@tonyEE said:
"But other than possible oscillation of the amplifier caused by some harmonics introducing something in the feedback.... "
Harmonics do not and cannot cause oscillations. Amplifiers that oscillate do so perfectly well with no input signal at all.
Jan
"But other than possible oscillation of the amplifier caused by some harmonics introducing something in the feedback.... "
Harmonics do not and cannot cause oscillations. Amplifiers that oscillate do so perfectly well with no input signal at all.
Jan
The FFT is a lot messier than yours, but I assume that's because I'm looking at a realistic amplifier rather than a simple model of one.
I think what you're seeing is the effects of running the amplifier close to clipping or quasi-saturation levels, at least for one or more of the stages. Looks like you're simulating at about 50 watts output into 8 Ohms.
Here is the same simple preamp buffer, DC coupled, run near clipping:
BTW, this may be a simple circuit, but aside from not including real world power supplies and the measures needed to guaranty high frequency stability regardless of the source and load impedances, it's a real and viable preamp circuit. (A lot of people have built and used Pass B1's, for example...) I chose to use it for illustration and testing of some LTspice parameter settings because it simulates fast and is pretty well understood.
Harmonics do not and cannot cause oscillations. Amplifiers that oscillate do so perfectly well with no input signal at all.
Isn't that only mostly true?
Aside from the necessary feedback conditions, oscillation needs to be initiated. That usually is from a start-up transient or from basic noise.
But, there are also situations where a high frequency stimulus, whether generated internally or applied externally, can change the basic dynamic conditions of the circuit just enough to allow oscillation, especially when the circuit is excited by that stimulus. I think most of us have experienced that. It can be really hard to track down.
I guess it's really semantically wrong to say that the harmonics themselves cause the oscillations, but their effect on the circuit behavior can.
You're right. I had things set up for a near full power test. Reducing power to about 6W calmed things down a bit. The THD is pretty much unchanged at 0.0030%, since the high frequency junk is >110dB down from the fundamental. BTW, this amplifier has been built and sounds great. I'm including the SPICE files for giggles. Never mind all the junk to the right of the output. It's just leftovers from various experiments.
There's been some minor component value changes between this and the built version. It's one of my first designs, so I'm sure there's room for improvement. Then again, it does sound pretty nice to me. 🙂
There's been some minor component value changes between this and the built version. It's one of my first designs, so I'm sure there's room for improvement. Then again, it does sound pretty nice to me. 🙂
Attachments
I suspect that C1, C4, and maybe C6 are what cause the upward slope of the floor as you go lower in frequency. You could certainly short out C1 and C4 for a simulation. Maybe tweak the DC offset of V4 or V5 to get zero VDC at the output with no signal to emulate the reasons for having C1 and C4 in the first place. See if the plot shape looks prettier, if that matters.
The other part is important, too, in my view. That is, how it sounds. It's always fun to make a lower distortion or otherwise optimized amplifier or whatever. That's almost a hobby unto itself, unless you are in the business of selling audio gear. But, if the gear you're building is really a means to the end of enjoying listening to music, then how it sounds to you maybe should be the foundation of the whole effort. If you're happy, well, then you're happy! It's a hobby!
The other part is important, too, in my view. That is, how it sounds. It's always fun to make a lower distortion or otherwise optimized amplifier or whatever. That's almost a hobby unto itself, unless you are in the business of selling audio gear. But, if the gear you're building is really a means to the end of enjoying listening to music, then how it sounds to you maybe should be the foundation of the whole effort. If you're happy, well, then you're happy! It's a hobby!
Isn't that only mostly true?
Aside from the necessary feedback conditions, oscillation needs to be initiated. That usually is from a start-up transient or from basic noise.
But, there are also situations where a high frequency stimulus, whether generated internally or applied externally, can change the basic dynamic conditions of the circuit just enough to allow oscillation, especially when the circuit is excited by that stimulus. I think most of us have experienced that. It can be really hard to track down.
I guess it's really semantically wrong to say that the harmonics themselves cause the oscillations, but their effect on the circuit behavior can.
As I pointed out earlier... my semantics were wrong because my wife was calling me and I hit "post" without really re-reading what I had written.
Yep - short out C1 and C4 and you get this:
That was with only 30m of settling time. Pretty fast simulation, too.
That was with only 30m of settling time. Pretty fast simulation, too.
I suspect that C1, C4, and maybe C6 are what cause the upward slope of the floor as you go lower in frequency. You could certainly short out C1 and C4 for a simulation. Maybe tweak the DC offset of V4 or V5 to get zero VDC at the output with no signal to emulate the reasons for having C1 and C4 in the first place. See if the plot shape looks prettier, if that matters.
I’ll have a look when I get home. The huge value for C1 is definitely a mistake.
It’s fun to chase zeros on the THD, but I believe this particular amplifier has passed “good enough” a while ago. Any decrease in THD wouldn’t be audible.
I’m thinking of making my next project something more “exotic” than just a straight Class AB. Maybe something inspired by the FirstWatt creations? I think that’s the direction I have to go to find the next epiphany in audio…
IIUC at one time long, long ago the standard was that you play a test tone and use a notch filter to filter the test tone out. Whatever is left must be noise and or distortion. Thus, you have a number for THD+N.As far as I know, you get the total THD by...
Sure its measurable, but just how objectionable is it? And how about linear distortions such as LF transients smeared out into whoooshes?f Inaudible some may say...
- Home
- Design & Build
- Software Tools
- How do you REALLY measure THD?