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)
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-?
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).
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.