Thank you for that. You'll be my age soon. 😉You mean those old farts who barely hear 10kHz, and hear absolutely nothing past 14kHz?
Have you checked your ears at doctors office?
I can't help with this simulator, but it may be hitting some accuracy limitation.This is where I get stuck and fail to understand how it actually calculates the THD.
The FFT size has to be a power of two. The simulator is likely computing a larger FFT and showing the first 100 harmonics. My guess is that PHD is the first 100 harmonics and THD is the half of the FFT size (the upper bins are a mirror image of the lower bins). The real problem is that the amplitude does not go down, possibly due to limited accuracy.
Ed
Something fishy is definitely going on, which is why I'm just looking at the PHD up to 50kHz and calling it a day. The way LTSpice calculates THD seems weird. The 50kHz PHD also happens to be relatively consistent with what I get when I look at the FFT on my scope on the physical built. I need to build some contraption so I can measure with a lower noise floor than scope probes, but on the physical build, I see a -70dB second harmonic and not much more.I can't help with this simulator, but it may be hitting some accuracy limitation.
I'm probably better off just enjoying how the amplifier sounds instead of obsessing over why the THD looks so weird in LTSpice. 🙂
Something is definitely weird. I did a run with 300 harmonics (i.e. up to 300kHz):
The harmonics are <1uV somewhere around 20kH and <100nV at about 170kHz. OK. I was going to stop obsessing over this! 🙂
Code:
Partial Harmonic Distortion: 0.003237%
Total Harmonic Distortion: 0.023793%
The harmonics are <1uV somewhere around 20kH and <100nV at about 170kHz. OK. I was going to stop obsessing over this! 🙂
I'll try to pull this train back on track.But the harmonics continue toward infinite frequency, although their sum obviously converges, or we'd have infinite power. But that begs the question: How many harmonics do you include?
Excellent question.
I don't know of any standard for this, but there seems to be some common ground, and some practises are limited by equipment.
For example, if you have a 192k soundcard and REW, obviously you will only see a few harmonics of a 20kHz signal.
There's nothing more you can measure.
Common practice (even at AP) is to measure the first 10 harmonics, on the assumption that any higher ones will be low enough and not add significantly to the first 10. I know you've seen different in LTspice but to measure THD accurately in LTspice is an art in itself and there are many settings that interact and have to be set just right. There's thread here on that.
With that 192kHz sound card you can see the first 10 harmonics for fundamentals below 8kHz or so, if you're lucky.
Jan
Thanks. I’m pretty sure that’s the exact thread I found when trying to figure out how to configure LTSpice. I think it’s as good as it’s going to get. I’m just going arbitrarily use all harmonics up to 50kHz. So if you see me quote a THD number, that’s what I’m using and you’re of course welcome to tell me I’m wrong. It wouldn’t be an Internet forum otherwise. 😀I'll try to pull this train back on track.
Excellent question.
I don't know of any standard for this, but there seems to be some common ground, and some practises are limited by equipment.
For example, if you have a 192k soundcard and REW, obviously you will only see a few harmonics of a 20kHz signal.
There's nothing more you can measure.
Common practice (even at AP) is to measure the first 10 harmonics, on the assumption that any higher ones will be low enough and not add significantly to the first 10. I know you've seen different in LTspice but to measure THD accurately in LTspice is an art in itself and there are many settings that interact and have to be set just right. There's thread here on that.
With that 192kHz sound card you can see the first 10 harmonics for fundamentals below 8kHz or so, if you're lucky.
Jan
To me THD is two things: A quick check that you haven’t done anything completely wrong and a fun way of challenging myself.I rest easy whenever this question comes up because (to me) THD is practically meaningless. 🙂
For what it's worth, this is what I go by for "good enough" HD (re: speakers only; electronics obviously should be an order of magnitude better):
HD2: -25 to -40 dB
HD3: -40 to -50 dB
HD4: -50 to -60 dB
HD5: -60 to -70 dB
and whatever makes me feel good that day about IMD. The issue with THD is that HD2 typically dominates and therefore you don't get any info, just looking at THD %, about the more audible higher harmonics.
HD2: -25 to -40 dB
HD3: -40 to -50 dB
HD4: -50 to -60 dB
HD5: -60 to -70 dB
and whatever makes me feel good that day about IMD. The issue with THD is that HD2 typically dominates and therefore you don't get any info, just looking at THD %, about the more audible higher harmonics.
10th harmonic for 100Hz is 1k... I would like to know if my bass drivers produce significant energy at say 5k... but I never pondered it. REW does 10...
But on the other hand, I use only high equality drivers, so not a worry... or? 🙂
Topic is a good observation that I hadn't thought about - thanks.
//
But on the other hand, I use only high equality drivers, so not a worry... or? 🙂
Topic is a good observation that I hadn't thought about - thanks.
//
This simulator bug is a curious one. I remember reporting a peculiar one in Tina-Ti.
https://www.diyaudio.com/community/threads/tina-ti-calculations.332976/
https://www.diyaudio.com/community/threads/tina-ti-calculations.332976/
This made me curious. I never really used the dot command "four" before, so I checked into it. The second resultant THD number, at least as used in LTspice, isn't really well documented. It's calculated differently than the first number, but the details aren't obvious.
There's some discussion of that here: LTspice .four results
Personally, I've always used the graphical results, just because they're easy to use. For me. But, I thought I'd check into what .four can do for me. I tried a very simple circuit (it's attached), using the template I've used for harmonic distortion simulation. (That template and some others are posted elsewhere in this forum.)
This is what I got for results.
That all seems rather ordinary.
So, how about a more complicated circuit? This is from a zero feedback amplifier design I've been fooling with.
0% THD! How great is that? Obviously, not right.
So, I narrowed down the MaxStep size in the simulation by a factor of four. This flattened out the computational error floor - what looks like noise. This is what I got:
Note that the distortion components are almost identical to the previous sim. But, look at the numbers:
It seems like the .four test is very sensitive to LTspice operational parameters - certainly the second "Total Harmonic Distortion" number is. In fact, if you calculate what the distortion levels for the harmonics are in dB for the first, larger MaxStep, power amp test you can see that the 6th and 7th harmonics don't match the graphical results, But, they do for the second test which used the smaller MaxStep. So... do what you need to do.
As I said, the simple test circuit is attached. If you don't have the JFETs I used in your library (2SK170gr's), it's easy enough to substitute with ones you do have.
There's some discussion of that here: LTspice .four results
Personally, I've always used the graphical results, just because they're easy to use. For me. But, I thought I'd check into what .four can do for me. I tried a very simple circuit (it's attached), using the template I've used for harmonic distortion simulation. (That template and some others are posted elsewhere in this forum.)
This is what I got for results.
That all seems rather ordinary.
So, how about a more complicated circuit? This is from a zero feedback amplifier design I've been fooling with.
0% THD! How great is that? Obviously, not right.
So, I narrowed down the MaxStep size in the simulation by a factor of four. This flattened out the computational error floor - what looks like noise. This is what I got:
Note that the distortion components are almost identical to the previous sim. But, look at the numbers:
It seems like the .four test is very sensitive to LTspice operational parameters - certainly the second "Total Harmonic Distortion" number is. In fact, if you calculate what the distortion levels for the harmonics are in dB for the first, larger MaxStep, power amp test you can see that the 6th and 7th harmonics don't match the graphical results, But, they do for the second test which used the smaller MaxStep. So... do what you need to do.
As I said, the simple test circuit is attached. If you don't have the JFETs I used in your library (2SK170gr's), it's easy enough to substitute with ones you do have.
Attachments
Last edited:
@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! 😀
Either way, I’m just going to measure the harmonics up to 50kHz and call that my THD. Because I can! 😀
A simulation does not have to be limited by A/D converters.
The spectrum that njswede posted shows unusually high amplitudes in its upper harmonics. This implies abruptness in the transfer function, which is a problem. A normal class AB amplifier should show negligible difference in total harmonic distortion between the first 15 harmonics, and an infinite number of harmonics.
In contrast, class D amplifiers are always measured through a low-pass filter. I consider that cheating because the low-pass filter masks the amplifier's faults.
Ed
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?
Or your hearing?
Remember the classic problem in Classical Mechanics: A row boat is on a lake, no wind, no water currents.. if we stop rowing, when will it stop? The calculations show it will never stop, but it will travel a finite distance... hence the Mathematician says it will never stop while the Physicist says it will.
By the time the mathematician gets tired of measuring the speed of the boat and comes inside, the Physicists have drunk all the beer and eaten all the pizza.
Can't you put an upper filter on your simulation?
- Home
- Design & Build
- Software Tools
- How do you REALLY measure THD?