If in doubt, ask.

Calibration

Here you will find details of

  • How a disting is calibrated.
  • How to use the calibration data in your own code.

The disting is calibrated before it leaves the factory. It is not expected that you would need to do this yourself in normal circumstances.

Calibration Procedure

Calibration requires a 3V voltage reference. Any stable and accurate voltage source can be used. It's a good idea to let the whole system warm up for 5 minutes before calibrating to stabilise any temperature-dependent factors.

The procedure is as follows:

  1. With the disting powered up and with nothing connected to it, use the menu to select option 5, 'Calibrate'. The message 'GO' will be displayed.
  2. Wait a few seconds for the display to show '1' and for the left-most column to flash.
  3. Using patch cables (as short as possible), connect output A to input X, and output B to input Y.
  4. Press the encoder.
  5. After a short delay, all four jack sockets should light up red. After another short delay, the display will show 'X' and the left-most column will flash.
  6. Remove the patch cables. Connect the 3V voltage reference to input X.
  7. Verify the reference voltage, and press the encoder.
  8. Wait a few seconds for the display to show 'Y' and the left-most column to flash.
  9. Connect the 3V voltage reference to input Y.
  10. Verify the reference voltage, and press the encoder.
  11. After a short pause, the disting will reboot, at which point the reference can be removed.
If after step 10 the disting displays the message "Uncalibrated", then the calibration was not performed correctly, and the data will not be used. Start back at step 1.

Calibration Data

The disting's calibration data is stored in eight 32 bit words from address 0xBD01FE00 (disting mk1) or 0xBD03FE00 (disting mk2/mk3). The first four refer to the left channel (input X/output A); the second four refer to the right channel (input Y/output B).

Each value is a sample of the relevant input under certain conditions. These conditions are

  1. Input disconnected (and therefore grounded)
  2. Input connected to output, output outputting a nominal zero level
  3. Input connected to output, output outputting a nominal half full range level
  4. Input connected to known 3V reference

From these we can derive constants A, Br, D, Er so that conversion between codec codes and actual voltages can be handled simply in the code as follows:

int vL = ( ( inL - A[0] ) * Br[0] ) >> 24;
int vR = ( ( inR - A[1] ) * Br[1] ) >> 24;

int cL = ( ( vOutL - D[0] ) * Er[0] ) >> 24;
int cR = ( ( vOutR - D[1] ) * Er[1] ) >> 24;

where inL/inR are the values read directly from the audio codec, cL/cR are the codes written directly to the audio codec, and vL/vR/vOutL/vOutR are .19 format voltages.

The derivation of A, Br, D, Er is as follows:

Let the four input samples be zeroIn, zeroOut, halfOut, threeVolt.
A = zeroIn
B = ( threeVolt - zeroIn )/3
Br = 0x80000000000LL / B
D = ( zeroOut - zeroIn )/B
E = ( halfOut - zeroOut )/( B * 0x400000 )
Er = 0x80000000000LL / E

The above is pseudo-code - a real C implementation is left as an exercise for the reader.