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).
The debug function however, retuns all zeros. I’ve pointed to the other 3 channels and have the same result.
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
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
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
-
851.7 KB Views: 25