Digital Distortion Compensation for Measurement Setup

A sawtooth wave is a linear sweep through the voltage output range of the opamp. Capturing the residual of that could be useful. Usually the frequency-dependent behavior makes this a futile task but with the frequency response calibrated out it may be possible to get a tidy chart.
 
The E-MU soundcard looks really stable. Compensation after 90 minutes of continous run since calibration vs. compensation off.
 

Attachments

  • compen-90min.png
    compen-90min.png
    82.2 KB · Views: 438
  • pass.png
    pass.png
    84.4 KB · Views: 434
This is what I have been looking for. Headphone output (single-ended stereo TRS) is connected to one balanced input. Left output channel with no signal (only DAC artefacts), right output with the measurement dual-tone signal (and DAC artefacts). Both channels are subtracted by the balanced input, then compensated. And the ugly non-harmonic DAC artefacts are almost gone, below -145dB.

Screenshot 2 - R balanced-out -> R balanced-in. The calibration was kept running to see only the non-harmonic noise, with harmonics compensated out.

Screenshot 3 - stereo headphone output with R =signal L=zeros -> R balanced-in + running calibraton. Again, the DAC artefacts are more eliminated (with accounting for the lower level)

The next step is adding another OPA1622 on top of the existing headphones output OPA1622 module and doing the R-L subtraction directly there, creating a new output. For many measurements a clean mono SE output is sufficient.
 

Attachments

  • imd-subtracted.png
    imd-subtracted.png
    95.9 KB · Views: 445
  • onetone-balanced.png
    onetone-balanced.png
    99.4 KB · Views: 428
  • onetone-subtracted.png
    onetone-subtracted.png
    96.9 KB · Views: 431
It was too big for my table anyway :)

Back to reality - the one-tone calibration was kept running (otherwise the harmonics would rise a bit for sure). And compensated dual-tone with DAC artefacts elimination would need 3 DAC channels. Since I can only side-split single tone signals, two compensated single tones would have to be merged in analog to make a compensated dual-tone generator. Plus the third channel for DAC artefacts subtraction.

555B takes just a flip of power switch and no limits guaranteed...

But yet I can see, far far in the future, a standalone device comprising

* a decent upgraded soundcard
* the calibration adapter controlled by external signals.
* and some 10-core RPI8 running/controlling the compensation and USB-audio async gadget driver (OTG) [alsa-devel] Options for ASYNC feedback source in USB-audio gadget (USB OTG)?

Hooked to any OS via USB, such "smart" standard USB-audio soundcard with built-in compensation would support any measurement software, no drivers required.

And then I woke up :)
 
AX tech editor
Joined 2002
Paid Member
You must keep on dreaming, otherwise it is all pointless anyway ;-)

But seriously, I don't see why it could not lead to a marketable product. But how to market it, how to position it, will be a major issue, and it isn't technical. If I were you I would start to think about that a bit, talk with people you trust, thinking about options. It may give you a unique opportunity, which will not come again. Don't f*ck it up :cool:

Jan
 
I am playing with Julia language, the new math kid on the block. About twice as fast as octave in running optimized math functions (and infinitely faster in scripts since Julia scripts are pre-compiled to C, like Matlab, unlike Octave).

Another major advantage is direct support for multithreading. My 8-core older xeon can generate about 80 million float64 sines every 250ms cycle in multithreaded julia code, that would be compensating 800 distortions on both playback and capture sides at 192kHz sampling rate. Quite an overkill :)

But certainly capable of compensating 768kHz DAC/ADC (?) with bandwidth 350kHz...

Code:
function generateSine(x)
    Threads.@threads for i=1:8
        sin.(x);
    end
end

cnt = Int64(1e7);
x = rand(cnt);
GC.enable(false);
@time generateSine(x)
GC.enable(true);

0.204249 seconds (50.69 k allocations: 612.883 MiB)
 
Last edited:
So far only ADC and DAC timed by one clock (i.e. one duplex soundcard) and integer-Hz fundamentals were supported . All due to FFT length = samplerate, i.e. resolution 1Hz.

Independently clocked DAC and ADC (two different sound devices) never yield the same absolute frequency. Even if the DAC generates integer Hz signal, sampled frequency behind the ADC will be slightly different. Measuring this frequency precisely is one issue, determining precise amplitude and phase of all harmonics with FFT is another issue - the frequencies must center on FFT bins.

Great inexpensive ESS-based USB DACs exist, but they almost never come with ADC, let alone a good one. Soundcards with very decent ADCs exist, but their DACs are way behind e.g. properly implemented ESS-9038 DACs.

The non-integer mode in the new version of my compensation tool:

Single tone:
----------------
* non-integer fundamentals - precise to around 0.001Hz

* different fundamental frequencies on split-side compensated playback and capture sides, i.e. support for independent DAC and ADC.

Dual tone:
---------------
* non-integer fundamentals on ADC side for any two integer-Hz fundamentals generated by an independent DAC

Distortion harmonics do not change (amplitude, phase) when shifting fundamental by fractions of Hz, allowing to shift the ADC-measured frequencies to DAC originals in split-sides compensation of independent DAC/ADC.

The incoming frequency/phase/amplitude are measured several times a second. I have not tested an analog oscillator, but I believe its distortion could be measured by an ADC which was previously split-sides compensated with dependent or independent DAC generating very close frequency. The analog oscillator frequency will shift in time, but the continuous measuring should adjust for a slow drift.

I tested the new version with PCI Infrasonic Quartet as DAC and E-MU 0404 USB as ADC. E-MU's balanced inputs eliminate the common-mode ground-loop noise of the two connected soundcards hooked to the same PC (standard unbalanced - balanced connection with output ground connected to cold line of the balanced input).

Screenshots:

1) The tool running split-sides compensation - Quartet generating 2911Hz, E-MU measuring 2911.040Hz. DAC-side compensation harmonics are generated at integer-Hz, while compensation harmonics generated on ADC-side must correspond to the incoming frequency - non-integer values.

2) Uncompensated loop of the two soundcards, VD in loopback - both soundcards distort quite a lot.

3) Split-sides compensation, VD in loopback

4) Split-sides compensation, LPF in loopback. The performance is slightly worse than in integer mode, but FFT length must be adjusted optimally several times a second so that its bins fit the measured fundamental/s as precisely as possible.

5) The tool running joint-sides compensation of dual tone. Quartet generates 3111Hz + 3333Hz, E-MU samples 3111.043Hz + 3333.046Hz

6) Uncompensated performance of the loopback

7) Combined-distortions compensation running on ADC side.
 

Attachments

  • dual-tone-joint-sides-compen-noninteger.png
    dual-tone-joint-sides-compen-noninteger.png
    89.2 KB · Views: 135
  • dual-tone-noninteger.png
    dual-tone-noninteger.png
    83.7 KB · Views: 114
  • dual-tone-noninteger-tool.png
    dual-tone-noninteger-tool.png
    139.5 KB · Views: 111
  • LPF.png
    LPF.png
    127.1 KB · Views: 117
  • VD.png
    VD.png
    127.4 KB · Views: 116
  • VD-pass.png
    VD-pass.png
    95.3 KB · Views: 123
  • split-compen-noninteger-tool.png
    split-compen-noninteger-tool.png
    111.8 KB · Views: 126
Last edited:
Guys, thanks a lot for your support.

Yes, I have been considering further development for a while. As of now I can see:

* a standalone device running RPi, interfacing with the measurement PC via standard USB-audio protocol for data and zero-conf USB-ethernet/web browser for advanced control. I.e. any measurement software/workflow supported out of the box.

* one (DAC + ADC) or two (DAC, ADC) USB-audio devices supplied by the user, since people often have some already, pre-owned items are cheap, etc. USB to the RPi, inputs/outputs to the frontend/calibrator, DUT connected to the frontend.

* passive-only frontend

* one/two compensated unbalanced outputs with passive (no distortion) output attenuators. Option to generate compensated dual-tone by resistor-mixing two output channels.

* one/two balanced inputs, compensated for unbalanced -> balanced connection for common-mode ground noise elimination (only hot line compensated). Passive (no distortion) balanced input attenuator before the compensated input.

* input protection behind the attenuator by clamping diodes to +/- batteries or external adapter.

* automated calibration, using geared stepper/s and multiturn pot/s, controlled by RPi GPIOs signals to microstepping drivers - already on the way for testing.

* pushbutton for DAC/ADC re-calibration at any moment

* a few status LEDs or small TFT LCD

* a metal enclosure, with separated (enclosure + distance) sections for [RPi + steppers] and [outputs + calibrator + inputs].

Another option would be a fully integrated device, with built-in DAC/ADC. But I think this segment is already quite well covered, IMO it makes no sense to duplicate the numerous efforts.

Such device is still many steps away (proper RPi USB-audio gadget support, rewriting the octave algorithms to multithreaded technology, developing the calibration control, etc).

The octave solution is and will stay GPL. As of the device, I am more looking at options for a commercial project, to be honest.

Plans may be plentiful, but the opamps have not been properly measured yet. A clean one/two tone generator only would be a rather incomplete offering. The very next step is a new calibration adapter wil low-z voltage divider.
 
> Another option would be a fully integrated device, with built-in DAC/ADC.
> But I think this segment is already quite well covered, IMO it makes no sense to duplicate the numerous efforts.

To me it makes a lot of sense, because you will be able to achieve top-end performance with less top-end hardware.
So you will win on cost, for the same performance as e.g. an AP2722.
We already know that there is a reference oscillator from Viktor.
The only "problem" with the Viktor is that it is fixed frequency, hence not as versatile as a digital solution.


Wishing you success,
Patrick
 
There is more to performance than THD. THD+N is what makes that device so expensive. While the distortion compensation may make a decent soundcard comparable (most likely better) in THD to expensive analyzers, the noise component in THD+N stays constant. While my E-MU 0404 has split DAC/ADC compensated THD below -136dB, the THD+N stays at quite poor -98dB.

On the other hand, the noise can be averaged-down by long FFT and tiny details become visible in static-frequency measurement which is the applicability area of the compensation principle.
 

Attachments

  • splt-VD-256fft.png
    splt-VD-256fft.png
    112 KB · Views: 288
Patrick, I appreciate your view. I just wanted to emphasize such tool would not make a soundcard on par with top-level analyzers in general, only in a specific measurement mode. Though quite a useful one, IMO.

I am considering a third option - an active frontend with good unbalanced output buffer (e.g. paralleled OPA1622) and good differential opamp input. That would make the performance of the compensation/measurement less dependent on performance/features of the connected soundcard. The input protection requires +/- voltage for the passive version anyway.

Honestly, I am not sure about including a full-blown USB DAC/ADC. Decent performance requires years of iterative development, expensive 4-layer PCB, etc. While good mass-produced USB soundcards cost 200USD brand-new, pre-owned half. Excellent ESS DACs cost 100USD (e.g. Khadas). Maybe a connector for built-in add-on board is a way... We will see.
 
The reported noise by REW is over the full measurement bandwidth - the measurement bandwidth can be modified, and there is also a means to block high and low frequency ranges from the reported result (as I recall I did that to exclude harmonics above a certain number during some checking).

Thanks for the info. I did not want to "fake" the results :) But it is definitely a very useful feature. REW is a great tool.
 
Disabled Account
Joined 2012
Honestly, I am not sure about including a full-blown USB DAC/ADC. Decent performance requires years of iterative development, expensive 4-layer PCB, etc. While good mass-produced USB soundcards cost 200USD brand-new, pre-owned half. Excellent ESS DACs cost 100USD (e.g. Khadas). Maybe a connector for built-in add-on board is a way... We will see.

My vote is to Not include ADC/DAC. I can get those from many places. In fact, I already have both which are suitable. Others are cheap enough.

get the software package together. Sell it to AP or thru others ... or outlets established for such products.

take a look at AP web site... they finally disconnected their HW from the SW and now selling the software alone.

Sell your work to them or at least be a good lower cost alternative.


-Richard
 
Member
Joined 2004
Paid Member
My view would be a bootable software image and a simple relay PCB with analog connectors for DUT and for a sound card and a list of supported sound cards. The PCB would need to provide input protection, input/output ranging and the necessary switching for the self calibration process. The PCB with those limitations would be pretty straightforward and not expensive (USB control and power). User to provide PC and soundcard. I would bet it could be made for $150 or less for both with the image on a bootable USB stick. A dedicated Linux distro in effect would eliminate a lot of potential problems. Add network and a web page for settings and displaying the output

Is there a market? I would add this to my arsenal but would many DIY'ers be interested? Not as sophisticated as an AP or even a QA401 but still possibly useful and much more manageable than a vintage HP.