ESP Logo
 Elliott Sound Products Project 232 

Distortion Measurement System

© November 2022, Rod Elliott (ESP)
Updated December 2023

HomeMain Index projectsProjects Index

Introduction

Distortion is not just a number.  While the reader could be excused for thinking otherwise, that's largely because it's often portrayed as just that: a simple percentage with no qualification.  This topic is described in detail in the article Distortion - What It Is And How It's Measured.  Although there are several methods described for measuring distortion, it's not a construction article.  There's also a handy spreadsheet you can download, that will calculate THD from up to ten harmonics.  It's in OpenOffice format, and can be downloaded Here.  The file is called 'thd.ods' and can be run with OpenOffice or LibreOffice (it's not an Excel file and won't run using Microsoft Office).

The measurement system described here is designed to allow you to take very detailed measurements, without the crippling expense of an Audio Precision system or equivalent.  To a large extent it relies on free (or paid by donation) PC software, which provides the spectrum analysis using FFT (fast Fourier transform).  There are many pieces of software available, and many readers will already have one (or more) that they rely on for basic analysis.

To be able to measure very low levels of distortion, it may be helpful if the fundamental is removed from the waveform.  This can improve the resolution of the spectrum analysis, because you don't have to accommodate a large voltage before looking at the spectrum.  A difficulty that many people will encounter is getting a very 'clean' sinewave signal to start with.  Fortunately, most software has an in-built signal generator.  With a resolution of at least 16-bits, these are usually better than most audio oscillators.  A disadvantage is that some are only capable of one frequency at a time, so you might be unable to test intermodulation distortion (for example).

This isn't an insurmountable problem though.  One thing you will need is a good audio interface (aka sound card).  Those provided by default in most PCs are usually best described as 'ok', but many will not have the resolution needed for accurate measurements at around -100dBFS (referenced to full-scale for the ADC).  The maximum input level is limited to somewhere between 1V and 1.5V RMS, since they almost always run from a single +5V supply.  If you're using a desktop PC and have a spare PCIe slot, you may want to consider a sound card that can provide up to 192kHz sampling at 24-bits.  One popular example is the Sound Blaster Audigy Fx.

It's worth noting at this point that software may generate 'artifacts'.  Having tested quite a few, I've seen spurious signals in the FFT window that appear regardless of the (very) low distortion source selected.  Using a different program reveals that these signals must be generated in the s/w itself.  This isn't a major hurdle, but it does require you to be aware of the problem so you can then ignore it.  One thing that will definitely cause problems is not matching the sample rate for the sound card with the settings in the software.  Not all packages let you specify a sample rate (and bit depth), but if they do, they must match the settings for the sound card itself.  If any mains hum is picked up (50/ 60Hz) the harmonics can extend to well beyond 500Hz, so very good shielding is essential.

Note that I have no affiliation with ESI, Creative, Behringer, Focusrite, or any other product or software mentioned in this article.  Recommendations are based solely on my tests (I donated to REW).

This isn't the only reference to using a sound card/ audio interface for distortion measurements, but it does take the process a step further than most others.  The hardware unit is really the heart of the system, as it allows you to set precise input and output levels so you can test anything from preamps to power amps.  This makes all the difference, because using simple stepped attenuators and relying on the output level adjustment of the sound card or the software is very limiting.  It's better (and easier) if the software (input and output) is kept at a standard 'reference' level, and all level adjustments performed externally.

That's what this interface is for - you can adjust levels without changing any settings for the sound card.  The selection of the opamps and pots is critical.  Anything with performance below that of an LM4562 or similar will limit overall noise and distortion, and multiturn wirewound pots mean that you have high reliability and the lowest possible noise.  The hardware won't be particularly cheap, but it's still far less than a dedicated distortion meter, and that will have lower resolution.

Please note that the hardware described is mono - 1 channel only.  This isn't just to save parts (although that's accomplished too), but because there is little requirement for stereo in a measurement test set.  Attempting to create a full stereo setup is ... unwise (IMO).  In an ideal situation you'll be able to verify that both channels of a stereo circuit are the same (or so close it doesn't matter), and keeping the system mono makes everything a great deal easier.  Ideally, the second channel of the sound card will be made available on the panel, so it's not 'lost'.

Of course you can use the sound card connected directly to a circuit for stereo tests, but you'll quickly discover that it's a pointless exercise.  If you were to use 'ordinary' dual-gang pots in a stereo version (the 10-turn wirewound pots are single types only), the error from the pot's tracking will exceed any error in the circuitry itself.  Almost all audio tests are performed on a single channel at a time, and no-one makes (or ever made) a stereo distortion analyser.  I've made provision for direct connection to/ from the second channel via front panel BNC connectors.


Project Description

The project described here concentrates on the additional hardware needed to perform reliable audio measurements.  The hardware isn't absolutely essential, but without it you'll constantly be fiddling around with external attenuators so power amps don't kill the sound card/ audio interface, and pots to adjust levels.  When everything has to be cobbled together it's very hard to duplicate measurements reliably, and mistakes are easily made.  You'll also be forever changing software settings to get the input and output levels necessary for a given test.

One sound card I suggest is the Behringer UCA202.  I've run extensive tests on its predecessor, the UCA222, and while it's not the greatest around, it's relatively low cost.  Anything that has similar (or better) performance can be used, but it depends on your budget.  You can even use the inbuilt audio interface/ sound card in a laptop or desktop PC, but performance is variable - some are very good, other not.  The UCA222 is specified to have distortion below 0.05%, but my tests show it to be less than that, with THD being 0.0038% and THD+N at 0.012%.  This still lets you measure lower distortion though, because you can observe any added distortion as an amplitude increase for any of the harmonics.  The spectrum I took of the interface in loop-back mode show the second harmonic at -100dBV (0.002%), 3rd at -108dBV (0.0007%) and 5th at -98dBV (0.0023%).  The reference level was -4.76dBV (577mV RMS).

The opamps used for input and output in the UCA222 are NJM2740s.  These are nothing even slightly special, but they appear to be 'adequate'.  Obviously using something of higher quality would provide a real benefit, but that would require micro-surgery which is hard to recommend.  They also operate from a single +5V supply (via USB), so choices are limited.  The input impedance isn't particularly friendly for measurement applications, at ~27kΩ.  The UCA202 costs around AU$50.00 at the time of writing.  One thing I really don't like is the fixed USB lead, but that can be replaced if you're willing to perform at least some surgery.  The RCA connectors are a let-down, and my suggestion is to wire in BNC connectors, and mount the PCB in an aluminium case.

The UAC222 uses a PCM2902 (TI) digital interface.  It doesn't rank with some of the more expensive ADC/ DAC ICs around, but its performance is respectable enough as shown by the screen captures shown in Fig. 2.  Interestingly, the second UAC222 I tried was better, having lower distortion and fewer harmonics.  The IC draws around 67mA (according to the datasheet), interesting, but not especially useful.

An alternative that I've also tested is the Focusrite Scarlett 2i2.  These are far more expensive (between AU$270 and AU$290 at the time of writing).  They have better performance, with distortion said to be below 0.002% (line-in and line-out).  Inputs and outputs are via 6.35mm (¼") phone plugs, so BNC adapters are suggested.  I'd expect that most people won't want to make major wiring changes to a relatively costly sound card.  The ESI U24-XL also uses phone jacks for inputs and outputs.

There are others that can be used, but I can only comment on those I have myself, and have tested to prove that they work as expected.  Due to the cost of the 2i2, I suspect that most people will opt for the UCA202 or something similar.  Most will work, but the setup under Windows may be different.  This is potentially one of the most irksome parts of the system, as the Windows sound settings aren't particularly well thought out (IMO).  Of the ones I have available, the ESI U24-XL is the pick of the bunch, and that's what I've used in my own unit.  Unfortunately they don't seem to be readily available, especially in Australia.

The next part of the puzzle is to decide what software to use.  There are quite a few options here, with some being 'shareware' and others are free.  I've tried quite a few, and some are excellent.  Others are no better than toys.  The better analysis software can have a steep learning curve, with REW (Room EQ Wizard) being one of the better choices.  It has a maze of options, and will take some time to learn, but it's well worth the effort.  Another one that I rather like is 'Visual Analyser', as it has the ability to display a basic THD measurement as well as the spectrum.  It lacks many advanced features though.

Beware of 'spectral leakage' [ 6 ].  This can change depending on the PC used.  One way that you can be assured of getting spurious frequencies is if the sample rate of the software doesn't match that set for the hardware.  If you set up using the defaults, the sample rate will be 44.1kHz at 16-bits.  The software must be set the same.

RMAA (Rightmark Audio Analyser) is a candidate, but it has some limitations that make it less suitable than the others.  When used for analysis in the way that's needed to look at distortion, it's used very differently from the way that was intended.  See the Reference section for a list of those I've tried out.  It's up to you which one you choose.  Of course you can use more than one if you wish.  My overall recommendation is REW - it has everything needed (plus many more options that have been explored, albeit briefly).

Figure 1
Figure 1 - Distortion Generator

One of the first things you need (IMO) is a distortion generator.  The general idea is shown in Fig. 1, and it allows you to select even or odd-order distortion products.  VR1 is shown as 100k, but that can be increased to provide lower distortion levels.  The effectiveness depends on the output impedance of the chosen sound card.  With a 400Ω source impedance, the lowest distortion the circuit will generate is 0.071% (even-order) and 0.0185% (odd-order), with an input voltage of 500mV RMS.

As the pot resistance is reduced the distortion increases.  The second version has the disadvantage of a relatively high output impedance (up to 25kΩ), but if you don't mind picking up more mains hum it's more flexible.  Schottky diodes (e.g. BAT43/ 46/ 81) let you generate distortion at lower levels than you can get with silicon diodes (1N4004, 1N4148 or similar).  The generator isn't absolutely essential, but it gives you the opportunity to see just how little distortion you can resolve.  With a decent setup you will be able to see as little as 0.01% easily.  There are limitations of course, most of which are related to the sound card itself.  It should be apparent that you can't get Audio Precision performance with some shareware software and a $100 sound card.

Figure 2
Figure 2 - UCA222 With REW - Residual  (2A - Scarlett 2i2 With REW - Residual(2B - ESI U24 XL With REW - Residual)

The screen captures are much larger than normal so that you can see the details.  In Fig. 2 you can see the residual distortion from a UCA222 with a loop-back from input to output.  The THD is 0.0038%, excluding noise.  The amplitude of each harmonic is shown, and the REW software identifies each harmonic.  For the test I ran, I didn't use the pot shown in Fig. 1, but a 150k fixed resistor was in series with a 1N4004 diode.  The simulator tells me that the THD with this arrangement is 0.044%, so there's fairly good agreement between the 'ideal' and 'real world' tests.  For reference, you can also see Fig. 2A - Scarlett 2i2 With REW - Residual.  The difference isn't as great as you may have expected.  The ESI U24 XL is the best of those I tested, but it's an expensive sound card (around AU$200.00) and may be hard to find.

Figure 3
Figure 3 - UCA222 With REW - With Even-Order Distortion Generator

The added harmonics (and increase of harmonic levels) is quite apparent.  This demonstrates that you don't really need to be too concerned about the sound card, because it's so easy to see if your circuit is creating distortion.  In an ideal case you'd see no difference between the distortion measured for the DUT vs. the distortion of the interface alone.  In reality, this is actually very unlikely, even if you use the finest parts available.  Everything causes some change, however minor.

For example, one test I did was to use a 100nF MLCC capacitor in series between the output and input.  Distortion was not only visible, but much higher than you may have imagined.  This is why I never suggest them for signal coupling in any circuit where distortion is important.  Some distortion may also be seen with polyester (aka Mylar) MKT capacitors, but once the distortion is below -100dBV it's probably not worth worrying about.

One thing that is important is a way to change the gain of the input and/or output.  Most of the software available allows this, but there are many factors that can change the system's calibration.  A stepped attenuator was considered.  The logical increments are 10dB steps, and that ensures that the display can be interpreted properly.  10dB steps means a ratio of 3.16 between each switch position.  There are many things that influence the design of an attenuator, with the most important being the maximum expected input level.  A stepped attenuator was contemplated, but was rejected because it becomes too complex when used with the gain stage as well.  A very simple two-switch design is far easier all round (Fig. 5).

If you think you'll be testing power amps at full output, you will need to reduce the level by anything up to 40dB (100V RMS in, 1V RMS out).  While the arrangement shown can handle that, it's safer to limit the voltage to ~50V (+34dBV).  Any time you provide the ability to measure high voltages (anything above +20dBV or 10V RMS) there is a risk that the input stage of the test set will be damaged if you forget to set the attenuator first.  The 20dB attenuator plus the input level pot (VR1) can provide up to 40dB attenuation with good resolution.  Since it's desirable to minimise noise that may obscure low-level harmonics, a low impedance attenuator was chosen.  Most spectrum analyser software can show levels down to -120dBV (1µV ref 0dBV), and anything that adds noise reduces your measurement range.


There are two major elements to the interface unit.  We have to be able to adjust the input voltage to the DUT and the output voltage from it.  To this end, my recommendation is to use 10-turn 10k wirewound pots as shown below.  These have very good accuracy, low noise and the vernier allows you to return to a setting easily.  The vernier is optional, but it makes it much easier to know the pot setting.  This is important for the input, because you have to ensure that the level isn't so high that it can damage the sound card.  Interfaces will all have some protection, but the output of a 100W amplifier (around 30V RMS) will be more than enough to cause serious damage.  In the final unit there is some protection, but it won't withstand direct connection to a high voltage, high current source such as the output from a power amplifier.  Care is required.

Figure 4
Figure 4 - 10k, 10-Turn Pot With Vernier

Note that the photo does not show the supplied mounting hardware.  If two of these are used (one for input and one for output), you have the ability to set the input and output levels independently.  Included is a switch for direct (loop-back) comparisons.  This means that the output from the sound card can remain fixed, so once everything is calibrated, input and output levels are set with the 10-turn pots, and not in the software.  A 10k pot used as an input attenuator will only dissipate 90mW with 30V RMS input.  The wiper is only at 5% rotation (500Ω) for 1V output and 30V input, but that's made easier with the 20dB attenuator.  The input impedance will change, but if you're connecting to a power amplifier or a preamp that won't cause any problems.

The pots and verniers are available from eBay for about AU$15.00 for each (one 10-turn pot and one vernier), so about AU$30.00 for the pair.  You can also get them from the normal suppliers (Element14, RS Components, Mouser, etc.), but expect them to cost up to 10 times more (up to AU$150 for a pot and vernier).  I doubt that many people will choose this option.  I've tested the one pictured, and it works perfectly - it may lack the ultimate precision of the more expensive options, but that's not an issue.  Like most people, I like to save money when I can, and having tested these I consider them more than 'good enough'.

Figure 5
Figure 5 - Input Circuitry

The attenuator and preamp should be considered essential.  The idea is that when the DUT is being tested, the level from and to the sound card should be the same, regardless of gain (or loss) in the external circuit.  This allows the loop-back switch to be operated whenever you like to compare the two signals.  Because no external circuit will be perfect (and nor is the interface), you can see the difference with only a small time lag (as the FFT refreshes).  The loop-back switch lets you make a direct comparison between the DUT and the 'naked' sound card.

It's useful to have the right channel inputs and outputs available too, particularly if you build the sound card into the interface unit.  The connections are shown above.  Optionally, you can include a loop-back switch, or just use a BNC-BNC lead to join them together.  There may be times when this is handy, and it's not sensible to have the extra input and output inaccessible.  If your test leads all use BNC connectors (mine do), you'll have all connections using BNC (except the microphone - mine has an RCA lead).  1:1 oscilloscope probes can then be used as well, which is convenient.  Note that the second channel input and output are not protected in any way, so care is necessary if you're messing around with a power amplifier (for example).

  Input Range  dB  Via  Z In
  100mV - 1V  -20dB   Pot, Preamp  10k
  1V - 10V  0dB  Pot  10k
  10V - 50V  20dB (14dB at 50V)  Attenuator, Pot  11.17k
Table 1 - Ranges, Signal Routing And Input Impedance

The attenuator for high input voltages uses a resistor network to the 10k level pot.  The impedance remains at close enough to 10k for all three settings.  Unfortunately, the switching is more involved than I'd prefer, because the attenuator and opamp stage must be disconnected when they're not used.  The attenuator will reduce the input impedance, and the preamp will increase noise.  The preamp stage has to be completely disconnected when not in use so it's never driven into clipping.  With a gain of 20dB, any input over 300mV would cause it to distort.  Some of that distortion will find its way to the sound card input.

I strongly recommend that the preamp be operated from a linear supply to prevent any pollution from a switchmode supply.  This is less convenient in many ways, but it means that the measurement path is as clean as possible.  A 12V external linear supply can be used to provide ±6V supplies to the opamp.  That helps to ensure that excessive voltages aren't available from the preamp, simplifying the protection circuitry.  Both input and output have protection, but it's far from foolproof.  Ideally, the 100Ω resistors will be (very) low power so they will fail first.  The four diodes are 1N4148.

Figure 6
Figure 6 - Output Circuitry

The output includes another 20dB attenuator, allowing output levels down to about 10mV.  To prevent distortion, the gain for the output opamp stage should not exceed 3.16 (10dB).  This requires silly resistor values though, and 3.19 is close enough, obtained with 1.8k and 820Ω.  These values are low enough to ensure their noise contribution is low, but high enough to not stress the opamp's output stage.  For output voltages between 1V and 10V RMS, the output of the sound card is sent directly to the 10k pot, and the pot also provides the signal to the DUT.

The protection diodes at the output look out of place, but they're there to provide some protection if the output of the interface is accidentally connected to a voltage source.  The protection is not wonderful, but unless you do something really silly it should be sufficient.  All impedances are deliberately low, but providing effective protection that doesn't introduce non-linearity is difficult.

  Output Range  dB  Via  Z Out
  10mV - 100mV  -20dB   Attenuator, Pot  100Ω - 3k
  100mV - 1V  0dB  Pot  100Ω - 2.6k
  1V - 3V  10dB  Pot, Preamp  100Ω
Table 2 - Ranges, Signal Routing And Output Impedance

Because the output signal doesn't pass through the opamp for the 100mV and 1V ranges, the output impedance will vary with the pot setting.  You may choose to re-arrange the attenuator and opamp stage (for input and output) so the opamp is always in circuit.  However, even the best opamp will contribute some extra noise and (possibly) some distortion as well.  The signal path should always be as short as possible, with no 'extras' in circuit to cause problems.  The whole signal path needs to be kept as simple as possible for each range.

Having said that, I ran tests using my low-noise preamp (Low Noise Test Preamplifier) with a gain of ten (20dB), and I was hard-pushed to see any difference between the direct interface output and that from the test preamp.  It uses NE5532 opamps (two in parallel), and was optimised for noise, not distortion.  The difference between two UAC222 interfaces was greater than the difference between direct and via the preamp.

The two circuits shown above form the base unit, and they are all you need for the test interface (other than the power supply).  There are three optional modules you can add (or not), depending on how you expect to use the system as a whole.  The extras provide additional capabilities, but if you don't need them, don't include them.


High Pass Filter (Option)

There is a module you might want to include, namely a high-pass filter to reduce low frequency noise - particularly mains hum.  The filter frequency can be set to anything you like, but around 220Hz is a reasonable compromise.  A third-order filter is suggested, having a rolloff of 18dB/ octave.  The filter is a convenience only, and it's not essential.  The filter can be built on a Project 99 infrasonic filter PCB, using only one stage.  You could use two stages (36dB/ octave), but there's no need.

Figure 7
Figure 7 - 3rd Order High Pass Filter

Using common resistor and capacitor values, the -3dB frequency is 224Hz, and that will provide 32dB attenuation at 50Hz and 17dB rejection at 100Hz (28dB and 13dB at 60Hz and 120Hz respectively).  While one could use a 4th order filter (24dB/ octave) or more, there's no real need to do so (IMO).  The appearance of mains hum and harmonics doesn't affect readings, but it does make the readout 'untidy'.  If hum is inherent in the DUT, that needs to be fixed in the DUT itself.  However if it's better than -80dB there's probably no point trying to improve that.  That's the equivalent of 100µV or 0.01% THD (referred to 1V) and it will be inaudible with most systems (assuming that you're measuring a power amp, not a preamp).

There is a tiny amount of boost at 400Hz (one of my preferred test frequencies), but it's less than 0.1dB so measurements won't be impacted.  The filter is more of a convenience than anything else, and I suggest that you use a cheap opamp, preferably with JFET inputs.  A TL072 will be fine here.  It allows you to see how much difference the filter makes, but probably won't be used for the majority of measurements.  Re-configuration of the P99 board is quite straightforward.


Low Impedance Driver (Option)

If you want to be able to use the interface to measure Thiele-Small speaker parameters, measure speaker response or for any other application where a low output impedance is needed, use the Fig. 8 circuit.  It's completely optional, and I chose this arrangement over a small power amp because it can share the same supply as the rest of the circuit.  The output impedance is close enough to 2.5Ω, and with two NE5532 dual opamps (4 in all) in parallel it can provide at least ±300mA (peak) output.  The power supply shown below will have to be beefed up if this is expected.

The output will be a maximum of about 100mW into an 8Ω load.  This was verified by testing, and with an efficient speaker it's surprisingly loud.  Note Cb1 and Cb2, both 1mF (1,000µF).  They only need to be rated for 10V, but this stage can draw high supply current, and we don't want it disturbing other parts of the circuit.  If it's used for speaker response testing, be aware of the 2.5Ω output impedance.  This will affect the low frequency performance of almost all loudspeaker drivers.

Figure 8
Figure 8 - Optional Low Impedance Output Circuit

Interestingly, the P99 board is also easily re-configured for this application as well (other than the two bypass caps).  There are a few jumpers needed, and a couple of resistors will be in odd positions, but it's easier than using Veroboard and gives a fairly neat final result.  The two dual opamps are already configured as unity gain buffers on the PCB, so it's just a matter of paralleling the inputs and outputs (via the 10Ω resistors).


Microphone Preamp (Option)

I have a microphone that's normally used with the CLIO test set I bought many, many years ago (the CLIO software will only run on an WinXP machine).  The mic is worth keeping (and using), so I included a basic mic preamp as well.  It uses a TL072 opamp, with two stages giving a total gain of 40dB (41.65dB to be exact - each stage has a gain of 11).  I used the first section of another P88 board to build the preamp, and it uses a 10k pot between the stages to allow the level to be adjusted.

If you don't have a microphone then don't include the mic preamp circuit, as it's even more optional than the high-current buffer stage.  If you do have a mic that uses a basic resistive feed (with the mic capsule powered from a 5V supply) and a suitable low-capacitance cable to use it with, then you can include the mic preamp as well.  I've only shown a very basic preamp, but you can always add a Project 66 mic preamp and add the Project 96 phantom supply if that's needed.

Fig 9
Figure 9 - (Even More) Optional Microphone Circuit

There's no real need to be too fussy with the mic preamp, as any noise or distortion it contributes will be far less than the ambient noise or distortion from a loudspeaker.  A TL072 is suggested here, but you can use something 'better' if it makes you happier.  Another candidate is a 4558 dual opamp, also low cost but with quite respectable performance.

If you add the mic preamp, the interface box is starting to get rather busy.  Mine is 360mm wide (the same as the PC I'm using it with) so there's enough room.  I included all of the options because everything has to be tested and verified anyway, and if circuits are going to be built it would be silly not to include them.  With the addition of the mic interface, I can test anything from a single-transistor preamp to a speaker enclosure, without having to put aside anything and hook up something else (other than my oscilloscope of course).

Of course it remains to be seen how much use these extras will get, but the cost is fairly reasonable, even factoring in the extra PCBs, switches, connectors and opamps.  It's entirely possible that this 'new' test setup will be the impetus for a few more projects, or at least I hope so.


Power Supply

The power supply is a simple regulated linear type, and is external to minimise mains hum from the transformer.  The supply voltage is 12V DC, and that's split to form ±6V rails.  The supply rails are derived using a low impedance resistive divider.  The positive and negative supplies feed the opamp(s).  The UCA222 is supplied from the USB port.  I originally planned to power the UCA222 from the linear supply as well, but tests showed that it makes little or no difference.

Note that if you use the Fig. 8 Low-Z driver and intend to output more than a hundred millivolts or so, the supply will need a bigger transformer than the one suggested below.  I wouldn't recommend anything less than 10VA, and it will be necessary to add to C5, C6, C7 and C8 - I used 5 × 1mF (1,000µF) 10V for each supply rail.  10V caps will be fine for these (but not C4), so they don't take up much space.

Fig 10
Figure 10 - Power Supply (Including Outboard Regulator)

The supply itself is unremarkable in most respects.  A transformer (3VA minimum, but preferably about 10VA) reduces the incoming mains (230V/ 120V 50/ 60Hz) to ~12V RMS, which is rectified, smoothed and regulated by U1.  The output is 12V DC, and it can supply about 100mA.  The same supply can be used with other gadgets you might want to build as well, but not together with the interface because the negative supply is not zero volts (it's -6V) because of the voltage splitter.  Note that C1, C2 and C6 are 1mF (1,000µF), rated for at least 16V (preferably 25V).  In case you're wondering about the two 6.8V zener diodes, they are part of the protection circuit.  Without them, a high input current (by accident of course) would force the supply rails higher as the protection diodes conduct.

Asymmetrical current drain may become an issue if the low impedance output circuit is used 'in anger'.  Feel free to use more than the 2 x 1mF caps shown for each supply rail - I used five in parallel for each supply polarity (5,000µF), partly because I know that I will want to push the limits of the circuit at times.  The two 220Ω resistors in parallel are to limit dissipation in each to 164mW so they won't be stressed.

The DC input connector for the interface must be insulated from the chassis.  Because the common DC connectors connectors normally have the barrel joined to the socket's mounting thread, you must either add insulation or use an isolated socket.  They do exist, but may be difficult to find.  The chassis is connected to the 'ground' - the centre-tap of the supply splitter.  I included a power switch, but it can be omitted if you'll disconnect the mains to the AC supply when the unit is not in use.  While you may expect that the inrush current due to the capacitors will be too high for the switch, the 7812 regulator will limit the current surge (hence only 10µF at its output).

Although they are not shown in the other drawings, all opamps must have 100nF multilayer ceramic capacitors (MLCC) between pins 4 and 8 for bypassing.  These are essential to ensure that the opamps remain stable.  If they are omitted (or too far from the IC), you will likely see oscillation.  Bypass caps are essential for high speed opamps.

If you happen to have a 12V regulated supply available (e.g. an early transformer-based plug-pack, before they were replaced by SMPS) you can use that.  This is obviously easier than building your own, but it might not be quite as much fun.  It's often quite satisfying to build simple circuits that present the minimum of challenges, but work well and can be used for any number of projects.  Admittedly, a single 12V supply isn't particularly useful if you need more than a couple of volts of audio, but they are often handy for testing.  For example, use a linear supply in place of the more common switchmode supply to see (or hear) if there's an audible difference.

At least one SMPS I used is almost as good as the linear supply.  It's pretty much guaranteed that some will be fine, and others not.  If you don't feel like building the linear supply you can try a SMPS, and if it doesn't increase the noise level then it will be alright.


PC Setup

Making sure the sound card is properly set up is critical.  There's a lot to be said for allocating one USB port exclusively for the interface.  It can be used for other purposes, but nothing else that provides audio input or output.  It's quite alright to use it for a USB memory stick (for example), but if it's used with a different sound card you will almost certainly have problems.  There are countless forum sites where people have struggled with various sound cards, and the UCA222 is no exception.  Windoze (all versions) often does very strange things, particularly with sound cards.  The only time you can be reasonably confident that everything will be as expected is if there's a dedicated driver supplied with it.  'Default' drivers often get things badly wrong.

The inputs must display as 'Line Inputs' (Control Panel  Sound  Recording).  If Windows gets confused and sets the inputs to Microphone, you'll never get the gain structure right, and there will be greatly increased noise.  If you use the UCA222 or UCA202 interfaces, you can obtain the proper drivers on-line.  The setup process can be a nightmare, and you may experience some very strange behaviour if something goes wrong.  For a time, I could only get the input to REW to work properly while the sound dialogue box was open.  As soon as I clicked 'Ok' to close it, the input fell apart and had lots of noise.  The Net is filled with complaints from users who can't get their interfaces to work properly, and if you have issues you'll (hopefully) find the answer on-line.  People have issues with almost all interfaces and on all major platforms (Win7/10/11, Mac, Linux).

Ultimately, the fix I found was to open the computer's 'Device Manager' (access differs for different versions of Windows).  One of the options is to display 'hidden' devices (hidden because they aren't connected).  Click 'View  Show hidden devices'.  You then need to right-click to select each one (including the UCA222) and choose 'Uninstall'.  You may be asked if you wish to uninstall the drivers as well, and the answer is 'Yes'.  No, I didn't find this solution on-line, I had to figure out myself.  After the system was cleaned of all the crap that had accumulated, installation and operation were relatively painless.

If you have problems on another operating system you'll have to figure it out yourself.  Mostly things will 'just work', but the PC I used is pretty ancient and has been used with a multiplicity of different sound cards and other USB devices during its life.  All operating systems end up with junk that's no longer relevant, so knowing how to clean it up is always useful.

You must verify the configuration of the sound card/ audio interface.  Go to Control Panel  Sound  Playback, and double-click on the device you're using.  Click the 'Advanced' tab to see/ change the settings.  The output (typically shown as 'Speakers/Headphones') should be set up as Stereo - '2-channel, 16 bit, 4800kHz (DVD quality)' as a minimum requirement, and use the same settings for the input - Control Panel  Sound  Recording (again selecting the sound interface you're using).  The 'Advanced' tab gives you access to the sample-rate and bit-depth settings.

Double check all settings to ensure they are correct and make sense.  If you get these settings wrong you'll have the devil of a time trying to get any software to work properly.  If you are using REW, it uses 16-bit and either 44.1kHz or 48kHz sampling.  I suggest 48kHz sampling and 16-bit, as that seems to work well.

One driver class requires some explanation - ASIO ¹.  In this case, we're not taking about the 'Australian Security and Intelligence Organisation', but an audio standard.  ASIO stands for 'Audio Stream Input/Output', and provides greater functionality than generic audio device drivers.  It's important to note that all other audio device support will be blocked from the USB port you select for the ASIO drivers, so make sure that you can allocate the desired port exclusively to the sound card you'll be using.  Memory sticks and other storage media won't change the settings.  In general, I suggest that you dedicate one USB port even if you're not using ASIO drivers.  The benefits of using an ASIO driver are somewhat dubious - you'll need to test it for yourself.

¹   ASIO is a trademark of Steinberg Media Technologies GmbH.

Using the 'Sound' setup process, make sure that the interface you're using is set as the default for input and output.  There aren't many differences between the various versions of Windows, and much the same comments apply from Win7 onwards.  I don't use any 'fruit-based' computing devices (nor do I use Linux for anything 'serious'), so I can't suggest any helpful hints here.

Fig 11
Figure 11 - Sound Card Setup Screens (Example Only)

Fig. 9 is an example, taken from my main PC.  The setup you see will be different, and the figure is simply to show the uninitiated the various options described above.  Hopefully the descriptions will assist you to get the sound card set up properly.  As noted already, I don't have any 'alternative' operating systems to show, so Apple and Linux users are on their own.  For Win10/11, you need to select 'search' to find the 'Control Panel', as it normally doesn't show up in the list of installed applications.

As with anything connected to a PC, things can (and will) go awry, especially as the system is being set up.  It's not possible to cover every eventuality, because the number of things that can go wrong is too great.  Different versions of an operating system can behave differently, and I must insist that if you run into difficulties please do not contact me for assistance.  An on-line search will show the number of questions asked about sound cards, and in most cases you'll also find the answer.  One thing that most experienced users will tell you is to avoid using a USB hub to connect a sound card.  You really do need a dedicated, direct, USB port on the computer.

One thing I found (much to my disappointment I must admit) is that the old laptop I intended to use isn't powerful enough to run the REW software.  I had glitches in the audio output stream that were very audible and caused a poor display on the spectrum analyser, with a high noise level and an unstable display with (what should have been) a continuous tone.  Using any of my bench oscillators was better, but the lack of PC 'grunt' still caused the display to be unstable.  It's usable with an external oscillator, but it's still sub-optimal.

The issue of old laptops (or PCs) being unable to provide a clean output waveform isn't limited to REW - I tested a few other generator/ analyser programs as well, and they all had problems.  The processor load whilst generating the output waveform and performing spectrum analysis appears to be fairly high, and any under-powered PC won't cope with the load.


Construction

There are many options for construction, dependent on your metalworking skills (amongst other things).  I chose to make a much larger than 'normal' enclosure that can sit below the laptop I'm using, and the sound card is internal.  I also added a (very) small power amplifier (Fig. 8) so some of the other things that REW can do can be utilised.  Amongst these is loudspeaker Thiele-Small parameter testing, where a small power amp provides better resolution than using the (comparatively) high output impedance of the sound card.

The case used should be all metal, preferably aluminium as it's easier to work with than steel.  If you must use a plastic enclosure, it should be lined with copper or aluminium foil for shielding.  The attenuators can be wired directly across their bypass switches, and the two preamps can be built on Veroboard or you can adapt (for example) a Project 88 preamp board.  While it not ideal, the PCB layout is flexible enough to use in this role.

Most of the construction is not critical, but inputs and outputs to/ from the sound card must use shielded cable, as should any signal leads more than ~50mm long.  As noted above, I recommend BNC connectors for all inputs and outputs, but use what suits your setup.  Almost everything other than the sound card can be mounted very close to the front panel, thus keeping wiring as short as possible.

Fig 12
Figure 12 - General Panel & Module Connections

The input and output attenuators aren't shown as circuit blocks because they are wired directly across their switches.  There are only two resistors for each, one in series and one to ground.  The schematics show the wiring (such as it is).  The microphone 'Link' switch means you don't need to use a double-ended BNC connector to connect the mic to the sound card.  The same could be done for the main loop (so both input and output circuits are part of the loop, but this is not requires because it's simply a matter of connecting the input and output leads together to get a complete loop-back that includes everything (other than the filter).  The switches shown are in the same positions as indicated in the front panel drawing.  I used the Australian convention of 'down' for 'on', but that the reversed in the US.  Mark the switches as you see fit.

The PCBs I used are shown in the drawing.  Note that all are heavily modified for their new tasks.  The layouts I used will be included in the secure section of the ESP site, so you can duplicate the arrangement I used.  Of course, you can assemble everything on Veroboard if you choose.  The internal power supply uses Veroboard, as I have no project PCBs that can be adapted.  You could use the positive half of a P05-Mini for the regulator if you build that yourself.

It's up to you which parts you include and which bits you feel are superfluous to your needs.  This project started out as a very simple interface, with only the circuits shown in Fig. 5 and Fig. 6, plus a simplified power supply.  As I looked at the things that REW can do, it became apparent that it was easy enough to add extra functionality, particularly as I decided early on that I wanted my unit to sit below the laptop that I'm using it with.  This gave me more room to add stuff that I thought might come in handy.

Fig 13
Figure 13 - Front Panel Of Test Unit

The front panel ended up being more crowded than I expected, but everything works.  The 'Low-Z' output is a bit close to the output level pot, but it won't be used often, and a BNC connector still fits and allows access to the pot.  I could have re-done the front panel, but there's a lot of work involved and I doubt it will cause me too much grief.

Fig 14
Figure 14 - Inside View Of PCBs and Wiring

The insides show the PCBs, adapted for their 'new' functions.  There are two P88 boards, with only the first stage of each populated.  One is the mic preamp (two stages, top right of pic) and the other provides the input and output gain (20dB and 10dB respectively).  The two P99 boards are next, and finally the power supply built on Veroboard.  The ESI U24-XL board can be seen at the rear of the chassis.  The extra length of the USB lead was coiled inside, and the remainder is attached to the case with a pair of cable ties.  The internal wiring is laced rather than using cable ties, as IMO the result is neater.

The electronics (gain stages, attenuators, filter, etc.) cause no noticeable degradation.  As a test I used the input with both 20dB attenuation and 20dB gain, and the spectrum was virtually identical to the signal using a loop-back ('Loop' switch).  The mic preamp has enough gain to get a satisfactory level for speaker measurements.  I've also tested my system with a 12V SMPS (switchmode power supply) and there was minimal degradation.  I still recommend the linear supply though, as the SMPS you buy may not be as good as the one I used.


Conclusions

For anyone who is into 'tweaking' audio circuitry, or for those who simply want to be able to measure distortion, the hardware described here will be invaluable.  You have to decide on the sound card you want to use, which will always be a trade-off between cost and performance.  As noted above, I eventually settled on using an ESI U24-XL, but a UCA222 is better than expected and low cost.  Having the ability to select 192kHz sampling at 24-bits resolution is 'nice', but the difference may not be as great as you may expect.

While it is a limitation, the inability of the circuitry and software described to measure anything above ~20kHz is not as serious as you might think.  Remember that the harmonics of audio at 10kHz and above are inaudible, being at 20kHz or higher.  3rd harmonic distortion is at 30kHz for a 10kHz input.  Any suspected issues at high frequencies can be observed on an oscilloscope, in particular slew-rate limits, where the waveform becomes triangular.  Remember that the levels (with music) at anything over 10kHz are at least 10dB less than that at (say) 3kHz.  Intermodulation distortion using 60Hz and 7kHz tones (4:1 ratio) can be measured using REW, and that is a good indication of high frequency performance.

Compare this project with any commercial design, and you'll see that it can provide measurements that are better than almost all self-contained distortion measurement instruments.  The circuitry is straightforward, and (unlike commercial systems) easily repaired if necessary.  If the sound card you're using fails, you can replace it (most are exclusively SMD and are hard to service).  It's also very flexible, so you can build the sections you need.  If you buy an old HP instrument and something goes wrong, you're in for a world of pain.  An HP 334A (for example) can't do anything much other than measure harmonic distortion plus noise (it can be used as a millivoltmeter as well, but that's all).  Maximum sensitivity is 0.1%, and any reading below 0.02% is unreliable at best.

The use of this measurement system doesn't replace an oscilloscope.  There is always the possibility of oscillation or other high frequency anomalies with circuitry, and they can't be seen with a system that can't measure beyond 20kHz or so.  An oscilloscope also lets you look at things you probably don't want to measure, especially during fault-finding.  My oscilloscope is the first (or sometimes second) piece of test gear that any circuit sees.  The second is a multimeter to verify that voltages are correct, but often only if an anomaly is seen with the scope.

This project came about after I wrote the article Distortion - What It Is And How It's Measured.  My original intention was to develop a simple spot-frequency distortion analyser, but during my research for the article (and resurrecting a PC based oscilloscope that had not been used for a while) I was reminded of the use of a sound card.  It was during my tests and experiments that the limitations of the sound cards became obvious.  Trying to set input and output levels quickly became tedious.  From that, it was obvious that a purpose-designed 'control box' was essential.

I've shown well in excess of 'the basics' here, but you will only include the bits that are important to you.  If the complete setup as described is used, you'll have a very capable measurement system for not a great deal of money.  We can't hope to reach the standards of an Audio Precision [ 8 ] system, but there's no doubt that this system will beat even a very good, low distortion oscillator and a commercial (or home made) distortion analyser using a notch filter.  There are many hurdles to overcome for both the oscillator and meter, and building something that can measure 0.01% THD+N (full scale) is a serious undertaking.  This makes it comparatively easy.

Of course there's a down side as well.  You need a PC in your workshop, set up so it's easily accessed but not in your way as you work (and keeping soldering irons and component lead 'clippings' well distanced is highly recommended).  You have to boot up the PC and run the software, so a 'quick test' isn't really an option.  During development of a project, you don't need to know the exact level of each harmonic, and a conventional distortion meter lets you get a reading quickly, and look at the distortion waveform on a scope.  Once you know what to look for, this is just as valid as any other technique, but it won't provide the detailed analysis that you get with the PC based test set.  As noted above, an 'old' PC/ laptop that's superfluous to other requirements will almost certainly cause grief unless you deem any PC more than a couple of years old to be 'ancient'.  A laptop running Win10 will almost certainly have enough power and speed to work properly.  An otherwise usable laptop that's 20 years old (such as the one I tried to use) will not be a success. cry

You also have to build (and find room for) the interface unit described, as well as the sound card (and the connections - audio in, audio out, USB and other test leads as may be required).  This all adds clutter, but far less than you'd have if you need to jury-rig attenuators, preamps and adapter leads.  I don't know how many readers will embark on this little adventure (especially if all options are included), because while it's superficially simple, the devil is in the details.  The metalwork is the most challenging unless you have a very comprehensive workshop setup.  My unit will now form a permanent part of my test equipment, but I know that I'll still use my function generator, the harmonic filters I use regularly (based on Project 218) and a conventional distortion analyser.  The oscilloscope will still be the first thing I connect to any project under development.

This unit is very capable with a decent sound card and the right software, but it will never be the equal of an Audio Precision test set.  However, it will give you the ability to run tests that are simply not possible otherwise.  The provision of a low-distortion oscillator and spectrum analysis lets you measure very low distortion levels (and identify the harmonic structure thereof), something you can't do otherwise.


References
  1. Room EQ Wizard (Donation) Highly Recommended
  2. SillanumSoft Visual Analyzer (Donation) Recommended
  3. AUDio MEasurment Syetem (AUDMES)
  4. RightMark (ShareWare €20.00)
  5. Audio Tester (ShareWare €39.00)
  6. FFT & Spectral Leakage
  7. Distortion - What It Is And How It's Measured (ESP)
  8. Audio Precision

 


 

HomeMain Index projectsProjects Index

Copyright Notice.This article, including but not limited to all text and diagrams, is the intellectual property of Rod Elliott, and is © 2022.  Reproduction or re-publication by any means whatsoever, whether electronic, mechanical or electro-mechanical, is strictly prohibited under International Copyright laws.  The author (Rod Elliott) grants the reader the right to use this information for personal use only, and further allows that one (1) copy may be made for reference while constructing the project.  Commercial use is prohibited without express written authorisation from Rod Elliott.
Change Log:  Page Created and © Rod Elliott November 2022./ Update Dec 23, corrected incorrect loop switch wiring in Fig 12.