Calibration
Here you will find details of- How a disting is calibrated.
- How to use the calibration data in your own code.
Calibration Procedure
Calibration is achieved by providing the board with various inputs and pressing the push button mounted on the board itself.When the board is awaiting a button press, LED ‘1’ flashes quickly.
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:
- With the board powered up and with nothing connected to it, press the button.
- Wait a few seconds for LED ‘1’ to flash rapidly.
- Using patch cables (as short as possible), connect output A to input X, and output B to input Y.
- Press the button.
- After a short delay, all four jack sockets should light up red. After another short delay, LED ‘1’ will flash rapidly.
- Remove the patch cables. Connect the 3V voltage reference to input X.
- Verify the reference voltage, and press the button.
- Wait a few seconds for LED ‘1’ to flash rapidly.
- Connect the 3V voltage reference to input Y.
- Verify the reference voltage, and press the button.
- After a short pause, the board will reboot, at which point the reference can be removed.
Calibration Data
The disting's calibration data is stored in eight 32 bit words from address 0xBD01FE00 (disting mk1) or 0xBD03FE00 (disting mk2). 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
- Input disconnected (and therefore grounded)
- Input connected to output, output outputting a nominal zero level
- Input connected to output, output outputting a nominal half full range level
- Input connected to known 3V reference
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 / EThe above is pseudo-code - a real C implementation is left as an exercise for the reader.