This page describes the legacy mk3 disting. For the current product, please see here.
If in doubt, ask.


Here you will find details of
  • How a disting is calibrated.
  • How to use the calibration data in your own code.

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 board powered up and with nothing connected to it, use the menu to select option 4, calibration. LEDs 1-3 & a-c will flash twice.
  2. Wait a few seconds for LED 'a' to light and LED ‘1’ to flash rapidly.
  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, LED ‘1’ will flash rapidly.
  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 LED ‘1’ to flash rapidly.
  9. Connect the 3V voltage reference to input Y.
  10. Verify the reference voltage, and press the encoder.
  11. After a short pause, the board will reboot, at which point the reference can be removed.
If after step 10 the disting flashes LEDs 1-3 & a-c rapidly for an extended period (40 flashes), 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.