Hello,
while trying to set the configuration register of the ADS1115,
when smbus2 library is used:
from smbus2 import SMBus
import time
with SMBus(1) as bus:
data = 0b0100001010000100
#config = data | (data >> 5) & 0x111
#config = (data << 8) | (data >> 8)
#data = 0x
bus.write_word_data(0x48,1,data)
with SMBus(1) as bus:
#time.sleep(1)
block = bus.read_word_data(0x48,1)
print(block)
the configuration register is not set correctly. Every bit of the register is fine except for the 3 bits responsible for change in data rate of the adc (bits 7:5). These three bits are somehow dependant on the lsb (bit 0 in data sheet of ads1115) and bit 8 of the register. When bit 8 is set to 1, the change in data rate bits is seen effectively but if the bit 8 is 0, then changes made to data rate bits is not reflected correctly in the configuration register. Likewise with bit 0, this behaviour is observed.
With adafruit_ads1x15 library:
import adafruit_ads1x15.ads1115 as ADS
from adafruit_extended_bus import ExtendedI2C as I2C
i2c = I2C(1)
ads = ADS.ADS1115(i2c, gain=1)
ads._write_register(1, value=0b0100001011100100)
data_read = ads._read_register(1)
print(data_read)
the change in bits of the configuration register is reflected perfectly. What is the point that is missed with the smbus2 library approach. Any help or suggestion is much appreciated. Thank you in advance.
while trying to set the configuration register of the ADS1115,
when smbus2 library is used:
from smbus2 import SMBus
import time
with SMBus(1) as bus:
data = 0b0100001010000100
#config = data | (data >> 5) & 0x111
#config = (data << 8) | (data >> 8)
#data = 0x
bus.write_word_data(0x48,1,data)
with SMBus(1) as bus:
#time.sleep(1)
block = bus.read_word_data(0x48,1)
print(block)
the configuration register is not set correctly. Every bit of the register is fine except for the 3 bits responsible for change in data rate of the adc (bits 7:5). These three bits are somehow dependant on the lsb (bit 0 in data sheet of ads1115) and bit 8 of the register. When bit 8 is set to 1, the change in data rate bits is seen effectively but if the bit 8 is 0, then changes made to data rate bits is not reflected correctly in the configuration register. Likewise with bit 0, this behaviour is observed.
With adafruit_ads1x15 library:
import adafruit_ads1x15.ads1115 as ADS
from adafruit_extended_bus import ExtendedI2C as I2C
i2c = I2C(1)
ads = ADS.ADS1115(i2c, gain=1)
ads._write_register(1, value=0b0100001011100100)
data_read = ads._read_register(1)
print(data_read)
the change in bits of the configuration register is reflected perfectly. What is the point that is missed with the smbus2 library approach. Any help or suggestion is much appreciated. Thank you in advance.
Statistics: Posted by Ananya — Thu Jul 25, 2024 2:35 pm — Replies 1 — Views 38