Mike said:
Forgive my ignorance...
Is there a way to get an estimation of the THD+N of an audio amp in
LTSpice? Ideally, I'd like to plot THD+N against frequency & possibly
temperature...
next question - what is the simplist way of generating a fairly
complex repetative sequence of pulses on a number of nets? What I'm
trying to do is to open & close a lot of analogue gates in a fairly
complex repative sequence. Again, ideally I'd like to manipulate this
sequence fairly simply, rather than change a load of PULSE
statements as I do at the moment (its rather prone to error).
Another Mike. Welcome, Mike.
The lack of a THD+N meter in SPICE is a problem that I've always wanted
a solution to.
SPICE guys, who are not usually audio engineers, will suggest the FFT as
a way to examine the spectral output, but it's not as informative as
looking at the output of a harmonic analyzer, which not only gives you
the ratio of the sum of the amplitudes of the various generated
harmonics (minus the fundamental, and within the bandwidth specified by
the user) to the total amplitude of the circuit's output, but -- and
this next is very useful to the experienced analog circuit designer user
-- by using an oscilloscope, one can view the actual distortion of the
device under test with the stimulus sine wave subtracted. This
"distortion residue" output is a graphic display of how the device is
distorting the sine wave. One trick that is often used is to sum the
(greatly amplified) distortion residue with the input signal on an
oscilloscopes screen so you can see how the sine wave has been changed
as a result of the various nonlinearities in
the device.
These bits are all modelable in SPICE using subcircuits, but it's
cumbersome -- to me, because I am not very clever with SPICE. To see the
distortion residue minus the fundamental, you need to basically build a
band-reject filter with a very narrow (less than an octave so as not to
attenuate the 2nd harmonic), very deep (like 120dB) notch. If you want
to change the generator frequency to examine the performance of the
circuit at a different frequency, you need to change the notch filter's
center frequency, and that's tedious as hell, esp. since the component
value have to be specified to many digits to get the notch spot-on and
narrow enough.
Another way of getting rid of the stimulus signal so the nonlinearities
can be made viewable is to subtract the input from the output. This does
not require a notch filter, but the gain of the circuit needs to be
established to a high enough degree so that the results are accurate to
within, say, 80dB. Math again -- calculate the gain, then feed that
number into the summer to get the residual output. This might not be
useful in circuits that change their gain intentionally -- like
limiters, expanders or compressors, or unintentionally, due to bias
point shifts that can occur when a circuit element is driven into
nonlinearity. But maybe the gain calculations could be made in real-time.
Making a "virtual" THD meter in SPICE that is parameter-driven seems
very do-able for some of the wizards that hang out in CAD-land.
Generally speaking, one need to take the output of the circuit and notch
out or subtract the fundamental sine wave. A way to specify the upper
cutoff frequency (usually 20kHz, but should be user-adjustable). A
little waveform math to compare the amplitude of this distortion reside
as a percentage of the device's total output would then provide the
usual THD number. One could easily sum the distortion residue with the
input sine wave to get a sense of what's happening to cause high THD
numbers.
Of course, SPICE models generally provide a simplified version of real
components' nonlinearities, so the results of our virtual THD meter
would only be as good as our models, and would need to be verified in
real life. But even so, this tool, which is basic to audio design, would
be very useful during the initial design phase of a complex analog audio
circuit.
The "N" portion of THD+N is not likely to be modelable unless you add
noise sources of the appropriate amplitude and spectrum to all your
component models -- then, of course, the aforementioned virtual THD
meter would simply sum the noise with the distortion reside and give you
that "N" number, just like a real harmonic analyzer.