Pages: [1]   Go Down
 Author Topic: ADS1114 convert bi-directional output to positive  (Read 636 times) 0 Members and 1 Guest are viewing this topic.
Offline
Full Member
Karma: 2
Posts: 106
 « on: March 31, 2013, 11:53:17 pm » Bigger Smaller Reset

Hi. Another question in my quest to learn.
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?
 Logged

East Anglia (UK)
Online
Karma: 108
Posts: 4016
 « Reply #1 on: April 01, 2013, 02:02:16 am » Bigger Smaller Reset

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.
 Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline
Full Member
Karma: 2
Posts: 106
 « Reply #2 on: April 01, 2013, 09:33:23 am » Bigger Smaller Reset

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

0
Offline
Newbie
Karma: 0
Posts: 27
Arduino rocks
 « Reply #3 on: April 01, 2013, 09:48:00 am » Bigger Smaller Reset

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"
 Logged

Left Coast, CA (USA)
Offline
Brattain Member
Karma: 361
Posts: 17259
Measurement changes behavior
 « Reply #4 on: April 01, 2013, 10:27:51 am » Bigger Smaller Reset

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
 « Last Edit: April 01, 2013, 10:29:32 am by retrolefty » Logged

Offline
Full Member
Karma: 2
Posts: 106
 « Reply #5 on: April 01, 2013, 11:32:53 pm » Bigger Smaller Reset

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.
 Logged

Left Coast, CA (USA)
Offline
Brattain Member
Karma: 361
Posts: 17259
Measurement changes behavior
 « Reply #6 on: April 02, 2013, 01:16:14 am » Bigger Smaller Reset

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
 Logged

Offline
Full Member
Karma: 2
Posts: 106
 « Reply #7 on: April 03, 2013, 01:56:08 pm » Bigger Smaller Reset

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.
Much appreciated.
 Logged

Left Coast, CA (USA)
Offline
Brattain Member
Karma: 361
Posts: 17259
Measurement changes behavior
 « Reply #8 on: April 03, 2013, 02:01:59 pm » Bigger Smaller Reset

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.