ADS1114 convert bi-directional output to positive

Hi. Another question in my quest to learn.
I am using an ADS1114 16 bit a/d converter and the Adafruit ADS1115 library

although I suppose this is common with many ADC's.
My sensor has a total output from 0.3v to 1.4v so only approx 1v full scale.
The ads1114 is giving me approximately -6000 to 6000 as an output which is about right I guess, 12000 counts for a 1v input.

My question is how do convert the input into a positive ONLY value in the most efficient way for processing time. I know i could just add 7000 to the value and always have it positive but I am sure there is a more efficient way done by the pro's?

Adding an offset seems like a perfectly reasonable thing to do, but you could also consider using the map() function to shift the values to another range and scale them at the same time if you wanted to.

Great, Thanks
I think the problem with Mapping is that the beginning and end values are not always the same from sensor to sensor.

that should not be a problem. You can make a different map function for every sensor. on the other hand, sensors measured with an arduino are usually not that precize to begin with.

if i'm not mistaking the map function is used as this:

your_var map(0,6000,0,5);

the first zero is the lowest value received from the sensor
6000 is the max value
next zero is the minimum value you want to get
and 5 is the maximum value (voltage)

if you want the voltage to be displayed with 2 numbers behing the comma, use "float" before "your_var"

There might be a better way. When you set the configuration word for the ADS1114, that determines if you are going to use two input pins as a differential pair (thus allowing for the possibilities of - and + value digital conversions, or you can set it for single input mode channels and only positive values will be converted from a single input pin.

Note that the ADS1114 as with most/many external ADC modules does not read true (relative to the chip's ground pin) negative voltages but rather the difference between two positive values on the the two input pins if run in differential input mode. Thus the max positive digital value is when the + input is at +5vdc and the - input is at ground and the max digital negative value is when the + input is at ground and the - input is at +5vdc.

Lefty

Hmm something must be wrong then, because according to the adafruit library, the default mode is single shot, and my input is only to A0 and GND, so I am not using the differential, and my input range measured with a DVM is +0.3 to +1.4v, but I am getting a -6000 to +6000 output.
Maybe I misunderstand you.

Lsnyman:
Hmm something must be wrong then, because according to the adafruit library, the default mode is single shot, and my input is only to A0 and GND, so I am not using the differential, and my input range measured with a DVM is +0.3 to +1.4v, but I am getting a -6000 to +6000 output.
Maybe I misunderstand you.

I'm not sure what the adafruit library default configuration is. Why don't you just ground the A1 pin and see if your measurement values on A0 change or not. The datasheet is the best source for working with this chip series. This one covers the ADS1113/4/5 which vary in number of input channels supported and a few minor differences. They all handle the single ended/differential input the same way.

If you are getting negative digital values then something is wrong in either as the library code is being set up or in how your sketch is interpreting the results. Single ended input should only be able to return digital codes from 0x0000 to 0x7FFF (just 15 bits of positive range numbers) only in differential mode can the digital results vary the full 16 bit range of 0x0000 to 0xffff with 0x8000 to 0xffff being the negative portion of the range when using ANin0 and ANin1 in differential mode.

Datasheet:

Lefty

Yup, connecting A1 to GND now gives me a 4000 - 29000 count range for my 0.3 -1.4v input which is the expected 15-bits. This is good for me.
Thanks for your pointers.
Much appreciated.

Lsnyman:
Yup, connecting A1 to GND now gives me a 4000 - 29000 count range for my 0.3 -1.4v input which is the expected 15-bits. This is good for me.
Thanks for your pointers.
Much appreciated.

Your welcome.

This TI series of I2C ADCs are really a great product line with lots of features. Configurable gain, built in voltage reference, comparator functions, etc.

Lefty