Published on August 29, 2019

Copyright © **Dan P. Bullard**

Up till now I've been calling the method of calculating SNR and THD according to the phase of the spectral components the **adaptive method**, but as I prepare to copyright yet another book, I think I'm just going to call it the Bullard Method. It's accurate, robust and far superior to the traditional method, otherwise known as the ASS U ME method where we assume that the first 8 (or 4, or 6 or whatever) harmonics after the fundamental are harmonics, and everything else is noise. When you make assumptions, that's when things go bad, which is why one tester line I was promoting lost all credibility after the applications engineer believed what the THD and SNR function told him, that he had a noise problem. Turned out, he had a **distortion problem**, and the solutions to those two problems are significantly different. Had we not made those assumptions, things would be very different, and while I know I can't go back in time (give me a few more years, you never know) I can try to right a wrong after the fact and make the world a better place.

In the plot above I show a distorted and noisy cosine wave in time domain. While the Bullard Method works best with cosine waves, as the phases of all harmonics are phased at either 0 degrees or 180 degrees, that doesn't mean we are stuck looking only at cosine waves. We can take any wave, even a non-coherent wave and shift and optionally trim it to be a coherent cosine wave so that it fits the input requirements of this algorithm. Now we do the FFT on the wave above and get this:

Now the thing that degreed engineers don't understand is that when a distortion happens at or near the zero crossing, the Odd (blue) and Even (red) harmonics behave very differently from the way they do with peak clipping. With this kind of distortion, the Odd harmonics start off very low, and climb up towards a peak well after we've stopped looking at harmonics for THD. In this case, they peak at the 33rd harmonic. When did we stop looking at harmonics for THD in the traditional method? Yep, the 9th. So the traditional SNR/THD method assumes that everything after the 9th harmonic is noise. That's not good for the designer or the test engineer, who might be facing a distortion problem, but the instrument is too stupid to know which spectral bins are harmonics and which ones are noise. And it's not the instrument that's stupid, it's the guys who coded the algorithm, based on their very expensive and completely worthless college education. You see, until I came along, nobody even looked at this stuff. They just treated it like magic and traded old-wives tales about harmonics. And let me tell you something, my old wife knows far more about harmonics than the morons at MIT or Stanford, and that's because she's had to put up with me showing her my discoveries. Now, let's look at the results from both methods.

The traditional method assumes that the products of distortion are all contained in the first 9 harmonics, so it gets a value of -20.17dB for THD and since everything after that is considered noise, the SNR comes out to be 14.34dB. But clearly, some of those other bins contain harmonics, we saw it clear as day in the spectrum above. Now look at the Harmonic Angles column. That column is not really named right. We look at the angle and then, based on the value, decide whether it's a harmonic or not. If the angle meets the dictates of Daver's Law, derived from the Bullard Laws of Harmonics #5, then it's a harmonic. That is, if it's 0 degrees or 180 degrees, plus or minus 2 degrees (that 2 under the Dan's THD column) then it's a harmonic. Notice that the noise does have an impact on the phases, they dance around a little bit, like the 3rd and 7th harmonic are not considered harmonics because the noise had dragged the phase away from the expected values. That's OK though, if the noise is strong enough in those bins to drag the phase away from, in these two cases, 180 degrees, then the noise is stronger than the harmonic energy, and who are we to argue with it? In fact, why did the noise overpower the harmonics in those bins? Because at those bins, the harmonics are pretty small, the 3rd harmonic is only -46.5dB and the 7th is only -36.7dB relative to the fundamental. Remember, when the distortion happens at or near the zero crossing, the Odd (blue) harmonics are quite small, and so they should probably not be paid attention to unless they can overpower the noise in the measurement. Notice that the same thing happens at bin 32, where the Even (red) harmonics are starting to lose power as they roll off and hit a null at the 40th harmonic. In this area, the Even harmonics lose a lot of battles against the noise, being dragged away from 0 degrees or 180. But so does an Odd (blue) harmonic, the 33rd, which is where the Odd harmonics are peaking in energy. But the noise is just too strong in this bin, so it loses and gets called noise. At least this method uses meritocracy to determine which one is stronger, the harmonic or the noise. That's far better than assuming! "I assume this rocket will lift off this morning without blowing up, so I will stand right next to the launch tower." How many times do you think SpaceX would let you take that attitude?

Now, we can see in the table above that lots of spectral bins were considered harmonics by the Bullard Method, which resulted in a THD of -14.9dB vs the ASS U ME method that read -20.17dB. But how much THD is there really in this wave if you don't add any noise. Oh, you mean, like the -20dB of noise that I added, that my method measured at 18.4dB SNR and their method measured at 14.34dB. Well, let's take a look. Here is the time domain version of the noise free distorted cosine wave:

And here are my numbers along with *their* numbers:

Notice that because the traditional method **assumed** that the first 8 bins were harmonics and everything else is noise, their numbers hardly changed at all! -20.24dB THD for this wave vs -20.65dB THD for the noisy wave. And the noise numbers are the same too, 14.45dB SNR for this noise free wave vs 14.33dB for the noisy wave. It seems that the traditional method can't tell the difference between harmonics and noise, it's just guessing, just assuming, and that is a very, very bad way to do science and engineering. But how does the Bullard Method compare? Let's look again, I want you to see this clearly.

Dan's THD measures just 1.5 dB smaller than before, meaning that 1.5dB of the harmonics were stolen by the SNR function because the noise in the previous waveform overpowered those harmonics. But look at Dan's SNR numbers! Whoa! 98.11dB, and look at the column of data! Nothing, I mean **nothing** is considered noise. Everything is a harmonic because everything obeys Daver's Law, where all harmonics of a distorted cosine wave will have a phase of either 0 degrees or 180 degrees relative to the fundamental. Notice that this law is confirmed simply by this low number, nothing in this spectrum is considered noise. Now, that's not entirely true because I didn't bother looking at the phases of anything with a value lower than -100dB, so some of those may have snuck in as noise, but you can look throughout the entire list of angles, it never comes back as anything other than 0 or 180 in a noise free distorted wave. That's due to the Bullard Laws of Harmonics #5. Daver's Law just makes it a bit easier, if you are willing to shift your sine wave over 90 degrees to make it a cosine wave. And as I mentioned, that's not hard. All you have to do is to perform an FFT, look at the phase of the fundamental, then rotate the wave by the phase offset relative to a cosine, modulo N samples. It's pretty easy, and if you don't know how to do it, watch this video.

Now, what's the real SNR? Let's remove the distortion and let the noise do what it wants to do:

Without any distortion, both methods find "harmonics," but the ones in the Traditional THD column are from the assumption that the first 8 harmonic bins are due to distortion. Dan's THD on the other had also gets almost the same number, -44.5dB vs -47.6dB but for a different reason. By pure chance, some noise does have a 0 or 180 degree phase shift. In this case, the first bin that meets that criteria is the 63rd harmonic with a 1 degree phase shift from the fundamental. This is purely random, there is no harmonic distortion at all, and yet 1 in 36 spectral bins will fit that criteria, since we allow -2, -1, 0, +1 and +2 degrees as well as 178, 179, 180, 181 and 182 degrees, a total of 10 degrees out of a possible 360 degrees. So the chances of calling a noise signal a harmonic are pretty small, and the THD numbers are in fact pretty close. But look at the SNR numbers, 27.78dB vs 27.83dB, almost a perfect match!

So the Bullard method does no worse than the traditional method for distortion free waves, but for waves with distortion, the results are so much better that this method **must be adopted**! Assuming that noise is a harmonic when it can't be proven is bad enough, but the fact that the traditional method *doesn't even try to check the noise's phase* to see if it might actually be a harmonic is absurd! Harmonics caused by distortion are absolutely guaranteed to have a predictable phase shift relative to the fundamental, it's written in stone, and soon to be part of the Library of Congress! Do not doubt the law.