Tutorials

AD7606 Code to Voltage: Signed 16-Bit Conversion with Test Vectors

Published · Updated

Decode the 16-bit word as two’s complement before multiplying by the voltage scale. Treating 0xFFFF as unsigned produces a large positive number where the ideal result is one negative LSB.

Device scope: Original eight-channel AD7606; other family members require their own timing and channel definitions.

Separate the wire format from the voltage scale

Bench instruments including a multimeter and signal generator. Record the applied signal at the converter pin rather than relying only on generator settings.
Bench instruments including a multimeter and signal generator. Record the applied signal at the converter pin rather than relying only on generator settings. Photo: Glrx · Source · CC BY-SA 4.0.

First reconstruct the raw word from the captured bits or bytes in the documented order. Next convert that word to a signed integer. Only then apply the selected analog range. These are three separate transformations, and testing them separately makes failures much easier to locate.

For the original AD7606's ideal bipolar transfer, use V = signed_code × F / 32768, where F is the positive range endpoint: 5 V for the ±5 V range, or 10 V for the ±10 V range. F is not the full peak-to-peak span. Using 10 V as F for a ±5 V setting doubles every reported voltage.

This calculation describes ideal code scaling, not the exact analog voltage that produced a noisy quantized result. Offset, gain, reference error and input-path error still need a calibration model. Keep the raw code available so later calibration changes do not require repeating the acquisition.

Keep fixed-point scale explicit.

Run boundary vectors before connecting the analog source

Signed code crosses zero; it does not wrap in voltageSigned code crosses zero; it does not wrap in voltage0x8000-5 V0x00000 V0x7FFF< +5 VIdeal +/-5 V scaling: signed code × 5 / 32768
Engineering illustration. Numerical examples and timing assumptions are identified in the text.

For the ±5 V range, 0x0000 maps to 0 V, 0x0001 to +0.000152587890625 V, 0xFFFF to the corresponding negative value, 0x8000 to −5 V, and 0x7FFF to 4.999847412109375 V. The positive endpoint is one LSB below +5 V because a signed 16-bit integer ends at 32767.

The Python function below rejects out-of-range raw integers rather than silently masking them. This catches an accidental 24-bit or malformed input at the software boundary. If the capture is two bytes, choose byte order explicitly before calling it. For example, bytes 0x40,0x00 represent 0x4000 in big-endian order but 0x0040 in little-endian order.

Use the same boundary vector file for the FPGA model and host conversion routine. A test at zero alone cannot detect a sign error, range factor error or reversed bytes. Test both signs, both endpoints and a midrange value.

def ad7606_volts(raw, positive_full_scale):
    if not isinstance(raw, int) or not 0 <= raw <= 0xFFFF:
        raise ValueError("raw must be a 16-bit unsigned integer")
    if positive_full_scale not in (5, 10):
        raise ValueError("use 5 for +/-5 V or 10 for +/-10 V")
    signed = raw if raw < 0x8000 else raw - 0x10000
    return signed * positive_full_scale / 32768

assert ad7606_volts(0x8000, 5) == -5
assert ad7606_volts(0x4000, 5) == 2.5
assert ad7606_volts(0xFFFF, 5) == -5 / 32768
assert ad7606_volts(0x7FFF, 5) == 5 - 5 / 32768

Run with Python 3; the assertions check ideal arithmetic only. They do not test board calibration.

Review rounding and saturation behavior.

Keep calibration and clipping visible

Keep four data transformations testableKeep four data transformations testableBytesChoose byte orderRaw word0...65535Signed integer-32768...32767VoltageApply range and calibration
Engineering illustration. Numerical examples and timing assumptions are identified in the text.

At a known +2.5 V input in the ±5 V ideal model, the target code is 0x4000. If a verified raw 0x4000 displays +5 V, inspect range scaling before touching the analog hardware. If the raw word is 0x0040, investigate byte assembly first. If repeated endpoint codes appear as input increases, inspect clipping and the actual range setting.

For a two-point correction, retain the two applied voltages, the averaged raw codes, the measurement instrument and the conditions. A line through two points can correct a fitted gain and offset; it does not prove linearity, noise performance or behavior outside those points. Repeated endpoint codes should be flagged as possible overload, not converted into a reassuring flat line without an annotation.

Store a range identifier alongside each block of samples. If hardware can change range during operation, define where the new scale becomes valid and mark the transition. A conversion function cannot infer the range from the raw code alone.

Retain the acquisition and transport budget.

Record the arithmetic implementation version.

Check your interpretation

Raw 0x4000 displays +5 V with a verified ±5 V setting. Which check comes first?

Check the full-scale factor: the ideal result is +2.5 V. Do not use the 10 V peak-to-peak span as the positive endpoint.

Replay the task sequenceRaw word: 0xFFFF; Unsigned container: 65535; Signed integer: -1; +/-5 V range: -152.588 uV

Raw word: 0xFFFF → Unsigned container: 65535 → Signed integer: -1 → +/-5 V range: -152.588 uV

Review packet: Bring raw hexadecimal words, the measured input voltage, range setting and byte order when requesting a conversion review. Open the engineering review page. Opening this page does not transmit your traces.

Sources and limits

Documentation checked 20 November 2026. Calculated examples and proposed tests are identified above; no board measurement or timing-closure result is claimed.

Back to Tutorials

Related evidence and next tasks

Continue the task with the relevant source scope. These reading paths do not establish interchangeability or current supply.

Source addresses and citation trail

Full source addresses are retained below. Read each citation with its document revision, page, table and applicability conditions above.

  1. https://commons.wikimedia.org/wiki/File:Electronic_instruments_digital_multimeter,_frequency_counter,_frequency_standard_receiver,_and_signal_generator.jpg
  2. https://creativecommons.org/licenses/by-sa/4.0
  3. https://www.analog.com/media/en/technical-documentation/data-sheets/ad7606_7606-6_7606-4.pdf
  4. https://developer.analog.com/docs/linux/latest/drivers/iio-adc/ad7606.html