ADS_1115 sampling rate
Moderators: adafruit_support_bill, adafruit

ADS_1115 sampling rate

by ptc on Fri Jan 25, 2013 6:51 pm

Hi,

I am trying to use the ads1115 adc to collect data from three inputs. I am using the ads1x15 library for Arduino. Using the example code, I get ~38 SPS. How do I increase the sampling rate?

thanks,
ptc
 
Posts: 3
Joined: Sat Dec 15, 2012 6:03 pm

Re: ADS_1115 sampling rate

by adafruit_support_mike on Sat Jan 26, 2013 12:00 am

You'll want to use the function ADS1115::setRate(). Send it one of the following values from the header file:

Code: Select all | TOGGLE FULL SIZE
#define ADS1115_RATE_8              0x00
#define ADS1115_RATE_16             0x01
#define ADS1115_RATE_32             0x02
#define ADS1115_RATE_64             0x03
#define ADS1115_RATE_128            0x04 // default
#define ADS1115_RATE_250            0x05
#define ADS1115_RATE_475            0x06
#define ADS1115_RATE_860            0x07
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 10122
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADS_1115 sampling rate

by ptc on Sat Jan 26, 2013 3:50 am

Thank you for the quite reply.
However, I did not see this function in the ADS1X15 library that I downloaded from https://github.com/adafruit/Adafruit_ADS1X15. Is there a newer version?
ptc
 
Posts: 3
Joined: Sat Dec 15, 2012 6:03 pm

Re: ADS_1115 sampling rate

by adafruit_support_bill on Sat Jan 26, 2013 8:15 am

Can you post the sketch you are using?
User avatar
adafruit_support_bill
 
Posts: 30872
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS_1115 sampling rate

by ptc on Sat Jan 26, 2013 2:11 pm

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <Adafruit_ADS1015.h>
 
Adafruit_ADS1115 ads1115;

void setup(void)
{
  Serial.begin(115200);
  Serial.println("Hello!");
 
  Serial.println("Getting single-ended readings from AIN0..3");
  Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV)");
  ads1115.begin();
}
 
void loop(void)
{
  int16_t adc0, adc1, adc2, adc3;
    adc0 = ads1115.readADC_SingleEnded(0);
    adc1 = ads1115.readADC_SingleEnded(1);
    adc2 = ads1115.readADC_SingleEnded(2);
    Serial.print(millis());
    Serial.print(",");
    Serial.print(adc0);
    Serial.print(",");
    Serial.print(adc1);
    Serial.print(",");
    Serial.print(adc2);
    Serial.println(",");
}
ptc
 
Posts: 3
Joined: Sat Dec 15, 2012 6:03 pm

Re: ADS_1115 sampling rate

by adafruit_support_bill on Sat Jan 26, 2013 5:39 pm

You have about 18mS worth of serial printing in your loop. That will slow things down a bit.
User avatar
adafruit_support_bill
 
Posts: 30872
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS_1115 sampling rate

by retrolefty on Sat Feb 02, 2013 12:56 pm

adafruit_support wrote:You have about 18mS worth of serial printing in your loop. That will slow things down a bit.


Even with the fully buffered interrupt driven serial transmission that the arduino hardware serial now has?

Lefty
retrolefty
 
Posts: 15
Joined: Tue Feb 17, 2009 10:28 pm

Re: ADS_1115 sampling rate

by zaman on Tue Sep 17, 2013 5:23 pm

Hi, It looks like this post is really old but I am having a similar problem. I am using arduino and the Adafruit_ADS1X15 library. I am getting around around 100hz if reading from 1 channel, and 33hz if reading 4 channels(or 130Hz). My goal is to get 200hz and reading 4 channels or 800 samples per second total. I have posted this on the arduino boards as well and it looks the same here that when people post this question everyone gets hung up on the serial print time. I don't buy and it and these rates are for the following code(the 4 channel situation is the same just add 3 more single ended reads from each channel). Now obviously I'm going to add more to this but this is just a proof of sampling rate. I did this as well without the single read and the serial.println(millis()); takes about .5ms or 2000hz.
Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads1115;

void setup(void)
{
  Serial.begin(115200);
  ads1115.setGain(GAIN_TWO);
  ads1115.begin();
}

void loop(void)
{
  ads1115.readADC_SingleEnded(0));
  Serial.println(millis());
}
 
zaman
 
Posts: 8
Joined: Tue Sep 17, 2013 5:07 pm