THD measurement - how to?

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
i am writing a set of procedures for amp and speaker evaluation. I have a early version up and running but my THD measurement is higher than expected for a LM3875 based amp. This result made me wonder if my method for calculating THD was correct.

The type of data i am trying to produce is similar to the following:
An externally hosted image should be here but it was not working when we last tested it.


presently, i am scaling the the control wave (the wave output by the sound card before running it through the amp), a frequency sweep, to the amplified waveform and then subtracting the two. I then express the amplitude of the subtraction wave as a percent of the amplified wave. This measurement would/should include both phase and amplitude distortion.

there is the possibility that my amp is distorting as much as measured but since i just intuited my way to the measurement method i thought i would make sure i am doing it correctly first.

summary: what is the method for obtaining THD measurement from a frequency sweep?
 
Getting a THD measurement from a frequency sweep will only work if you have some sort of tracking filter to separate the harmonics from the fundamental, and then calculate from all their relative levels. Incidentally, phase distortion has NO CONTRIBUTION to THD, THD is harmonic amplitude only. If your measurement is affected by phase response, then you aren't measuring THD (not that phase distortion is irrelevant, but it isn't involved in THD).

As far as I know, the only practical way to get THD using a frequency sweep and only a soundcard is with software that can operate with a logarithmic swept sinewave and a very clever and sophisticated technique called "Farina's method" that extracts impulse response of the fundamental and separate impulse responses of each harmonic product. I don't know of any freeware way to do it, though.

Your best bet is to just measure at single frequencies individually, use some kind of FFT analysis program to show the fundamental level and the level of each harmonic tone. Then, THD is the ratio of the RMS summation of all the harmonics to the RMS summation of fundamental along with harmonics. If one harmonic is much stronger than all others, then you'll be pretty close if you just take the ratio of the level of that one to the fundamental tone's level.

If you're doing it with a soundcard, also be sure that you are operating near the full scale levels (that is, just below clipping) of both the playback (D/A) and record (A/D) converters. Else, you won't be able to get residual distortion of your test setup down very far -- you need to use all the bits of resolution your soundcard has available.
 
bwaslo, your reply is very helpful - thank you. i am a biologist trying to find my way in an engineering world. i have a few follow up thoughts.

1. it looks like i will have to obtain my distortion vs frequency plot from discrete points (something i already have partially implemented). I will also look into the Farina method as i am writing the code myself (in igor pro from wavemetrics) and have already implemented a log swept sin wave.

2. would an alternative method to calculate THD from a frequency sweep be to remove the phase distortion before subtracting the waves as i already do?. For example, i could select a filter that matches the phase roll off i measure, and then use those filter parameters to remove the phase shift from the amps output. or is this just crazy talk.

3. i do think my measurement has some appeal as it is a way of showing the effect of phase and amplitude distortion in one trace. Am i reinventing the wheel here or just doing something useless?

4. i am using a sound card, and i do try to maximize the use of the 16 bits i have available by operating near full scale. when i am careful i can get near -85 dB (about 95 db is the theoretical limit for 16 bit?). i hope to get a 24 bit sound card soon so i can improve my measurement range.


thanks again.
 
Re: shareware Farina

okapi said:
http://www.fesb.hr/~mateljan/arta/news.htm

it's not freeware but seems like a good deal.

That is to say, you can use the program for free without limits. The only limitation is you can’t save data files. But you can transfer screenshots to the clip board from within the program.

The bundle also includes “STEPS” which is a separate program, that measures distortion with a stepped sine sweep.

;)
 
bwaslo said:
...............................

If you're doing it with a soundcard, also be sure that you are operating near the full scale levels (that is, just below clipping) of both the playback (D/A) and record (A/D) converters. Else, you won't be able to get residual distortion of your test setup down very far -- you need to use all the bits of resolution your soundcard has available.

No all soundcards measures best just below full scale. My M-Audio Audiophile 2496 measures best at –10 dB full scale.
 
i will check THD as a function of gain for my test hardware experimentally.

can anyone recommend a good, $350 or less soundcard for this type of work? preferably one that can do square waves. i have seen this page which has instructions on how to mod the M-audio delta for decent square wave reproduction.

when reading the arta manual i was happy to see that the sound card protection circuit i came up with, with some help, was the same one implemented by arta. I also loop back one channel, as they do, to create my reference wave.
 
Yes, this is a key point. I always keep everything below -6dBFS for the aforementioned reasons and more. The reconstruction filters can clip even when the absolute value of the samples is less than full scale. This is because they are trying to recreate a sine wave between the discrete points and so the waveform can peak above the max sample before it starts back in the other direction. I see THD rising in all my DAC outputs above -10dBFS

I also use the ESS method described by Angelo Farina, a very elegant technique that can tolerate distortion unlike MLS. But for THD I fall back on taking FFTs at discrete frequencies. It allows you to get the pure THD as opposed to THD+N which can be deceptive.

Angelo Farina's method is excellent at visually representing the harmonic distortion components but when it comes to analyzing what's happening in a system at 834Hz, it's not too friendly. I have implemented both techniques in MATLAB and using ESS on a relative scale is great: A is obviously better than B but when it comes to absolute values I have as yet failed to correlate ESS to stepped sine FFT. My poor math skills.:(

If you have a good S/W package such as soundeasy, mlssa etc, then you can probably rely on their calibration but I haven't had the opportunity to evalulate these devices so can't comment.

edit: Angelo Farina's ESS method was, if I remember correctly, devised to provide the best impulse response measurement for large rooms and auditoria. Using long ESS sweeps (like 20-30secs because that's how long the decay is) you can get phenomenal signal to noise. I think it has a lot in common with Heysers seminal Time Delay Spectroscopy work.
 
Iain McNeill said:
I have implemented both techniques in MATLAB and using ESS on a relative scale is great: A is obviously better than B but when it comes to absolute values I have as yet failed to correlate ESS to stepped sine FFT. My poor math skills.:(

would you mind posting your matlab code here for the Farina method. I plan to implement the same thing in IgorPro but i can almost guarantee my math skills are inferior to yours.

Here is a screenshot of the acquisition panel i have developed in igor. Analysis is running as well but it is not fully implemented at this time.
 
okapi said:
can anyone recommend a good, $350 or less soundcard for this type of work? preferably one that can do square waves. i have seen this page which has instructions on how to mod the M-audio delta for decent square wave reproduction

Uhm, that link doesn't work ???

Good PCI cards are the already mentioned M-Audio Audiophile 2496 and the Audiophile 192. The 192 has balanced inputs and outputs which can be an advantage when measuring amplifiers to avoid ground loops. Concerning distortion performance they are almost equal.

When it comes to USB the EMU 0202 and the EMU Tracker are a big bang for the buck. The Tracker is a more advanced version of the 0202 and has phantom power to power condenser microphones. The noise level is very low approaching the 24 bit theoretical level when using averaging. But despite they can sample at 192 kHz, they are only practical usable up to approx 50 kHz signal bandwidth.. Above 50 kHz the noise shaping mechanism of the converters starts rising the noise level sharply. This will you give wrong THD or THD+N figures. So practical sample rate is limited to 48 kHz then.
 
okapi said:
i am writing a set of procedures for amp and speaker evaluation. I have a early version up and running but my THD measurement is higher than expected for a LM3875 based amp. This result made me wonder if my method for calculating THD was correct.

Now that the economy is hitting the wall, a lot of high quality analyzers are coming into the market. You'll also see some of the Tektronix units at knock down prices. The Boonton 1120/1121 and HP8903B are programmable via GPIB.

If you are starting out, you'll find that one number is going to give you quite a bit of information -- THD% at 1 or 2 kHz -- and you can do this quite well with an HP334 or HP339.
 
okapi said:
would you mind posting your matlab code here for the Farina method.

sure, I think this is OK as long as the credit to Angelo Farina is recognized.

This was the tricky part, actually making the ESS signal and it's counterpart, the inverse filter. So you'd run the m-file, use wavwrite to create the recording, play it through the DUT and record the output.

Extracting the impulse response is a simple convolution of the DUT recording with the inverse filter.

All the impulse responses (linear + all harmonics) get separated along the timeline of the impulse response. You can pick a particular impulse and do an FFT for freq response.

Automating the collection of the harmonic IR's is a bit tricky too. I can post a snippet of that if anyones interested. As I say, I haven't worked out the calibration on it yet so it's always dBr.

PS, you have to change the extension from .txt to .m
(or not):)
 

Attachments

  • essgen1.txt
    1.1 KB · Views: 118
Pjotr said:


Yes, as do the 0202 and the Tracker. But how does the 1212m perform at 192 kHz sample rate concerning noise at high frequencies? Do you have any loop- through measurements available?


no i dont even have that soundcard, but a lynx aes16 (hehe) , but a buddy of mine modded one with diamond buffers & did a complete redo basically.

I doubt very much that the 0202 or the other one you mentioned has the 5394 ,cause another buddy of mine has 0404 usb that has an inferior chip for sure compared to the 1212m ( and btw that 0404 used to be praised for its "block transfer" based USB drivers, not because the flagship adc chip, what was a rather overused term when the 1212m came out), so it was bested by an old RME converter box , eguipted with an older AKm chip (538x) .

BTW there s also the PCM4222 ev-kit from TI, but that could do better in the jitter department ( 74lvc clock divider and buffering), mod-wise.
 
Automating the collection of the harmonic IR's is a bit tricky too. I can post a snippet of that if anyones interested.


Hello everybody,

I've implemented a code snippet in C++ according to FARINA which collects the harmonic IR's.
Unfortunately the curves scatter. I suppose that I didn't choose the right length and starting point in the time domain of the according signal.

I would be glad about any help.

Greetings

joma
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.