ADS1115 Quad AD converter blues

fernando_g

Senior Member
I’m experimenting with the ADS1115, which is a 4 channel, 16 bit, I2C ADC
The datasheet instructions indicate the following I2C structure to perform a read.

Write to Config register:
First byte: 0b10010000 (first 7-bit I2C address
Second byte: 0b00000001 (points to Config register)
Third byte: 0b10000100 (MSB of the Config register to be written)
Fourth byte: 0b10000011 (LSB of the Config register to be written)

Write to Pointer register:
First byte: 0b10010000 (first 7-bit I2C address to the device-specific product data sheet. followed by a low read/write bit)
Second byte: 0b00000000 (points to Conversion register)

Read Conversion register:
First byte: 0b10010001 (first 7-bit I2C address followed by a high read/write bit)
Second byte: the ADS1113/4/5 response with the MSB of the Conversion register.
Third byte: the ADS1113/4/5 response with the LSB of the Conversion register.
The following is how I implemented the code. I’m assuming that the first byte alluded on each step, (the device address), is taken care by the hi2csetup command line).

Code:
symbol chan0 = w0 
symbol temp_wd = w4
Symbol MSBy = b8
Symbol LSBy = b9

hi2csetup i2cmaster, %10010000, i2cfast_8, i2cbyte 'address with grounded address pin

 	main_read:
hi2cout 0,(%00000001,%11000010,%10000011)'Write Pointer reg, MSB, LSB (Configure AIN0)
hi2cout 0,(%00000000)	'Write conversion register 
hi2cin 0,(MSBy,LSBy)'Read MSB,LSB for chans 0
chan0 = temp_wd/16
debug
toggle C.0 'signal reading activity
goto main_read
The debug function however, retuns all zeros. I’ve pointed to the other 3 channels and have the same result.:confused:
And yes, I’ve checked all my voltages a couple of times, including that feeding the AD channel = 1.00 volt, decoupling, the pullup resistors, and the SDA, SCL signals with a scope.
Although I include the data sheet, I have a summary of the configuration register settings:

Pointer Register

%00000000 Conversion register
%00000001 Config register
%00000010 Lo-Tresh register
%00000011 Hi-Tresh register

Configuration registers
Bit [15] 0 : No effect 1 : Begin a single conversion (when in power-down mode)
Bits [14:12] 100 : AINP = AIN0 and AINN = GND
101 : AINP = AIN1 and AINN = GND
110 : AINP = AIN2 and AINN = GND
111 : AINP = AIN3 and AINN = GND
Bits [11:9] 001 : FS = 4.096V
Bit [8] 0 : Continuous conversion mode
Bits [7:5] 100 : 128SPS
Bits [4:0] xxx11: Disable comparator
 

Attachments

sniper887

Member
On all of your hi2cout commands, remove the 0, from the beginning. Having that means the Picaxe sends a 0 byte before the bytes you intend to send, and you won't get anything from the ADC.

A command should be like this:

Code:
hi2cout (%00000001,%11000010,%10000011)'Write Pointer reg, MSB, LSB (Configure AIN0)
 

fernando_g

Senior Member
Thanks, sniper!
Unfortunately for me, the Picaxe setup is in other place and I won't be able to try anything until tomorrow.

So until tomorrow, I'll make the changes and report back.
 

fernando_g

Senior Member
I implemented the suggested changes, and voila! it worked! Thanks.

There were some additional code errors, like adding a small delay between conversions to allow the results to be written to the conversion register.
When I've thoroughly debugged it, I will post it in the snippets section.
 

spheris

Senior Member
Hi,
Excuse me to up an old post but i need one answer.
I used your code for my application, the same as yours.
But how to adjust input gain? is it possible with picaxe?
For arduino, they add this line :
ads.setGain (GAIN_SIXTEEN); // 16x gain 1 bit = 0.0078125mV.
i want to have the same gain with picaxe.
Thanks for your answers.
;)
 

PhilHornby

Senior Member
I know nothing (at all!) about this hardware - but staring at Adafruit's ADS1x15 Arduino code (here and here), in conjunction with the remarks above
Code:
Bits [11:9]    001 : FS = 4.096V
leads me to conclude that since

GAIN_SIXTEEN => ADS1015_REG_CONFIG_PGA_0_256V, which in turn, is defined as
ADS1015_REG_CONFIG_PGA_0_256V (0x0A00) // +/-0.256V range = Gain 16

or in other words,

bits 11:9 of the CONFIG should be "101" (since 0x0A00 =1010 0000 0000)

I could be wrong :)
 
Top