Post Go back to editing

Category: Software

I am programming a library for the ADAQ7768-1 (together with the Mikroe DAQ click board) for use with an Arduino using SPI communication. I'm able to read the several provided registers. But I'm wondering about converting the raw data to the actual voltage. The datasheet provides the following formula:

Where Offset and Gain are 24-bit, signed, two's complement values.

Using a reference voltage of 4.096 V (provided by the DAQ click board), and the standard gain and offset of 0x555555 (default as per the datasheet), voltage under ~3.7 V give negative data values. How should I read these values? It's not clear from the data sheet.

Moreover, in the DAQ click example code (search for "DAQ click" on this page), they use a simplified formula that doesn't even involve nor the offset nor the Vref:

`voltage = ( ( ( ctx->gain ) / ( DAQ_RESOLUTION ) ) * adc_data );`

## Top Replies

• Hi  ,

We will look into this. I will contact the product owner and get back to you.

Regards,

JC

• Hi ,

## Codes to Voltage Conversion

The code snippet from MikroElektronika’s github for DAQ Click is correct: voltage conversion of the ADC_DATA is that simple.

We also intend to add this section / formula to the datasheet in the future:

“Use the following equation to convert from codes to volts, assuming the codes have first been converted from twos complement to straight binary:

where the Midscale Code is 0x800000 in straight binary, and 0x7FFFFF in Table 12 is converted to 0xFFFFFF in straight binary. Use the previous equation to calculate a voltage in the VREF / AFE_GAIN range.”

Followed by Figure 75 and Table 12 (already in the datasheet):

Ex. If input Voltage = 12.6V at AFE_GAIN = 0.325, and VREF = 4.096V:

## Gain and Offset Calibration

Regarding the formula:

This is actually the formula that calibrates ADC_DATA, depending on the Offset and Gain values from the Offset Calibration Registers (0x21 to 0x23) and the Gain Calibration Registers (0x24 to 0x26). Any register value to “Offset” and “Gain” would affect the ADC_DATA, before you would even convert it to voltage.

Vin here was also not able to consider the AFE_GAIN, which is an error on our part.

To improve this, we would think about changing some variable names, such that:

Where:

ADC_DATA is in 2's complement code.

OffsetCal = decimal value from the Offset Calibration Registers (0x21 to 0x23), default value = 0 (not 0x555555).

GainCal = decimal value from the Gain Calibration Registers (0x24 to 0x26), default value around 0x555555 (varies from device to device).

Ex. Using VIN = 12.6V, AFE_GAIN = 0.325, VREF = 4.096V, OffsetCal = 0, GainCal = 0x555555