[solved] Read data from differential ADC

I have a PCB that provides processed voltages from thermocouples to a fully differential ADC (AD7790) but I read a value that is half of what I expect.

The differential input voltage of the ADC is Vin = -2.279 V with AIN(+) = 1.36 V and AIN(-) = 3.639 V. The PGA's gain is set to 1 and Vref = 2.5 V.

According to the datasheet of the AD7790 the return value is calculated as followed:
Code = 216-1[(Vin(gain/Vref))+1]

I would expect a Value of 2897 but I receive a value of 1362.

Has anyone an idea where to look? I used uint16 for the ADC value but in this case a signed int shouldn't make any difference.

#include <Arduino.h>
#include <SPI.h>
#include "AD7790.h"

// AD7790 Pin Assignments
#define AD7790_SS      8  // value of the CS pin assignment

// AD7790 variables
//uint16_t ui16Adcdata = 0; //unsigned
int ui16Adcdata = 0;  //signed 


void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);
  SPI.begin();

  pinMode(AD7790_SS,OUTPUT);          //set CS pin for ADC
  digitalWrite(AD7790_SS,HIGH);   //brings chip select high 

  // initialize AD7790
  AD7790.AD7790_SPI_Configuration();
  Ad7790INIT();
}

void loop() {
  // put your main code here, to run repeatedly:
do
        {
          ui16Adcdata = AD7790.readAd7790(STATUS_READ);
          Serial.print("ADC Status Reg value = ");
          Serial.println(ui16Adcdata); 
        }while (ui16Adcdata & 0x80); 

        ui16Adcdata = AD7790.readAd7790(DATA_READ);
        Serial.print(ui16Adcdata);
        Serial.print("\n");

  delay(1000);
}

void Ad7790INIT(void)
{
  AD7790.writeAd7790 (RESET, 0xFF);       //Resets the part for initial use
  delay(1000);
  AD7790.writeAd7790 (MODE_WRITE, 0x00);      //Mode register value (single conversion, +/- Vref input, unbuffered mode)
  AD7790.writeAd7790 (FILTER_WRITE, 0x07);    // Filter register value (clock not divided down, 9.5 Hz update rate)

AD7790.cpp (2.39 KB)

AD7790.h (1.09 KB)

I used uint16 for the ADC value but in this case a signed int shouldn't make any difference.

The code shows that you are using a signed int. What are we supposed to believe?
What Arduino are you using?
What happens if you swap the connections to AIN+ and AIN-?

AD7790 data sheet here.

Sorry for the confusion, I tried both signed and unsigned int with no difference in the result.

// AD7790 variables
//uint16_t ui16Adcdata = 0; //unsigned
int ui16Adcdata = 0;  //signed

I am using a Nano Every board with a ATMega4809. I will first try to use the channel selection bits of the AD7790 and test the internal VDD monitor, if that doesn't work I guess I have to modify the PCB and swap the input signals. But I would expect a hugh different because the calculted value for swaped inputs is 62639 instead of 2897.

I will let you know about the result. Many thanks for your reply!

Provide a range of differential inputs, from -Vref to Vref including zero and let us know the result.

I agree that your result is confusing, based on that one test, but I don't have the hardware to verify it. With the ADS1115 there has been some confusion about interpreting the result: the differential resolution is 15 bits, not 16.

In the real world, with sensor and environmental noise, it may not matter that you lose the bottom one or two bits. Just average, and scale the result appropriately.

Can I measure the different inputs by applying a voltage of -2.5 V (-Vref) to +2.5 V (+Vref) and 0 V to the AIN(+) pin while AIN(-) is connected to GND?

For the moment I can provide the following data. I was not able to get a accurate temperature of 200°C, so it can be +/- 20K but the other two values are much more precise (approx. +/- 2K).

Temp (°C) Code measured Code calculated Vin (Diff) (V) AIN(+) (V) AIN(-) (V)
20 1362 2897 -2,279 1,36 3,639
70 4568 5990 -2,043 1,478 3,524
200 14100 14431 -1,399 1,802 3,2

Only positive voltages (GND+100mV to Vcc-100mV) may be applied to either input. Check the data sheet absolute maximum table.

I finally found the time to record some input values:

Code measured
Code calculated
Vin (Diff) (V)
AIN(+) (V)
AIN(-) (V)
variable

32768
32768
0
0
0
uint

58369
58982,4
2
2
0
uint

64755
65536
2,5
2,5
0
uint

65535 (max)
91750,4
4,5
4,5
0
uint

7166
6553,6
-2,0
0
2
uint

778
0
-2,5
0
2,5
uint

39929
26214,4
-0,5
2
2,5
uint

27115
45875,2
1
3,5
2,5
uint

-25606
26214,4
-0,5
2
2,5
int

27115
45875,2
1
3,5
2,5
int

7166
6553,6
-2,0
0
2
int

778
0
-2,5
0
2,5
int


Since 1 V in a signed int is half of the calculated value I would prefer the unsigned int with:

-2.5 V = 0
0 V = 32768
+2.5 V = 65536

Somehow it seems that the formula in my first post was correct but the voltages I tested in the beginning were applied not precise enough. However, thank you for the hint to record the input voltage range. It was my first project for a long time.

Congratulations! Please edit the title of the thread to indicate "solved".