Strange A/D acquistion results

Board=Bls4160, DynamiC=DCRabbit_10.64 (no difference to DCRabbit_10.72E)

We do not unterstand how to configure the A/D acquisition or do not unterstand the results we get:

  • we configure all 8 channels of the board with
    anaInConfig (channel, SE0_MODE); // 0 - 20v
  • we acquire the channel values with
    voltage = anaInVolts (channel, GAIN_X5); //0-4V
    rawDigits = anaIn(channel, GAIN_X5); //0-4V

What we expect is to have a measurement range of 0-4V with a resolution of 2048 digits.
What we get is ~1650 digits at 4V. We assumed ~2048 digits at 4V!!!

Examples:
voltage rawDigits
3,10161 1281
3,11371 1286
3,09677 1280
3,09919 1281
3,0871 1275
3,10161 1282
3,09677 1281
3,08952 1277

What is wrong?

1 Like

Have you calibrated the BL4S160? I’m not sure if they’re calibrated during manufacturing, or if it’s assumed customers will calibrate it for the modes/gains they require.

You can use Samples/BL4S1xx/ADC/adc_rd_se_unipolar.c to display the current calibration data.

Run adc_cal_se_unipolar.c to perform a calibration and store the data.

It has nothing to do with calibration. The boards are calibrated.

The anaIn function returns a value (rawdata) which is somehow(?) related to the assumed digits of 0 to 2047.
The voltage (returned by anaInVolts) is computed via the calibration values stored in the ADC_Cal_Table.

rawdata =anaIn(…)
rawdata = ADC_Cal_Table[channel].offset - rawdata;
return ADC_Cal_Table[channel].gain * rawdata; //<<

So you have seen the code in anaInVolts() (from BL4S1xx.lib), and you’ve posted the relevant code on how it converts from a raw reading to volts. Has that answered your original question, or are you looking for additional information?

I would like to understand why the code returned from the ADC is only between ~0 to ~1630 counts for all gain/measurement ranges.
The resolution of the ADC in each range is
input_voltage/~1630
and NOT as expected
input_voltage/2047
The documentation is not really helpful here.
At least now we know why we do NOT get counts values up to 2047. So this behaviour is not caused by a bug in our software, it seems to be nominal.

From the documentation for anaInVolts():
Voltage ranges given in the table below are nominal ranges that will be returned. However, values outside these ranges can often be seen before the return of a BL_OVERFLOW error.

I don’t have a definitive answer, but note that a voltage range of 0V to 5V does align with the readings you’re seeing. I don’t know if the restricted range of 0V-4V is to allow a safety margin for voltages up to 25% higher, or if this is an issue with the ADC configuration in BL4S1xx.lib. I note that the library configures the ADC for a 2.5V reference voltage (see the ads7870_power() function), but the ADC also supports 2.048V as an option. Perhaps using that reference voltage results in the voltage ranges for each gain code using the full 2048-bit range. It wasn’t clear to me from reading the ADS7870 data sheet (https://www.ti.com/product/ADS7870) how the gain codes and reference voltage affect the supported voltage range.

Hello Tom,
thank you for your answer and effort!
I did not really understand the ADS7870 as well.
for the moment we can continue working with the information we have.
Thank you!

May be helpful for others the following tests:
Input Voltage Selected Gain anaInVolts() anaIn() value
5,0000 20 5,015 405
5,0000 10 5,019 813
5,0000 5 5,016 1627
4,0001 4 4,02 1628
2,5000 2,5 2,505 1629
2,0000 2 1,998 1630
1,2500 1,25 1,251 1634
1,0000 1 1,002 1637

10,0000 20 10,018 812
9,9998 10 10,035 1627