0

ADS1115 Read Rate
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ADS1115 Read Rate

by Phil_Rounds on Mon Jul 06, 2015 11:52 am

The ADS1115 takes just under 9ms to perform a read, not fast enough for my application. I did some poking around in the Adafruit_ADS1015.h & Adafruit_ADS1015.cpp files, and saw a few things.

1: #define ADS1115_CONVERSIONDELAY is set at 8mS, where as ADS1015_CONVERSIONDELAY is only 1mS. Is this differerence real?

2: The Adafruit_ADS1015::readADC_Differential_0_1() function starts with an extended configuration sequence, culminating in delay(ADS1115_CONVERSIONDELAY ). If I'm willing to have a version of this for my one application where I read only one port, with only one gain, etc, can I separate the configuration portion from the actual read portion, and call my new configuration function once then read at will, or does the chip need to be configured for every read?

Phil_Rounds
 
Posts: 54
Joined: Thu Aug 07, 2014 5:12 pm

Re: ADS1115 Read Rate

by adafruit_support_bill on Mon Jul 06, 2015 12:22 pm

The library has not been optimized. There is room for some performance enhancement. If you are only reading a single channel, you can configure it for continuous reads at the max sample rate (860/s) and then just issue reads every 1.2 ms.
http://www.adafruit.com/datasheets/ads1115.pdf

adafruit_support_bill
 
Posts: 81900
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1115 Read Rate

by Phil_Rounds on Mon Jul 06, 2015 4:24 pm

Here's the readADC_Differential_0_1 code
Code: Select all | TOGGLE FULL SIZE
int16_t Adafruit_ADS1015::readADC_Differential_0_1() {
  // Start with default values
  uint16_t config = ADS1015_REG_CONFIG_CQUE_NONE    | // Disable the comparator (default val)
                    ADS1015_REG_CONFIG_CLAT_NONLAT  | // Non-latching (default val)
                    ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low   (default val)
                    ADS1015_REG_CONFIG_CMODE_TRAD   | // Traditional comparator (default val)
                    ADS1015_REG_CONFIG_DR_1600SPS   | // 1600 samples per second (default)
                    ADS1015_REG_CONFIG_MODE_SINGLE;   // Single-shot mode (default)

  // Set PGA/voltage range
  config |= m_gain;
                   
  // Set channels
  config |= ADS1015_REG_CONFIG_MUX_DIFF_0_1;          // AIN0 = P, AIN1 = N

  // Set 'start single-conversion' bit
  config |= ADS1015_REG_CONFIG_OS_SINGLE;

  // Write config register to the ADC
  writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config);

  // Wait for the conversion to complete
  delay(m_conversionDelay); [b]// For 1115 m_conversiondelay = 8ms, for 1015 1ms[/b]

  // Read the conversion results
  uint16_t res = readRegister(m_i2cAddress, ADS1015_REG_POINTER_CONVERT) >> m_bitShift;
  if (m_bitShift == 0)
  {
    return (int16_t)res;
  }
  else
  {
    // Shift 12-bit results right 4 bits for the ADS1015,
    // making sure we keep the sign bit intact
    if (res > 0x07FF)
    {
      // negative number - extend the sign to 16th bit
      res |= 0xF000;
    }
    return (int16_t)res;
  }
}



To put in continuous mode, I see where I would have to change the line following " // Set 'start single-conversion' bit" to set continuous mode, as specified in ADS1015.h.

Would I then have to add to the initiation of my ADS1115 all the code (modified to continuous) in the readDifferential_0_1 up to the actual read and have my new readDifferential_0_1 just issue the read?

Thanks
Last edited by franklin97355 on Mon Jul 06, 2015 6:42 pm, edited 1 time in total.
Reason: Added missing [code] tags

Phil_Rounds
 
Posts: 54
Joined: Thu Aug 07, 2014 5:12 pm

Re: ADS1115 Read Rate

by adafruit_support_bill on Mon Jul 06, 2015 4:51 pm

Once you put it into continuous sample mode, you can just keep reading the results.

adafruit_support_bill
 
Posts: 81900
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1115 Read Rate

by Phil_Rounds on Mon Jul 06, 2015 5:40 pm

So I can change the code to put it into continuous mode by changing ADS1015_REG_CONFIG_MODE_SINGLE to ADS1015_REG_CONFIG_MODE_CONTINUOUS - but every subsequent call to ADS1115_readDifferential_0_1() still runs the delay( 8ms ) , keeping me to fewer than 125 reads per second.

Phil_Rounds
 
Posts: 54
Joined: Thu Aug 07, 2014 5:12 pm

Re: ADS1115 Read Rate

by adafruit_support_bill on Mon Jul 06, 2015 5:45 pm

You don't need the delay.

When the ADC is in continuous conversion mode, the contents of the conversion register are always valid. At the max conversion rate of 860Hz, the output will be updated about every 1.2ms. You can read it more frequently than that if you want - it just won't change any faster.

adafruit_support_bill
 
Posts: 81900
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1115 Read Rate

by Phil_Rounds on Fri Aug 07, 2015 2:06 pm

I can read quickly, but I read the same results 3 or 2 times in a row.

I'm using SoftTimer with a method triggered ever 3ms. I get the same results 3 times, then another result 2 times, then another result 3 times,

Phil_Rounds
 
Posts: 54
Joined: Thu Aug 07, 2014 5:12 pm

Re: ADS1115 Read Rate

by adafruit_support_bill on Fri Aug 07, 2015 2:20 pm

Are you setting the data rate to the maximum speed? See pages 18-19 in the data sheet" http://www.adafruit.com/datasheets/ads1115.pdf

adafruit_support_bill
 
Posts: 81900
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1115 Read Rate

by Phil_Rounds on Fri Aug 07, 2015 6:44 pm

Thanks - that did it - though I had to just make a swag at changing
ADS1015_REG_CONFIG_DR_1600SPS
to
ADS1015_REG_CONFIG_DR_3300SPS

Phil_Rounds
 
Posts: 54
Joined: Thu Aug 07, 2014 5:12 pm

Re: ADS1115 Read Rate

by adafruit_support_bill on Fri Aug 07, 2015 7:52 pm

ADS1015_REG_CONFIG_DR_3300SPS is 0x00C0. That will give you 475 SPS on the ADS1115.
From the data sheet, you need 0x00E0 for 860 SPS on the ADS1115.

adafruit_support_bill
 
Posts: 81900
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.