Using math instead of common sense
When I saw the "humping" pattern of harmonic amplitudes (above) on a spectrum analyzer, and then later on the Applicos ATX7006, I knew there was a mathematical basis for it. I knew that if I could figure out what the formula was, I would be famous. But it wasn't going to be easy. On the web and in books by every known author there is a lot of conjecture, but not much that was actually very useful. But then I found a web site called Analogue Heaven. There I found that David Hillel Wilson, curator of the New England Synthesizer Museum had tried to answer a question posed by Richard Lainhart, "Does anyone know the formula for calculating the resulting harmonics of a pulse wave when the pulse width is varied?" David Wilson answered the question as best he could, and he came pretty close. His answer was this:
"Allright, I'm a math junkie, I admit it. I've always been curious about the formula myself, so I dug out Schaum's Outline Series - Mathematical Handbook of Formulas and Tables by Murray R. Spiegel. On page 134, in the section on Fourier Transforms, Equation 23.17 is what you want, sort of. It doesn't give the result in terms of duty cycle, though, so I transformed it for you. In a Pulse Wave, the amplitude of the Nth harmonic is
sin(N * Pi * d)/N
where d is the duty cycle/100% (i.e., d=0.5 for a 50% duty cycle -> square wave)"
Then came his most infamous revelation: "I haven't tried to prove this, but if you substitute d=0.5, a square wave, you get the expected result"
Luckily, the library that I volunteered at had a copy of Schaum's Mathematical Handbook of Formulas and Tables, here is the referenced formula:
I assumed that he transformed it into a useful formula properly, so I tried his formula and the result stunned me! It did work well with a duty cycle of 50%. But then I tried changing the duty cycle away from 50% and the result was OK up to the first notch, then all hell broke loose. You see, sin takes the value negative after a while, and when I converted the predicted harmonic amplitudes into dB, a very bad thing happened. What's the log of a negative number? It's a quantity known in Excel as #NUM, otherwise known to us computer nerds as #NAN meaning Not A Number. To convert an amplitude to dB I have to take the logarithm of the amplitude, and an amplitude is a magnitude value, meaning it doesn't have a sign. But if it (incorrectly) has a negative value, the Log function returns a #NUM or #NAN, not really a useful value. So how do you fix this? Well, it's obvious, use the abs function to get rid of the sign. So now the formula is:
VHarmonic = abs(sin(π*Harmonic#*Duty_Cycle))/Harmonic#
That was simple, no? So now, how well does this formula predict the amplitudes of the various harmonics in a rectangle wave? Let's look at the chart from above again:
In blue is the result taken from the formula from the Schaum's book, in red is the result from my formula and in brown is the actual result from doing an FFT on the waveform in question, which has a 12% duty cycle in this case. You can see the result of the #NAN value in the plot, Excel just plots it to zero, and lucky for me, zero is in my range of amplitudes. You will notice that the red (Dan's) and brown (Actual) values track pretty well, except at some of the "nulls" or as I call them, notches. I think calling them nulls is wrong, because the actual values at these points are not zero (unless you have very low resolution instruments) but in this case close to -60dB. So my formula very closely matches the actual values of the square wave/rectangle wave spectrum of any duty cycle, except it overestimates the depth of some of the notches, but that's OK. In fact, the result is so good that I deemed it good enough to use it as the basis for my formula for calculating the harmonic amplitudes of a triangle wave based on Trise/Ttotal time, and then later, when I had my Eureka moment, it became the basis for the Bullard Harmonic Solution which predicts the harmonic amplitudes of a distorted wave based on the angle where the distortion impacts the stimulation sinusoid. In the book I beat these formulas to death and they seem to match the actual FFT results pretty darn well.
I guess that the lesson I learned in this endeavor is that math is fine, but sometimes these books full of wallpaper don't lead you to the right answer. Don't get me wrong, the Schaum's book got me close, and without it and Analogue Heaven, I might never have gotten the right answer. But you have to apply common sense too. I don't care what the book says, harmonic amplitudes are magnitude values, not signed values, and you have to apply common sense when using math because otherwise you end up propagating untested theories and leading people down the wrong path. Let's remember what drove the Wright brothers to invent the wind tunnel, a device essential to aircraft design. They had read a book that contained formulas predicting lift from various wing configurations. They could not get the expected lift from the wings they built despite these very elaborate formulas, so they built their wind tunnel and did a lot of experiments that proved the book to be wrong! So now we honor them because they used empirical data to design wings that actually worked and threw the book away. Something to keep in mind next time you run into a problem.
To end this on a sad note, David Hillel Wilson passed away from congestive heart failure at the untimely age of 49 shortly after his post on Analogue Heaven. Richard Lainhart passed away not long afterwards. I guess we all know where they are now.
Leadership and Keynote Speaker and member of the Data Science Research Centre at University of Derby
1 年I had an experience like this in the summer of 1969. I was working in a Materials Lab for the summer before joining RR as an undergraduate apprentice. They had a problem with processing the results from an X-Ray Microprobe Analyser. Even at that age, I was quite good at coding, so they gave me the task of seeing if I could come up with a better system than the only other one that was available and calibrated for much heavier metal alloys than they used. It took them about four and a half days to hand process the results of half a day's use of this extremely expensive machine, it cost about £25k in 1969 pounds. It turned out that there were two different theories about how to process the readings from the machine, in the text books. Like you, I looked at them and played around a bit and merged what seemed to be the best bits of each theory and experimented further. Using calibrated metallurgical samples, we were able to show that my "non-expert" approach worked exceptionally well. In fact, for their light steel alloys, it beat the "experts" system at the UKAEA significantly. After I left, I heard later that it had transformed their work, they could run the machine for several days a week, rather than half a day a week.