Here's a basic question I haven't been able to find a good answer for: How do you really measure THD?
Yes, I know how THD works. It's the RMS of the harmonics divided by the RMS of the fundamental (or the RMS of the total signal, depending on who you ask).
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? I've seen a bunch of arbitrary numbers: 20kHz, 100kHz, as many as you can. Just looking at the THD number in LTSpice vs. say the PHD of 50 first harmonics on a 1kHz fundamental, you sometimes see variation as large as an order of magnitude or more. And if we assume we're using a quantified time algorithm to determine the THD, the number of included harmonics becomes a function of the sampling frequency, which again is a somewhat arbitrary quantity. If even if it's not time discrete, your equipment is going to have a finite bandwidth, so there's still an arbitrary limit.
So when you're stating various THD numbers, how are you measuring them? Up to a certain number of fundamentals? Up to a certain frequency? Or whatever the highest frequency your equipment can pick up? I personally measure up to 50kHz, since the THD number in LTSpice tends to be all over the place and sometimes is lower than the PHD.
Yes, I know how THD works. It's the RMS of the harmonics divided by the RMS of the fundamental (or the RMS of the total signal, depending on who you ask).
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? I've seen a bunch of arbitrary numbers: 20kHz, 100kHz, as many as you can. Just looking at the THD number in LTSpice vs. say the PHD of 50 first harmonics on a 1kHz fundamental, you sometimes see variation as large as an order of magnitude or more. And if we assume we're using a quantified time algorithm to determine the THD, the number of included harmonics becomes a function of the sampling frequency, which again is a somewhat arbitrary quantity. If even if it's not time discrete, your equipment is going to have a finite bandwidth, so there's still an arbitrary limit.
So when you're stating various THD numbers, how are you measuring them? Up to a certain number of fundamentals? Up to a certain frequency? Or whatever the highest frequency your equipment can pick up? I personally measure up to 50kHz, since the THD number in LTSpice tends to be all over the place and sometimes is lower than the PHD.
Example:
1kHz tone input, 100 harmonics. THD almost 10x higher than PHD, but the remaining harmonics are all >-100dB, so they shouldn't have any meaningful impact. How does it calculate the THD? Is it somehow weighted?
1kHz tone input, 100 harmonics. THD almost 10x higher than PHD, but the remaining harmonics are all >-100dB, so they shouldn't have any meaningful impact. How does it calculate the THD? Is it somehow weighted?
Code:
N-Period=200.00
Fourier components of V(out)
DC component:-0.0104119
Harmonic Frequency Fourier Normalized Phase Normalized
Number [Hz] Component Component [degree] Phase [deg]
1 1.000e+3 1.819e+1 1.000e+0 90.67° 0.00°
2 2.000e+3 3.612e-4 1.986e-5 -65.97° -156.65°
3 3.000e+3 2.587e-4 1.422e-5 145.87° 55.20°
4 4.000e+3 1.649e-4 9.068e-6 -99.84° -190.51°
5 5.000e+3 1.914e-4 1.052e-5 -165.86° -256.53°
6 6.000e+3 1.451e-4 7.975e-6 -82.25° -172.92°
7 7.000e+3 3.879e-5 2.133e-6 -179.56° -270.24°
8 8.000e+3 1.111e-4 6.109e-6 -82.79° -173.47°
9 9.000e+3 1.895e-5 1.042e-6 9.76° -80.92°
10 1.000e+4 9.151e-5 5.031e-6 -80.20° -170.87°
11 1.100e+4 5.290e-5 2.908e-6 10.90° -79.77°
12 1.200e+4 7.379e-5 4.057e-6 -77.81° -168.48°
13 1.300e+4 6.741e-5 3.706e-6 12.18° -78.50°
14 1.400e+4 5.851e-5 3.217e-6 -74.95° -165.62°
15 1.500e+4 7.084e-5 3.895e-6 13.67° -77.01°
16 1.600e+4 4.463e-5 2.454e-6 -71.76° -162.44°
17 1.700e+4 6.708e-5 3.688e-6 15.02° -75.66°
18 1.800e+4 3.284e-5 1.806e-6 -67.71° -158.38°
19 1.900e+4 5.998e-5 3.297e-6 16.40° -74.27°
20 2.000e+4 2.262e-5 1.243e-6 -62.33° -153.01°
21 2.100e+4 5.102e-5 2.805e-6 17.56° -73.12°
22 2.200e+4 1.462e-5 8.039e-7 -53.95° -144.63°
23 2.300e+4 4.208e-5 2.314e-6 18.76° -71.91°
24 2.400e+4 8.530e-6 4.690e-7 -38.43° -129.11°
25 2.500e+4 3.355e-5 1.845e-6 19.62° -71.06°
26 2.600e+4 5.086e-6 2.796e-7 -6.90° -97.58°
27 2.700e+4 2.619e-5 1.440e-6 20.56° -70.11°
28 2.800e+4 4.547e-6 2.500e-7 36.57° -54.10°
29 2.900e+4 1.991e-5 1.095e-6 21.00° -69.68°
30 3.000e+4 5.420e-6 2.980e-7 60.82° -29.85°
31 3.100e+4 1.491e-5 8.199e-7 21.48° -69.19°
32 3.200e+4 6.165e-6 3.390e-7 71.86° -18.82°
33 3.300e+4 1.098e-5 6.039e-7 21.46° -69.22°
34 3.400e+4 6.427e-6 3.533e-7 76.24° -14.44°
35 3.500e+4 8.062e-6 4.432e-7 21.13° -69.55°
36 3.600e+4 6.319e-6 3.474e-7 77.54° -13.13°
37 3.700e+4 5.931e-6 3.260e-7 20.90° -69.77°
38 3.800e+4 5.941e-6 3.266e-7 76.42° -14.26°
39 3.900e+4 4.477e-6 2.461e-7 19.60° -71.08°
40 4.000e+4 5.455e-6 2.999e-7 73.40° -17.28°
41 4.100e+4 3.501e-6 1.925e-7 20.06° -70.62°
42 4.200e+4 4.961e-6 2.728e-7 68.74° -21.93°
43 4.300e+4 2.933e-6 1.612e-7 19.39° -71.28°
44 4.400e+4 4.527e-6 2.489e-7 62.86° -27.81°
45 4.500e+4 2.627e-6 1.444e-7 20.76° -69.92°
46 4.600e+4 4.209e-6 2.314e-7 56.36° -34.32°
47 4.700e+4 2.504e-6 1.377e-7 23.38° -67.30°
48 4.800e+4 3.994e-6 2.196e-7 49.79° -40.89°
49 4.900e+4 2.526e-6 1.389e-7 24.48° -66.19°
50 5.000e+4 3.867e-6 2.126e-7 44.29° -46.39°
51 5.100e+4 2.600e-6 1.430e-7 28.32° -62.35°
52 5.200e+4 3.793e-6 2.085e-7 39.65° -51.02°
53 5.300e+4 2.728e-6 1.500e-7 29.81° -60.86°
54 5.400e+4 3.750e-6 2.062e-7 36.48° -54.19°
55 5.500e+4 2.872e-6 1.579e-7 31.74° -58.94°
56 5.600e+4 3.713e-6 2.042e-7 34.37° -56.31°
57 5.700e+4 3.003e-6 1.651e-7 34.47° -56.21°
58 5.800e+4 3.684e-6 2.026e-7 33.42° -57.25°
59 5.900e+4 3.120e-6 1.715e-7 35.05° -55.62°
60 6.000e+4 3.638e-6 2.000e-7 33.21° -57.47°
61 6.100e+4 3.224e-6 1.772e-7 36.96° -53.71°
62 6.200e+4 3.591e-6 1.974e-7 33.49° -57.18°
63 6.300e+4 3.291e-6 1.809e-7 38.41° -52.27°
64 6.400e+4 3.540e-6 1.946e-7 34.38° -56.30°
65 6.500e+4 3.342e-6 1.838e-7 38.95° -51.73°
66 6.600e+4 3.482e-6 1.914e-7 35.44° -55.24°
67 6.700e+4 3.372e-6 1.854e-7 40.60° -50.08°
68 6.800e+4 3.423e-6 1.882e-7 36.81° -53.87°
69 6.900e+4 3.373e-6 1.855e-7 41.34° -49.34°
70 7.000e+4 3.368e-6 1.852e-7 38.05° -52.62°
71 7.100e+4 3.371e-6 1.853e-7 42.02° -48.65°
72 7.200e+4 3.312e-6 1.821e-7 39.57° -51.11°
73 7.300e+4 3.354e-6 1.844e-7 43.33° -47.34°
74 7.400e+4 3.258e-6 1.791e-7 40.81° -49.87°
75 7.500e+4 3.314e-6 1.822e-7 43.81° -46.86°
76 7.600e+4 3.206e-6 1.763e-7 42.21° -48.47°
77 7.700e+4 3.286e-6 1.807e-7 44.53° -46.14°
78 7.800e+4 3.155e-6 1.735e-7 43.33° -47.35°
79 7.900e+4 3.238e-6 1.780e-7 45.58° -45.10°
80 8.000e+4 3.112e-6 1.711e-7 44.50° -46.17°
81 8.100e+4 3.200e-6 1.760e-7 45.98° -44.70°
82 8.200e+4 3.062e-6 1.683e-7 45.49° -45.18°
83 8.300e+4 3.151e-6 1.732e-7 46.81° -43.87°
84 8.400e+4 3.023e-6 1.662e-7 46.44° -44.24°
85 8.500e+4 3.106e-6 1.708e-7 47.48° -43.20°
86 8.600e+4 2.976e-6 1.636e-7 47.34° -43.34°
87 8.700e+4 3.058e-6 1.681e-7 48.01° -42.66°
88 8.800e+4 2.942e-6 1.617e-7 48.07° -42.60°
89 8.900e+4 3.016e-6 1.658e-7 48.66° -42.01°
90 9.000e+4 2.895e-6 1.592e-7 48.87° -41.80°
91 9.100e+4 2.974e-6 1.635e-7 49.43° -41.24°
92 9.200e+4 2.862e-6 1.573e-7 49.41° -41.27°
93 9.300e+4 2.928e-6 1.610e-7 49.79° -40.89°
94 9.400e+4 2.822e-6 1.551e-7 50.18° -40.50°
95 9.500e+4 2.891e-6 1.590e-7 50.46° -40.21°
96 9.600e+4 2.785e-6 1.531e-7 50.61° -40.06°
97 9.700e+4 2.853e-6 1.568e-7 51.13° -39.54°
98 9.800e+4 2.749e-6 1.511e-7 51.28° -39.40°
99 9.900e+4 2.817e-6 1.549e-7 51.41° -39.26°
100 1.000e+5 2.714e-6 1.492e-7 51.78° -38.89°
Partial Harmonic Distortion: 0.003234%
Total Harmonic Distortion: 0.023773%
You have to pick the one which is close to what the human ear hears. If there were an A-weighted THD calculation that would be even better.
That was my whole point. The THD seems really off, which is why I switched to a Partial Harmonic Distortion up to 50kHz or so. But is that the correct way of measuring it?
Sure. I could just do up to 20kHz, but then all the audiophiles with ultrasonic hearing will get mad. 🙂 My question was really what the best practice is. But I'm not sure there is one.You have to pick the one which is close to what the human ear hears. If there were an A-weighted THD calculation that would be even better.
You mean those old farts who barely hear 10kHz, and hear absolutely nothing past 14kHz?
Have you checked your ears at doctors office?
Have you checked your ears at doctors office?
I'm 56 and yes, through normal aging, biology and physiology, my hearing above, say 13kHz is limited. So what? I don't need to see a doctor for that.
But back to the question: How do you measure THD? What bandwidth? I just want to make sure that whatever measurements and simulations I make are in line with some best practice.
But back to the question: How do you measure THD? What bandwidth? I just want to make sure that whatever measurements and simulations I make are in line with some best practice.
Figure out why the simulator is reporting the wrong THD.That was my whole point. The THD seems really off, which is why I switched to a Partial Harmonic Distortion up to 50kHz or so. But is that the correct way of measuring it?
Ed
I'll just use the PHD up to 50kHz and call it good. It's consistent with what I get from eyeballing the FFT plot.
I suspect that "PHD" is some way to make up for the usually long tail. IMO, ignoring harmonics above 50KHz is cheating.
Ed
Ed
I though he was asking how to measure REALLY thd, in all caps, shoulting! I thought it means real thd in real circuit. Not some simulation. My bad.Figure out why the simulator is reporting the wrong THD.
Ed
If you want to 'really' measure harmonics above 50kHz, wouldn't you need to have sampling frequency double that?I suspect that "PHD" is some way to make up for the usually long tail. IMO, ignoring harmonics above 50KHz is cheating.
Ed
Care to tell me what soundcard do you use to measure harmonics above 50kHz?
I was kind thinking both measuring and simulation.I though he was asking how to measure REALLY thd, in all caps, shoulting! I thought it means real thd in real circuit. Not some simulation. My bad.
But it brings up an interesting point, which was sort of THE (I’m shouting again) point of my question:
Physical measurement of THD is obviously limited by bandwidth, but in SPICE, I’m using time steps as small as 100ns, which gives me several MHz of useful bandwidth. SPICE then shows a THD that’s way off from the PHD up to, say, 50kHz. My thesis is that the PHD is a “better” measurement, since it mirrors what I can measure physically. I’m also curious to know how LTSpice calculates THD, because it doesn’t correspond to anything I see on the FFT plot.
Can't help with SPICE simulation, as i do not use it. Ask lineup, maybe he can help, i see him designing lots of amps by simulating. (Some very good).
When i was working on hamptone, simple jfet preamp, i only seen 2nd and 3rd harmonics. In some cases just pure 2nd. Nothing more! You can see for yourself.
When i worked on step up transforners as part of preamp without feedback, thd and harmonics were very important and wastly different based on core type. I have seen predominatly 2nd and 3rd, and upper up to 10th harmonic. Thats 10kHz from 1kHz fundamental. I am sure there were higher, but burried in noise.
When i worked on tube preamps and compared various tubes, manly 2nd and 3rd were there, as distortion was quite low.
In general i found no need for higher sampling rate than 44kHz, even soundcard allows up to 96kHz.
Enlike EdGr.
Reality is sometimes different than simulation.
When i was working on hamptone, simple jfet preamp, i only seen 2nd and 3rd harmonics. In some cases just pure 2nd. Nothing more! You can see for yourself.
When i worked on step up transforners as part of preamp without feedback, thd and harmonics were very important and wastly different based on core type. I have seen predominatly 2nd and 3rd, and upper up to 10th harmonic. Thats 10kHz from 1kHz fundamental. I am sure there were higher, but burried in noise.
When i worked on tube preamps and compared various tubes, manly 2nd and 3rd were there, as distortion was quite low.
In general i found no need for higher sampling rate than 44kHz, even soundcard allows up to 96kHz.
Enlike EdGr.
Reality is sometimes different than simulation.
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
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
@EdGr 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.
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.
Last edited:
- Home
- Design & Build
- Software Tools
- How do you REALLY measure THD?