diff --git a/check_adc_lock.py b/check_adc_lock.py index 7e85a592e23d05104fda019d4c9005c4c499cc83..97eec85eccd9d45ddd262f5557d59fa2dcf72e3b 100644 --- a/check_adc_lock.py +++ b/check_adc_lock.py @@ -41,8 +41,7 @@ def Read_byte_ADC(ADC_reg_address, ADC_bytes=0, ADC_NR = 0, ADDRESS=0x20 ): # # Read Byte from the ADC # - I2C_device = I2C(ADDRESS) - I2C_device.bus = I2CBUSNR + I2C_device = I2C(ADDRESS, , BUSNR=I2CBUSNR) ADC_rw = 0x01 # 0 for write, 1 for read stri = "Read ADC from Address {:8x}".format(ADC_reg_address) diff --git a/set_adc.py b/set_adc.py index ec48ff0af65d7a4d64cf18d0704b5e735a8808e9..e8f8a1cc6d259376887d1a0a1b52fcc2fa914954 100644 --- a/set_adc.py +++ b/set_adc.py @@ -23,6 +23,7 @@ if os.name =="posix": else: from I2C_serial import * +I2CBUSNR=1 sleep_time=0.05 CHECK_I2C_DEVICES = False WRITE_DATA = True @@ -40,7 +41,7 @@ ADC_ORDER = [0, 1, 2] def blink_led(address=0x76, times = 5): print("Blink LED") - I2C_device = I2C(address) + I2C_device = I2C(address, BUSNR=I2CBUSNR) I2C_device.write_bytes(0x06, 00) I2C_device.write_bytes(0x07, 00) for cnt in range(times): @@ -55,7 +56,7 @@ def Write_byte_ADC(ADC_reg_address, ADC_data, ADC_bytes=1, ADC_NR = 0, ADDRESS=0 # # Write Byte to the ADC # - I2C_device = I2C(ADDRESS) + I2C_device = I2C(ADDRESS, BUSNR=I2CBUSNR) ADC_rw = 0x00 # 0 for write, 1 for read stri = "Write : {0:2x} to Address : {1:2x}".format(ADC_data, ADC_reg_address) print(stri) @@ -86,7 +87,7 @@ def Read_byte_ADC(ADC_reg_address, ADC_bytes=0, ADC_NR = 0, ADDRESS=0x20 ): # # Read Byte from the ADC # - I2C_device = I2C(ADDRESS) + I2C_device = I2C(ADDRESS, BUSNR=I2CBUSNR) ADC_rw = 0x01 # 0 for write, 1 for read stri = "Read ADC from Address {:8x}".format(ADC_reg_address) @@ -132,7 +133,7 @@ def rcu_sensors(): addr = 0x14 Vref = 3.3 one_step = Vref/(2**(16+1)) - I2C_device = I2C(addr) + I2C_device = I2C(addr, BUSNR=I2CBUSNR) I2C_device.write_bytes(0xB8, 0xB0) sleep(1) ret_ack, ret_value = I2C_device.read_last_reg(3) @@ -165,7 +166,7 @@ def rcu_sensors(): def rw_eeprom(value=0xAB): ADDR = 0x50 - I2C_eeprom = I2C(0x53) + I2C_eeprom = I2C(0x53, BUSNR=I2CBUSNR) I2C_eeprom.write_bytes(0x00, value) I2C_eeprom.write_pointer(0x00) ret_ack, ret_value = I2C_eeprom.read_last_reg(1) @@ -177,7 +178,7 @@ def rw_eeprom(value=0xAB): def power(state): ADDRESS_IO = 0x76 - I2C_IO_device = I2C(ADDRESS_IO) + I2C_IO_device = I2C(ADDRESS_IO, BUSNR=I2CBUSNR) I2C_IO_device.write_bytes(0x06, 00) if state=='ON': print("Switch ON") @@ -212,7 +213,7 @@ def set_gain(gain, channel): else: set_gain = max_gain-min_gain bits_to_set = set_gain - I2C_IO_device = I2C(ADDRESS_IO) + I2C_IO_device = I2C(ADDRESS_IO, BUSNR=I2CBUSNR) I2C_IO_device.write_bytes(0x06, 00) I2C_IO_device.write_bytes(0x07, 00) if channel == 0: