From 02c00824d47d467795b03a8620bdabe9e7d5425c Mon Sep 17 00:00:00 2001 From: awatlet <arnaud.watlet@umons.ac.be> Date: Tue, 26 Sep 2023 10:28:09 +0200 Subject: [PATCH] Implements io on MUX --- configs/config_mb_2023_3_mux_2024.py | 3 ++- configs/config_mb_2023_4_mux_2023.py | 5 +++-- ohmpi/hardware_components/mux_2023_rev_0_0.py | 3 ++- ohmpi/hardware_components/mux_2024_rev_0_0.py | 9 +++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/configs/config_mb_2023_3_mux_2024.py b/configs/config_mb_2023_3_mux_2024.py index 680aba50..a4134e6d 100644 --- a/configs/config_mb_2023_3_mux_2024.py +++ b/configs/config_mb_2023_3_mux_2024.py @@ -63,7 +63,8 @@ HARDWARE_CONFIG = { 'cabling': {(i+24, j): ('mux_04', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'voltage_max': 12.} }, - 'default': {'voltage_max': 100., + 'default': {'connection': 'i2c', + 'voltage_max': 100., 'current_max': 3.} } } diff --git a/configs/config_mb_2023_4_mux_2023.py b/configs/config_mb_2023_4_mux_2023.py index 6546b118..0c0309a2 100644 --- a/configs/config_mb_2023_4_mux_2023.py +++ b/configs/config_mb_2023_4_mux_2023.py @@ -18,7 +18,7 @@ OHMPI_CONFIG = { } HARDWARE_CONFIG = { - 'ctl': {'model': 'raspberry_pi_i2c'}, + 'ctl': {'model': 'raspberry_pi'}, 'pwr': {'model': 'pwr_batt', 'voltage': 12.}, 'tx': {'model': 'ohmpi_card_3_15', 'mcp_board_address': 0x20, @@ -59,7 +59,8 @@ HARDWARE_CONFIG = { 'cabling': {(i, j): ('mux_4', i) for j in ['N'] for i in range(1, 65)}, 'voltage_max': 12.}, }, - 'default': {'voltage_max': 100., + 'default': {'connection': 'i2c', + 'voltage_max': 100., 'current_max': 3.} } } diff --git a/ohmpi/hardware_components/mux_2023_rev_0_0.py b/ohmpi/hardware_components/mux_2023_rev_0_0.py index 63f1f4fd..a9012710 100644 --- a/ohmpi/hardware_components/mux_2023_rev_0_0.py +++ b/ohmpi/hardware_components/mux_2023_rev_0_0.py @@ -71,7 +71,8 @@ class Mux(MuxAbstract): else: self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !') self._mode = '' - self._tca = [adafruit_tca9548a.TCA9548A(self.ctl.bus, tca_address)[i] for i in np.arange(7, 3, -1)] + self.io = self.ctl.connections[MUX_CONFIG['connection']] + self._tca = [adafruit_tca9548a.TCA9548A(self.io, tca_address)[i] for i in np.arange(7, 3, -1)] # self._mcp_addresses = (kwargs.pop('mcp', '0x20')) # TODO: add assert on valid addresses.. self._mcp = [None, None, None, None] self.reset() diff --git a/ohmpi/hardware_components/mux_2024_rev_0_0.py b/ohmpi/hardware_components/mux_2024_rev_0_0.py index 71c0655e..11ce2f96 100644 --- a/ohmpi/hardware_components/mux_2024_rev_0_0.py +++ b/ohmpi/hardware_components/mux_2024_rev_0_0.py @@ -12,8 +12,8 @@ MUX_CONFIG.update({'voltage_max': 50., 'current_max': 3.}) # board default valu MUX_CONFIG.update({'activation_delay': 0.01, 'release_delay': 0.005}) # s # defaults to 4 roles cabling electrodes from 1 to 8 default_mux_cabling = {(elec, role) : ('mux_1', elec) for role in ['A', 'B', 'M', 'N'] for elec in range(1,9)} -# defaults to ic connection -ctl_connection = HARDWARE_CONFIG['ctl'].pop('connection', 'i2c') +# # defaults to ic connection +# ctl_connection = HARDWARE_CONFIG['ctl'].pop('connection', 'i2c') inner_cabling = {'4_roles' : {(1, 'X'): {'MCP': 0, 'MCP_GPIO': 0}, (1, 'Y'): {'MCP': 0, 'MCP_GPIO': 8}, (2, 'X'): {'MCP': 0, 'MCP_GPIO': 1}, (2, 'Y'): {'MCP': 0, 'MCP_GPIO': 9}, @@ -76,10 +76,11 @@ class Mux(MuxAbstract): else: self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !') self._mode = '' + self.io = self.ctl.connections[kwargs.pop('connection', MUX_CONFIG['connection'])] if tca_address is None: - self._tca = self.ctl.connections[kwargs.pop('connection', ctl_connection)] + self._tca = self.io else: - self._tca = adafruit_tca9548a.TCA9548A(self.ctl.bus, tca_address)[tca_channel] + self._tca = adafruit_tca9548a.TCA9548A(self.io, tca_address)[tca_channel] self._mcp_addresses = (kwargs.pop('mcp_0', '0x22'), kwargs.pop('mcp_1', '0x23')) # TODO: add assert on valid addresses.. self._mcp = [None, None] self.reset() -- GitLab