ADS1015 - Continuous conversion mode

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
achille70
 
Posts: 2
Joined: Thu Mar 07, 2013 9:02 am

ADS1015 - Continuous conversion mode

Post by achille70 »

Hi all,

I'm new in this forum, and relatively new in electronic projects at all, so please excuse me if my question could be ingenuous.

I've bought an ADS1015 Adafruit breakout board and I'm performing some experimets with it, using the Python library for Raspberry PI.

My proble is that I would like to perfomr some "continuous mode" conversion, capturing a signal segment for a certain time (let's say 1 second), putting the values readed in an array of samples.

Can someone explain me:
1. how to set the chip register to perfomr this task?
2. which condition should I test to know when a new value is available in the conversion register?

Thanks a lot for your help!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: ADS1015 - Continuous conversion mode

Post by adafruit_support_rick »

I don't know. Unless somebody else can chime in with specific instructions, I'm afraid you're going to be stuck reading the datasheet. :(

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADS1015 - Continuous conversion mode

Post by adafruit_support_mike »

It's possible to do what you want, but the programming won't be trivial.

The Adafruit python library (http://github.com/adafruit/Adafruit-Ras ... it_ADS1x15) has all the constants necessary to run the chip in any of its several modes, but only seems to have one function to actually take readings.. and that uses single-conversion mode.

The C++ library (http://github.com/adafruit/Adafruit_ADS ... DS1015.cpp) has more options, including a function that tells the chip to operate in continuous-conversion mode and set a flag when the input crosses a certain threshold ( Adafruit_ADS1015::startComparator_SingleEnded() ).

Converting that to python would take a bit of work. Changing the flags to do continuous readings without having the comparator set a flag would take some more work.

The actual information you need is mostly on pages 15 and 16 of the datasheet: http://adafruit.com/datasheets/ads1015.pdf

To start the ADC in continuous-conversion mode, you need to set the configuration register's MODE bit to 0. The values for the other bits in that register depend on how you want to multiplex the inputs and how much gain you want.

Reading data is fairly easy in continuous-conversion mode. You can do it at any time, and the conversion register always holds the results of the most recently completed conversion.

Talking to the chip is a two-step process. First you need to tell it which of the four internal registers you want to work with, then you send the read or write command you want to execute. The rough sequence of operations you want is:

- Tell the chip you want to work with the configuration register

- Send the chip a Write command with the value you want to store in the configuration register. For continuous-conversion mode, the lowest bit of that byte should be 0.

- Tell the chip you want to work with the conversion register

- Send the chip a Read command every time you want another reading.

achille70
 
Posts: 2
Joined: Thu Mar 07, 2013 9:02 am

Re: ADS1015 - Continuous conversion mode

Post by achille70 »

[email protected] wrote:It's possible to do what you want, but the programming won't be trivial.
ok, i'm working on the library.
I need an explaination. I test the CONFIG register to know ewhen the conversion i s complete, checking the following bits:

__ADS1015_REG_CONFIG_OS_MASK = 0x8000
__ADS1015_REG_CONFIG_OS_BUSY = 0x0000 # Read: Bit = 0 when conversion is in progress
__ADS1015_REG_CONFIG_OS_NOTBUSY = 0x8000 # Read: Bit = 1 when device is not performing a conversion

I read the content of the CONFIG register, shift the first nyte of 8 bits, and add in OR the second byte.
After this i perform an AND with __ADS1015_REG_CONFIG_OS_MASK

I should expect thatthe result could be:
1) __ADS1015_REG_CONFIG_OS_BUSY when a conversion is in progress
2) __ADS1015_REG_CONFIG_OS_NOTBUSY when no conversion is in progress

I have to wait until the conversion is complete before readinh the content of CONVERSION register, right?
Instead the test returns alALWAYS the __ADS1015_REG_CONFIG_OS_BUSY result, and never turns to NOTBUSY, so i cannot know when take the result of a conversion.

How can I know when is the correct moment to take the result for a certain conversion?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADS1015 - Continuous conversion mode

Post by adafruit_support_mike »

If you're doing continuous conversion, you don't have to check that bit. The results of the most recent conversion are always available in the conversion register.

If you're using the I2C library and sending the commands yourself, have you sent __ADS1015_REG_CONFIG_OS_SINGLE to the chip to start the conversion?

The ADS1015's single-conversion process start with the chip in a low-power shutdown state. You send an I2C Write command that stores the settings you want in the configuration register, and which includes __ADS1015_REG_CONFIG_OS_SINGLE. That's actually the same bit you test to see when the conversion is done, the symbol just gives it a name that's (slightly) easier to understand.

When the chip wakes up, it looks at the CONFIG_OS bit in its configuration register. If that bit is HIGH, the chip sets it LOW and starts a conversion. When the conversion is done, the chip stores the result of the conversion in the conversion register, sets the CONFIG_OS bit HIGH again, and goes back into its low-power shutdown state.

You have to wite that bit before the conversion will start though.

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

Return to “Other Products from Adafruit”