Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

ADS1115 and Arduino Due reading wrong channels
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ADS1115 and Arduino Due reading wrong channels

by colemanautosports on Thu May 22, 2014 11:16 am

I am having a peculiar problem when i try to use the ADS1115 16bit breakout with my Arduino Due.
I am using Arduino IDE 1.5.6-r2 with a copy of the Adafruit ads1115 library from a few days ago. I am using the example single ended sketch.
Everything works normally with the same hardware and code one my Arduino Mega from the 1.5.6-r2 IDE and from the old 1.0.5 IDE.
However, whenever i upload to the the Due (after, of course, selecting the due from board menu) it has the problems listed below:

the A0 read is duplicated to the output of A0 and A1
the A2 read shows the reading from what is connected to the A1 pin on the board
the A3 read shows the reading from the A2 pin on the board

For example with two separate potentiometers connected to pins A0 and A1 the output (in volts instead of counts) is as follows:

A0=2.36
A1 =2.36
A2 =1.12
A3 =0

A0 and A1 change together with pot 1
A2 changes with Pot2 even though it is connected to input A1

Has any one else experienced this or can duplicate it? Is it possibly a problem with the library on the due processor?
I have two of the ads1115 breakout boards and both act the same when connected to the Due but everything is fine on the Mega...

------------------------------------------------------------

I am also curious how to configure the data rate from 8sps to 860sps. I could not find out how to change that from the documentation.

The Jeff Rowberg library has a function for changing sample rate:
adc.setRate(ADS1115_RATE_860); // 860 samples per second

However, i was unsure how to do that for the Adafruit library.

I appreciate all the work Adafruit does to make these breakout boards so easy to use!



Code Below:
-------------------------------------------------------------------------------------------------


#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("ADS1015 (12bit)ADC Range: +/- 6.144V (1 bit = 3mV)");
Serial.println("ADS1115 (16bit) ADC Range: +/- 6.144V (1 bit = 188uV or .000188 V)");
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);
adc3 = ads1115.readADC_SingleEnded(3);
Serial.print("AIN0: "); Serial.println(adc0);
Serial.print("AIN1: "); Serial.println(adc1);
Serial.print("AIN2: "); Serial.println(adc2);
Serial.print("AIN3: "); Serial.println(adc3);
Serial.println(" ");

Serial.print("AIN0 Volts: "); Serial.println(adc0*.000188);
Serial.print("AIN1 Volts: "); Serial.println(adc1*.000188);
Serial.print("AIN2 Volts: "); Serial.println(adc2*.000188);
Serial.print("AIN3 Volts: "); Serial.println(adc3*.000188);

delay(500);
}

colemanautosports
 
Posts: 4
Joined: Tue Sep 18, 2012 6:10 pm

Re: ADS1115 and Arduino Due reading wrong channels

by adafruit_support_mike on Thu May 22, 2014 4:42 pm

The 'duplication of inputs' issue sounds like you're asking the chip for readings faster than it can collect them. Make sure you have at least one sampling period's worth of delay between calls from the Due.

adafruit_support_mike
 
Posts: 63805
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADS1115 and Arduino Due reading wrong channels

by colemanautosports on Thu May 22, 2014 5:16 pm

Good suggestion.
That will be a good avenue to explore to see if it is getting choked up between channel reads.
The Adafruit description says the chip is configurable from 8 samples/sec to 860 samples/sec.
How do i reconfigure the chips sample rate to the full 860hz?

colemanautosports
 
Posts: 4
Joined: Tue Sep 18, 2012 6:10 pm

Re: ADS1115 and Arduino Due reading wrong channels

by antoniob on Thu Jun 05, 2014 5:38 am

I recently posted that I had issues with the library and examples. I'm using a uC32 ChipKIT board. I've finally managed to get it working. A combination of hardware (analog) and some digital. Now I have the exact same problem that has been described. A0 and A1 readings are duplicated (A0 result), A2 shows result from A1, and A3 shows nothing. As far as I can see (please correct me if I'm way off the mark here) one thing that can be tried is to change the "conversionDelay" value in Adafruit_ADS1015.h.

This i'll be trying first thing in the morning.

Cheers all.

antoniob
 
Posts: 30
Joined: Tue Jul 09, 2013 2:47 am

Re: ADS1115 and Arduino Due reading wrong channels

by colemanautosports on Thu Jun 05, 2014 10:59 am

Antoniob,

You hit the nail on the head. After some experimentation i found that if you increase the "conversion delay" from 8ms to 9ms in the ADS1015.h file line 39 then everything reads correctly on the DUE. The default sample rate for this chip is 128hz which is about 7.8ms per sample...... hence the 8ms delay in the library. I would have expected the Due to require less delay time than the uno and mega chips and do not have a good answer for why this is necessary. Maybe an Adafruit professional can chime in

My current issue is that the necessary 9ms conversion delay is slowing my code down way too much. I can live with it when i only do one or two single ended channel reads but any more than that and i will start loosing data from my 20hz (50ms / sample) GPS. I need someone at Adafruit to point me in the right direction to change the ADS1115 sample rate from the default rate of 128hz to the max of 860hz.

There is also the Jeff Rowberg Library for the ADS1115. I have not experimented with it on hardware yet but it seems promising because it is specifically for the ADS1115 and it has an easy setup to change to the full 860hz :

https://github.com/jrowberg/i2cdevlib/t ... no/ADS1115

-Cheers
Clay

colemanautosports
 
Posts: 4
Joined: Tue Sep 18, 2012 6:10 pm

Re: ADS1115 and Arduino Due reading wrong channels

by adafruit_support_mike on Thu Jun 05, 2014 6:33 pm

ColemanAutosports wrote:I would have expected the Due to require less delay time than the uno and mega chips and do not have a good answer for why this is necessary. Maybe an Adafruit professional can chime in

The conversion time depends on the circuit inside the ADS1115. The speed of the microcontroller talking to it doesn't matter.

The header for the ADS11x5 library has a list of values you can use to set different sampling rates:

Code: Select all | TOGGLE FULL SIZE
    #define ADS1015_REG_CONFIG_DR_MASK      (0x00E0) 
    #define ADS1015_REG_CONFIG_DR_128SPS    (0x0000)  // 128 samples per second
    #define ADS1015_REG_CONFIG_DR_250SPS    (0x0020)  // 250 samples per second
    #define ADS1015_REG_CONFIG_DR_490SPS    (0x0040)  // 490 samples per second
    #define ADS1015_REG_CONFIG_DR_920SPS    (0x0060)  // 920 samples per second
    #define ADS1015_REG_CONFIG_DR_1600SPS   (0x0080)  // 1600 samples per second (default)
    #define ADS1015_REG_CONFIG_DR_2400SPS   (0x00A0)  // 2400 samples per second
    #define ADS1015_REG_CONFIG_DR_3300SPS   (0x00C0)  // 3300 samples per second

adafruit_support_mike
 
Posts: 63805
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADS1115 and Arduino Due reading wrong channels

by colemanautosports on Fri Jun 06, 2014 12:30 pm

Thanks Mike,

I was commenting more on it being confusing why you have to increase the delay time in the library header file (from 8ms to 9 ms) for the faster 32bit processors to read the channels properly.

I suspect Antoniob was having the same problem as me because we are both using 32bit processors that are about 80MHz.



I spent several hours again last night troubleshooting and the Jeff Rowberg library has similar results as the Adafruit library when running on a DUE.
If you connect a pots to A0, A1, A2, A3 then the pot connected to A1 is actually displaying on the A0 read.

I also tried including the "ADS1015_REG_CONFIG_DR_3300SPS;" command and unfortunately, it did not affect my outcome.

I would challenge someone to hook an ADS1115 (16bit) to four potentiometers and Arduino Due. Then, take all four AV readings faster than 100hz (10ms).
I have not been able to figure out how to do it.

Hopefully someone smarter than I can help.

colemanautosports
 
Posts: 4
Joined: Tue Sep 18, 2012 6:10 pm

Re: ADS1115 and Arduino Due reading wrong channels

by adafruit_support_mike on Tue Jun 10, 2014 5:32 pm

All timing-based code ultimately boils down to counting. Either you busy-wait by sitting in a loop that does NOPs, or you set a counter value that's compared to ticks of the clock.

In both cases, the amount of time associated with a given limit number depends on the speed of the CPU. An 8MHz CPU has to wait eight ticks to make a microsecond delay, while an 80MHz CPU has to wait eighty.

Depending on the way your delay is coded, you may need to increase the count to compensate for the faster processor.

adafruit_support_mike
 
Posts: 63805
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADS1115 and Arduino Due reading wrong channels

by antoniob on Wed Aug 27, 2014 10:40 am

After several weeks away I came back to the issue being discussed. In digging through the adafruit code and the rowberg code I've come to the conclusion that there is no simple answer. I've found that the following seems to work for my setup (chipKIT uC32) and have had no issues;

/*==========================================================*/
CONVERSION DELAY (in mS)
-----------------------------------------------------------------------*/
#define ADS1015_CONVERSIONDELAY (6) // fix for ChipKIT
#define ADS1115_CONVERSIONDELAY (8)
/*==========================================================*/

Thanks to all for their assistance

antoniob
 
Posts: 30
Joined: Tue Jul 09, 2013 2:47 am

Re: ADS1115 and Arduino Due reading wrong channels

by vkeeranagi on Tue Jun 05, 2018 12:14 am

Hi Guys,

I read your forum. I too am using the ADS1115 for one of my project. I am able to read ADC value for 3.2-3.5 volts which is 16657. However when I provide input voltage lower den 3.2 volts it gives digital reading as 354 which seems to be weird from 0-3.2 Volts. Any suggestion on this issue.

Thanks in advance.

vkeeranagi
 
Posts: 3
Joined: Fri Jun 01, 2018 6:17 am

Please be positive and constructive with your questions and comments.