Analog to Digital Converter with Arduino Uno and ADS7883

Hello, I made my Analog to Digital Converter few hours ago. However, it doesn’t work. It just print 0 all the time. Please give me any suggestion.

I refered the code from here. " https://forum.arduino.cc/index.php?topic=116719.0 " In there, same IC chip and same content.

Here is my code.

#include <SPI.h>

const byte slaveSelectPin = 10; //CS

void setup() {
  Serial.begin(9600);
  pinMode(slaveSelectPin,OUTPUT);
  digitalWrite(slaveSelectPin,HIGH); //chip active LOW
 
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE1);
  SPI.setClockDivider(SPI_CLOCK_DIV16);
 
  Serial.println("Initialized!");
}

void loop() {
  long readADC = SpiRead();
  Serial.println(readADC);
}

long SpiRead(void) {
  byte result;
  byte b;
 
  digitalWrite(slaveSelectPin,LOW);
  result = SPI.transfer(0xFF);
  result <<= 8;
  b = SPI.transfer(0xFF);
  result |= b;
  result = result>>2; 
 
  digitalWrite(slaveSelectPin,HIGH);
  return(result); 
}

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

In the function SpiRead You need to change the variable result from byte to word, unsigned int, or maybe unsigned long.