LTC2499 ( Reading data )

Hi

I am using ADC(LTC2499 ) on my board without E2PROM with Vref=4.096V. I want to get raw data from some channels then convert it to voltage but I have issue with my code ,each channel will be single ended measurement - My address is 0x76 for I2C .
I used library from ard-ltc2499 which available on github

If I understand how can work with one channel I can do rest.Tested Temp feature it worked I got temperature but struggle with channels data

The GitHub page: https://github.com/IowaScaledEngineering/ard-ltc2499/

Thank you for help .

This is my code

#include <Wire.h>
#include <Ard2499.h>

Ard2499 ard2499board1;

byte confChan=0;

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  Wire.begin();
  ard2499board1.begin(ARD2499_ADC_ADDR_111, ARD2499_EEP_ADDR_ZZ);
  ard2499board1.ltc2499ChangeConfiguration(LTC2499_CONFIG2_60_50HZ_REJ);


}
byte i=0;

void loop() {
  
  float Channel_1=ard2499board1.ltc2499ReadRawAndChangeChannel(LTC2499_CHAN_SINGLE_1P);
  float convert_to_voltage = (Channel_1 * 4.096)*(16777215);
  
      Serial.print("Channel ");
      Serial.print(" SE");
      Serial.print(" = [");
      Serial.print(Channel_1);
      Serial.print("]\n");
      delay(5000);
}

this is my result from raw-data

hannel  SE = [1107439360.00]
Channel  SE = [1107369344.00]
Channel  SE = [1107456256.00]
Channel  SE = [1107451392.00]
Channel  SE = [1107303936.00]
Channel  SE = [1107394304.00]
Channel  SE = [1107460736.00]
Channel  SE = [1107462784.00]
Channel  SE = [3221225472.00]
Channel  SE = [1113034752.00]
Channel  SE = [1112996736.00]
Channel  SE = [1112502144.00]
Channel  SE = [1112089344.00]
Channel  SE = [1111644032.00]
Channel  SE = [1111415296.00]
Channel  SE = [1111068672.00]

Are you sure that ltc2499ReadRawAndChangeChannel() returns a float? It looks like it is returning an 'unsigned long' (32-bit unsigned int) containing 24 bits of data.

You are calculating a voltage, but not displaying the value. That's going to make it hard to verify the calculation.

You are multiplying by the maximum reading (16777215) instead of dividing! That will not only give the wrong answer but it will likely overflow your 32-bit math.

Try this instead:

void loop() {
  unsigned long raw = ard2499board1.ltc2499ReadRawAndChangeChannel(LTC2499_CHAN_SINGLE_1P);
  float voltage = (raw * 4.096) / 16777215ul;
 
      Serial.print("Channel ");
      Serial.print(" SE");
      Serial.print(" = [");
      Serial.print(raw);
      Serial.print("]  V=");
      Serial.println(voltage, 5);  // Voltage from 0 to 4.09600
      delay(5000);
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.