Commit 02c00824 authored by Arnaud WATLET's avatar Arnaud WATLET
Browse files

Implements io on MUX

Showing with 12 additions and 8 deletions
+12 -8
...@@ -63,7 +63,8 @@ HARDWARE_CONFIG = { ...@@ -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)}, 'cabling': {(i+24, j): ('mux_04', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.} 'voltage_max': 12.}
}, },
'default': {'voltage_max': 100., 'default': {'connection': 'i2c',
'voltage_max': 100.,
'current_max': 3.} 'current_max': 3.}
} }
} }
......
...@@ -18,7 +18,7 @@ OHMPI_CONFIG = { ...@@ -18,7 +18,7 @@ OHMPI_CONFIG = {
} }
HARDWARE_CONFIG = { HARDWARE_CONFIG = {
'ctl': {'model': 'raspberry_pi_i2c'}, 'ctl': {'model': 'raspberry_pi'},
'pwr': {'model': 'pwr_batt', 'voltage': 12.}, 'pwr': {'model': 'pwr_batt', 'voltage': 12.},
'tx': {'model': 'ohmpi_card_3_15', 'tx': {'model': 'ohmpi_card_3_15',
'mcp_board_address': 0x20, 'mcp_board_address': 0x20,
...@@ -59,7 +59,8 @@ HARDWARE_CONFIG = { ...@@ -59,7 +59,8 @@ HARDWARE_CONFIG = {
'cabling': {(i, j): ('mux_4', i) for j in ['N'] for i in range(1, 65)}, 'cabling': {(i, j): ('mux_4', i) for j in ['N'] for i in range(1, 65)},
'voltage_max': 12.}, 'voltage_max': 12.},
}, },
'default': {'voltage_max': 100., 'default': {'connection': 'i2c',
'voltage_max': 100.,
'current_max': 3.} 'current_max': 3.}
} }
} }
......
...@@ -71,7 +71,8 @@ class Mux(MuxAbstract): ...@@ -71,7 +71,8 @@ class Mux(MuxAbstract):
else: else:
self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !') self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !')
self._mode = '' 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_addresses = (kwargs.pop('mcp', '0x20')) # TODO: add assert on valid addresses..
self._mcp = [None, None, None, None] self._mcp = [None, None, None, None]
self.reset() self.reset()
......
...@@ -12,8 +12,8 @@ MUX_CONFIG.update({'voltage_max': 50., 'current_max': 3.}) # board default valu ...@@ -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 MUX_CONFIG.update({'activation_delay': 0.01, 'release_delay': 0.005}) # s
# defaults to 4 roles cabling electrodes from 1 to 8 # 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)} 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 # # defaults to ic connection
ctl_connection = HARDWARE_CONFIG['ctl'].pop('connection', 'i2c') # 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}, 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}, (2, 'X'): {'MCP': 0, 'MCP_GPIO': 1}, (2, 'Y'): {'MCP': 0, 'MCP_GPIO': 9},
...@@ -76,10 +76,11 @@ class Mux(MuxAbstract): ...@@ -76,10 +76,11 @@ class Mux(MuxAbstract):
else: else:
self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !') self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !')
self._mode = '' self._mode = ''
self.io = self.ctl.connections[kwargs.pop('connection', MUX_CONFIG['connection'])]
if tca_address is None: if tca_address is None:
self._tca = self.ctl.connections[kwargs.pop('connection', ctl_connection)] self._tca = self.io
else: 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_addresses = (kwargs.pop('mcp_0', '0x22'), kwargs.pop('mcp_1', '0x23')) # TODO: add assert on valid addresses..
self._mcp = [None, None] self._mcp = [None, None]
self.reset() self.reset()
......
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