Hello, There !
In one of my projects, I am trying to read ADC (ADS8681) data using SPI mode with Arduino Mega2560. I am able to get correct waveform across SPI pins while applying analog input of the range +- 10V in this case in first attempt (No Load to Full Load) it gives correct variation on LCD from 0 to 65,536 values. But when i remove the analog input (No Load) it shows some random values, instead of "0". SO can anyone suggest how to fix this problem? I would be rateful for any advice how to receive suitable data.
(connection to a single ADC, according to figure 71 (ADC data sheet p.37))
References which i used :
1] ADS8681 Datasheet : https://www.ti.com/product/ADS8681
2] Arduino SPI Library : SPI - Arduino Reference
3] TI Community : ADS8681: Problems to configure ADS 8681 to a Arduino MKW 1010 Wifi via SPI - Data converters forum - Data converters - TI E2E support forums
Here is the code
#include <SPI.h>
#include <LiquidCrystal.h>
#define SS 53
#define SCK 52
#define MOSI 51 // SDI
#define MISO 50 // SDO_x
uint16_t receivedVal16 = 0 ;
LiquidCrystal lcd (38,37,36,35,34,33);
void setup()
{
lcd.begin(16,4);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
digitalWrite(SCK,OUTPUT);
digitalWrite(MOSI,OUTPUT);
digitalWrite(SS,OUTPUT);
digitalWrite(MISO,INPUT);
digitalWrite(SS, HIGH); //Write RANGE_SEL_REG
delay(10);
digitalWrite(SS,LOW);
SPI.transfer(0xD4);
SPI.transfer(0x14);
SPI.transfer(0x00);
SPI.transfer(0x01);
digitalWrite(SS, HIGH); //Write DATA_OUT_CNT_REG
delay(10);
digitalWrite(SS,LOW);
SPI.transfer(0xD4);
SPI.transfer(0x10);
SPI.transfer(0x41);
SPI.transfer(0x00);
}
void loop()
{
digitalWrite(SS, HIGH); //Write RANGE_SEL_REG
delay(10);
digitalWrite(SS,LOW);
SPI.transfer(0xD4);
SPI.transfer(0x14);
SPI.transfer(0x00);
SPI.transfer(0x01);
digitalWrite(SS, HIGH);
delay(10);
digitalWrite(SS,LOW);
receivedVal16 = SPI.transfer16(0x00);
lcd.setCursor(0,1);
lcd.print(receivedVal16);
delay(100);
}