LTC 1867 external ADC range/bit problem

I have managed to connect my Arduino Nano to an LTC1867. It is wired as recommended in the datasheet (Typical Connection), however my results are not so typical.

I understand the measuring range should be 0-4.096V translating into 0-65535 as it’s a 16-bit-ADC. I am getting only half of the range, that means 0-32767 between 0-2V. The upper half does not get measured, the ADC doesn’t count further than 32767.

Below is my stripped down source code.

What did I miss?

#include <SPI.h>

const byte CH0 = 0b10000000; //Channel select, select channel 1, unipolar mode

const int chipSelectPin = 10;

unsigned long finresult;

void setup() {
  Serial.begin(9600);

  // start the SPI library:
  SPI.begin();

  // initalize the  chip select pin:
    pinMode(chipSelectPin, OUTPUT);

 
  // give the sensor time to set up:
  delay(100);
}

void loop(){
ergebnis=cycleData(CH0);
   Serial.println(finresult);
  delay(1000); 

}

unsigned long cycleData(byte channelNo) {
  byte hiByte = 0;
  byte loByte = 0;           // incoming byte from the SPI
  unsigned long result = 0;   // result to return
  
  // take the chip select low to select the device:
  digitalWrite(chipSelectPin, LOW);
  delay(50);
  hiByte = SPI.transfer(channelNo); //Send request
  result = hiByte;
  result = result << 8; //shift byte
  loByte = SPI.transfer(0x00);//send empty byte to fetch byte
  result = result | loByte;//combine
  digitalWrite(chipSelectPin, HIGH);//deselect slave
  return(result);
}
const byte CH0 = 0b10000000; //Channel select, select channel 1, unipolar mode

should be

const byte CH0 = 0b01000010; //Channel select, select channel 1, unipolar mode, single ended.

for unipolar mode. You have selected bipolar mode which will only give you 15 bits plus sign resolution.

Edit: I also noticed that the SD bit was wrong. The configuration word only has 7 bits of significance.

Thank you for looking into it,

but that does not seem to work either, as no channel gets selected at all anymore.

Yes, the configuration word has only 7 bits and I need to get back 16 for the result.

Sorry I have made a mistake, I commented in the code I wanted to select channel 1 with is in fact channel 0 on the LTC, the connection is numbered 1 on my soldering board. So I tried to select channel 0 using 10000000.

So the first bit I send should be the SD-bit, followed by six other relevant bits as decribed in the Datasheet. The last (8th) bit would be not needed and is a dummy as the whole second byte I send to fetch the lower byte of the result.

In the datasheet the config word for using channel 0 as "+", ground as "-" is 10000 for the first five bits followed by another zero to select unipolar and another to deselect sleep mode.

I don't get why you've come up with 0b01000010, and it doesn't seem to work either..

Thanks

Sorry, I got the configuration word offset by one bit. If you are using channel 0 with GND as your negative lead the 7 bit configuration word should be 0b10000100.

To select unipolar operation, which is what you need to get the full 16 bits of resolution, you have to set the "UNI" bit to one as well. That bar over "BIPOLAR" in the data sheet means zero for bipolar operation. You are correct that "SLP" should be zero.

Sorry for replying so late, private life kept me away from my Arduino last week.

Thank you so much, it works like a charm now!

spacko: Sorry for replying so late, private life kept me away from my Arduino last week.

Thank you so much, it works like a charm now!

Yeah, life gets in my way too. :) I'm glad you got it working.

sorry to bother you. I am trying to do a project similar to what you did. I have understood the LTC1867 sends back two bytes (please correct me if i am wrong). how do you obtain the 16bit resolution if you are only getting one byte back?