Any way to get a uint16 returned from ADS1115?

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rbardsley
 
Posts: 62
Joined: Fri Jan 06, 2012 11:09 am

Any way to get a uint16 returned from ADS1115?

Post by rbardsley »

I am using an ADS1115 to measure a signal that goes from 0 VDC to +4 VDC. I have been experimenting with the programmable gain on the ADS1115, but had a question about trying to use the full range of an unsigned 16-bit integer (0-65,535). I know my voltage will never be negative. I know it will never be higher than 4 VDC. So, can I use the gain setting of:

Code: Select all

ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
to get the highest resolution within a known range? Right now, my signal is saturating at 32767 counts, so I know it is a number type issue.

Is there a way to modify the library to ignore the sign and just return a value of 0 - 65535 corresponding with 0 - 4 VDC?

Many thanks,

Ryan

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Any way to get a uint16 returned from ADS1115?

Post by adafruit_support_bill »

To get the full 16 bit resolution from the device, you need to use differential mode. Connecting your signal to channels A0 and A1, it will give you positive values when A1 is higher than A0 and negative values when A0 is higher than A1. Since your signal is 0v-4v, you can achieve this by creating a 2v reference voltage and connecting it to A0, then connect your 0v-4v signal to A1. Then set the gain to GAIN_TWO. That will give you readings of -2v to +2v. Just add 2v to that to get your 0v-4v range.

User avatar
rbardsley
 
Posts: 62
Joined: Fri Jan 06, 2012 11:09 am

Re: Any way to get a uint16 returned from ADS1115?

Post by rbardsley »

Perfect! Thanks for the quick reply.

User avatar
Paul_L_
 
Posts: 28
Joined: Fri Nov 07, 2014 6:16 pm

Re: Any way to get a uint16 returned from ADS1115?

Post by Paul_L_ »

rbardsley,

Were you able to complete your objective and if so can you share the details?

Thanks,
Paul

User avatar
rbardsley
 
Posts: 62
Joined: Fri Jan 06, 2012 11:09 am

Re: Any way to get a uint16 returned from ADS1115?

Post by rbardsley »

Hi Paul,

Sorry for not seeing this earlier. Yes, I did get things to work properly. The key is really to map out the highs and lows of your signal voltages and design around that, both in code and hardware. My new sensor outputs a signal between 0-5VDC. I am using a voltage reference that outputs 2.5VDC and have that connected to ADC1 and my sensor output to ADC0. I have the ADS1115 set to operate with a gain of ONE so that I don't blow the chip. I wish there was a way I could use the GAIN_TWO setting, but I don't have a voltage reference that works well enough at 2VDC to allow me to limit the max voltage from my sensor to 4VDC.

Basically, take the high and low of your sensor output, find a gain that can accommodate the full swing of voltage (e.g. GAIN_ONE gives me ~8V which is more than the 5V max I'll be sending. GAIN_TWO would only allow 4V and would damage the chip), and then design a circuit or select a component to provide a voltage in between your high and low sensor output voltages.

Then you get to do math in code to make the number more usable.

Does that help? Happy to answer any questions. Two years later and I am still working on this project. In fact, it's connected to my laptop now collecting data!

User avatar
Paul_L_
 
Posts: 28
Joined: Fri Nov 07, 2014 6:16 pm

Re: Any way to get a uint16 returned from ADS1115?

Post by Paul_L_ »

Hi Ryan,

Thanks for your reply. Great to hear that this is possible.
I'd set this aside while working on another aspect, but will be applying this in about a week, and probably with questions. One right now is what are you using for your 2.5V reference? I haven't found a 2.5V yet. You might be interested in the Adafruit breakout; Precision LM4040 Voltage Reference Breakout - 2.048V and 4.096V PRODUCT ID: 2200.

Regarding gain, I'd done some sleuthing and found these forum topics. If I understand correctly, you can't break the ADS1115 with a Gain setting. You can break it with input voltages outside of the range -0.3 to +5.3 .
viewtopic.php?f=19&t=65300 (this includes a link to a TI forum answer)
viewtopic.php?f=25&t=50763
viewtopic.php?f=22&t=64040

Paul

User avatar
rbardsley
 
Posts: 62
Joined: Fri Jan 06, 2012 11:09 am

Re: Any way to get a uint16 returned from ADS1115?

Post by rbardsley »

Hi Paul,

I had just ordered the LM4040 from Adafruit and got it on Friday. I'll be hooking that up tomorrow. It is the surface mount version of the 2.048V reference I was using.

For a 2.5V reference, I use the Maxim MAX6325CPA which has awesome temp stability. I use the 5V version to power my ADS1115 actually. They are super sensitive to temperature fluctuations and my device needs to be very stable. I found that my readings were drifting as the device warmed up, but that went away when powering the ADS1115 from a MAX6350CPA. Not a cheap way of doing it, but simple and really stable.

Let me know if you need help next week.

User avatar
rbardsley
 
Posts: 62
Joined: Fri Jan 06, 2012 11:09 am

Re: Any way to get a uint16 returned from ADS1115?

Post by rbardsley »

I did a quick run in my thermocycler using the LM4040 from Adafruit and managed to get a good cubic fit that can be used for temperature compensation if you have it hooked up to an ADS1115. I used the following equation to flatten out the drift due to temperature changes from 110F to 47F. Try this:

Code: Select all

cubic = diff01 - (-1.7051)*tempC - 0.0035705*pow(tempC,2) - 0.00015451*pow(tempC,3);
The original output from the LM4040 can be seen in green at the bottom. You can see that it changes as the temperature changes (line in blue). However, you would really need to test all of your components in a similar chamber, but if you are using an ADS1115 running off of the output of a MAX6350CPA doing a differential measurement of your signal line vs. the output from the LM4040, this is a good equation to start with. See how nice and flat the response curve is (red) in the graph below? I am happy with it! This has been a long time in the making.

Let me know if it works for anyone.

Image

Best,

Ryan

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”