Using LTSpice To Measure Total Harmonic Distortion

Audiophiles spend a lot of time and effort worrying about audio specs like Total Harmonic Distortion (THD). Makes sense, because THD affects the quality of audio reproduction. However, THD can also affect interference from radio signals and even losses in power transfer systems. A simplified definition is the THD is the ratio of the sum of the power of all harmonic frequencies to the power of the fundamental frequency.

If a circuit produced a perfect sine wave, there would be no harmonics. There are many ways to measure THD in practice, but [Michael Jackson] has an interesting video showing how he easily visualizes THD using LTSpice. Assuming you already have the system in question in LTSpice (or you could use another simulation tool, if you prefer) it is fairly straightforward.

The key concept is to find what the expected output is. In [Michael’s] case, he had an amplifier with a simulated input, so he made the load impedance very high to find the actual voltage gain. Then he simulated a perfect differential amplifier and a perfect source that matched the expected output of the amplifier.

The rest is probably pretty obvious. You replace the load and look at the output of the differential amplifier. You can do an FFT on it to gain further insight into what’s happening. Of course, as good as Spice is, it isn’t reality. Your results in the real world may vary. But the technique is great for at least looking at (and presumably correcting) potential sources of high THD.

If you are into tube amps, THD is a critical subject. Modeling a tube amplifier is probably a lot easier than building it. Wiring up a plate supply and punching holes in a chassis only to find your THD is higher than you hoped would be a lot of wasted effort.

https://www.youtube.com/watch?v=GKlMVNoQGiY

7 thoughts on “Using LTSpice To Measure Total Harmonic Distortion

  1. LTspice is probably one of the best free circuit simulators with many industry level features and performance. Here is me explaining monte-carlo simulations in LTspice:
    http://sinusoid.in/2015/07/monte-carlo-simulation-in-ltspice/
    My confidence in this simulator grew when I listened to Mike Engelhardt on the Amp hour. He knows in and out of circuit simulation and has invented simulation (simulation) methods to reduce transient ringing and faster simulation.
    Sometimes, I’m surprised LT gave it away!

      1. But LTSpice has not much to do with the old spice system.
        It’s like Mac OS X and BSD.
        Many things were added by LT and seriously I don’t use other spice system since many years now.
        Even commercial one are not better than LTSpice

  2. This is interesting. I’ve been toying with developing a tube amplifier stage that produces predictable significant amounts of even order THD (the ‘good’ kind) to introduce a warmth to digital recordings. Not high fidelity but a certain kind of low fidelity for a particular effect. So far I have to laboriously measure the gross distortion with a HP analog THD meter and pick apart the harmonics with Soundcard Scope. Empirically I find that the results vary greatly from one sample to another of different manufacturers of the same tube type. The nonlinear region of the transfer function that I’m looking for isn’t always where the datasheet says it should be. So no luck so far coming up with a repeatable circuit with fixed component values. It always has to be tweaked. I would expect that the accuracy of THD modeling depends strongly on how closely the actual parts match the model in LT Spice. Tubes have a certain amount of sample to sample variation but FETs and BJTs have far more variation in their operating characteristics (Beta, IDSS, etc). Or maybe this matters less in the typical circuit architecture of solid state designs. I dunno, I’m pretty much a glass and vacuum guy.

  3. YouTube video no longer available [tried on 10 Nov. 2017 UTC+7].

    Alternative (not video – thank goodness):

    http://www.audio-perfection.com/spice-ltspice/distortion-measurements-with-ltspice.html

    Tips:

    Be careful what window function you choose when you are doing SPICE THD FFT simulations. You want best amplitude accuracy. Start with the Blackman function. If you need higher frequency resolution increase the total number of samples taken (a proportional relationship exists – more samples equals more resolution). Always make your total sample interval an integer of the signal of interest period. Finally, turn data compression off and use maximum precision options. In LTspice do that with this SPICE directive card:

    .OPTIONS plotwinsize=0 numdgt=15

    There is more on window functions here:

    https://en.wikipedia.org/wiki/Window_function

    and here:

    http://www.multi-instrument.com/doc/D1003/Evaluation_of_Various_Window_Functions_using_Multi-Instrument_D1003.pdf

Leave a Reply to VikasCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.