ADS1015 not functioning correctly

Hi

I’m reading two differential voltages. The results of A0 - A1 are also displayed in A2 - A3. If I delay 10 ms to measure A2-A3, I will get the correct results. But I need higher speed than that! If I substitute with ADS1115 module then there’s no problem. Is my ADS1015 defective?
Thanks

#include <Wire.h>
#include <Adafruit_ADS1015.h>

// Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */
Adafruit_ADS1015 ads;     /* Use this for the 12-bit version */

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Hello!");
  
//  Serial.println("Getting differential reading from AIN0 (P) and AIN1 (N)");
//  Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
  
  // The ADC input range (or gain) can be changed via the following
  // functions, but be careful never to exceed VDD +0.3V max, or to
  // exceed the upper and lower limits if you adjust the input range!
  // Setting these values incorrectly may destroy your ADC!
  //                                                                ADS1015  ADS1115
  //                                                                -------  -------
  // ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default)
  // ads.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
   ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
  // ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV
  // ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
  // ads.setGain(GAIN_SIXTEEN);    // 16x gain  +/- 0.256V  1 bit = 0.125mV  0.0078125mV
  
  ads.begin();
}

void loop(void)
{
  int16_t results1;
  int16_t results2;
  
  /* Be sure to update this value based on the IC and the gain settings! */
//  float   multiplier = 3.0F;    /* ADS1015 @ +/- 6.144V gain (12-bit results) */
  //float multiplier = 0.1875F; /* ADS1115  @ +/- 6.144V gain (16-bit results) */

  results1 = ads.readADC_Differential_0_1();  
  delay(10);
  results2 = ads.readADC_Differential_2_3(); 
 

  Serial.print("Results1: "); Serial.println(results1); 
  Serial.print("Results2: "); Serial.println(results2); 

  delay(1000);
}

The problem I'm seeing is not just related to differential measurements. I place a different voltage on each of the 4 inputs. The single ended result displayed is always that of the first measurement. If A0 is accessed first, then A1, A2 and A3 will also show same output as A0. If A3 is accessed first, then all will show A3's output. If I put a 10ms delay between readings then I get correct outputs.

It all works OK with ADS1115.

Is there a problem with the library?

Did you read the datasheets of the two sensors to find the 7(?) differences between the 1015 and the 1115?

I have looked at the datasheets. There are more than 7 differences. Other than possible problems with the library, I haven't seen anything that correlates to my issue. What's on your mind?

I don't know how the library is configured or know how to view it. The a/d can be accessed via single shot or continuous. In single shot it goes to a low power mode. It would be great to rule out the library if someone can verify their ADS1015 operates a lot faster than the 100 SPS I'm getting. The spec for single shot mode is 128 SPS! Continuous is 3.3k SPS.

Gerry

I was able to find the Adafruit_ADA1015.ccp library and see the power-down single-shot mode is listed in the configuration as default for measuring single ended and differential. That will certainly slow down the a/d.

I've changed Adafruit_ADA1015.ccp

from: ADS1015_REG_CONFIG_MODE_SINGLE // Power-down single-shot mode (default)

to: ADS1015_REG_CONFIG_MODE_CONTIN; // Continuous conversion mode

in 4 locations but I'm still getting same results. I must be doing something wrong as I have no experience in these issues.

I get the feeling I’m just talking to myself. :confused:

Got a handle on what’s going on… (more or less)

You can only get high speeds out of the ADS1015 (or ADS1115) if you’re operating just one of the four channels. Switching channels will cost about 10 ms, making 100SPS the max data rate when accessing multiple channels.

It was perplexing that in the original sketch, the ADS1115 was working OK while the 1015 was not. That’s because in the library .h file, there are two different delays defined. The 1015 has a 1 ms delay added before each data read and the 1115 has a 8 ms delay. I don’t know if my 1015 is bad, but it also needs a 8 ms delay to make it work.

I believe you need a 8ms delay each time the config file is changed in the device. And, each time the channel is changed the config file must change.

When using “readADC_SingleEnded(uint8_t channel)”, all 9 config variables are first loaded into the device, a delay is instituted and then the a/d is read. It doesn’t matter if the device is in single step (power down mode) or continuous mode, there’s just one measurement taken.

To get around these problems, the 1015 is limited to just one channel. The “readADC_SingleEnded(uint8_t channel)” command with continuous mode defined in the config file is implemented in setup to run just once. The command “getLastConversionResults()” is then used in the sketch to get a 1.5 ms data rate. But first the delay needs to be removed from within the getLastConversionResults() function. No delay is needed or wanted.

Here’s some data of vehicle battery current during a start. y-axis is current in amps. x-axis is time in seconds.

I get the feeling I'm just talking to myself. :confused:

Sorry, it is holiday time and I have little time for the forum now. Still good to hear you came this far.

No problem Rob. It's sometimes good to talk to yourself to work the problem out.

Happy New Year.