Commit e65d7190 authored by Arnaud WATLET's avatar Arnaud WATLET
Browse files

Adds MUX board 2024 capability

No related merge requests found
Showing with 14 additions and 13 deletions
+14 -13
......@@ -9,9 +9,9 @@ import os
mux_board_version = '2024.0.0'
mux_addressing_table_file = "compiled_mux_addressing_table.csv"
mux_addressing_table_file = os.path.join(mux_board_version,"relay_board_32",mux_addressing_table_file)
#mux_addressing_table_file = os.path.join("MUX_board",mux_board_version,"relay_board_32",mux_addressing_table_file)
electrode_nr = 1
electrode_nr = "1"
role = "A"
# state = on
......@@ -20,9 +20,10 @@ with open(mux_addressing_table_file, 'r') as myfile:
mux_addressing_table = np.genfromtxt(mux_addressing_table_file, dtype=str,
delimiter=',', skip_header=1, )
mux_addressing_table = {header[k]: mux_addressing_table.T[k] for k in range(len(header))}
print(mux_addressing_table)
def set_relay_state(mcp, mcp_pin, state=True):
print(mcp,mcp_gpio)
pin_enable = mcp.get_pin(mcp_pin)
pin_enable.direction = Direction.OUTPUT
pin_enable.value = state
......@@ -31,16 +32,16 @@ i2c = busio.I2C(board.SCL, board.SDA)
idx = np.where((mux_addressing_table['Electrode_id'] == electrode_nr) & (mux_addressing_table['Role'] == role))[0]
tca_addr = mux_addressing_table['TCA_address'][idx][0]
tca_channel = mux_addressing_table['TCA_channel'][idx][0]
mcp_gpio = mux_addressing_table['MCP_GPIO'][idx][0]
mcp_gpio = int(mux_addressing_table['MCP_GPIO'][idx][0])
if tca_addr is None:
tca = i2c
else:
tca = adafruit_tca9548a.TCA9548A(i2c, role)
#tca = adafruit_tca9548a.TCA9548A(i2c, hex(int(tca_addr, 16)))[tca_channel]
tca = i2c
mcp_addr = hex(int(mux_addressing_table['MCP_address'][idx][0], 16))
MCP23017(tca, address=mcp_addr)
mcp_addr = int(mux_addressing_table['MCP_address'][idx][0], 16)
mcp = MCP23017(tca, address=mcp_addr)
set_relay_state(mcp_addr,mcp_gpio, True)
set_relay_state(mcp,mcp_gpio, True)
time.sleep(2)
set_relay_state(mcp_addr,mcp_gpio, True)
\ No newline at end of file
set_relay_state(mcp,mcp_gpio, False)
......@@ -1337,13 +1337,13 @@ class OhmPi(object):
tca = self.i2c
else:
tca = adafruit_tca9548a.TCA9548A(self.i2c, self.board_addresses[role])
tca = adafruit_tca9548a.TCA9548A(self.i2c, hex(int(tca_addr,16)))[tca_channel]
mcp_addr = hex(int(mux_addressing_table['MCP_address'][idx][0], 16))
MCP23017(tca, address=mcp_addr)
tca = adafruit_tca9548a.TCA9548A(self.i2c, int(tca_addr,16))[tca_channel]
mcp_addr = int(mux_addressing_table['MCP_address'][idx][0], 16)
mcp = MCP23017(tca, address=mcp_addr)
if state == 'on':
set_relay_state(mcp_addr, mcp_gpio, True)
set_relay_state(mcp, mcp_gpio, True)
if state == 'off':
set_relay_state(mcp_addr, mcp_gpio, False)
set_relay_state(mcp, mcp_gpio, False)
else:
self.exec_logger.warning('MUX board version not recognized')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment