diff --git a/doc/mux_2024_rev_0_0.py b/doc/mux_2024_rev_0_0.py deleted file mode 100644 index 0627326f418d7c509dd406153ec72971fdcf0b74..0000000000000000000000000000000000000000 --- a/doc/mux_2024_rev_0_0.py +++ /dev/null @@ -1,72 +0,0 @@ -from OhmPi.config import HARDWARE_CONFIG -import os -from OhmPi.hardware_components import MuxAbstract -MUX_CONFIG = HARDWARE_CONFIG['mux'] - -class Mux(MuxAbstract): - def __init__(self, **kwargs): - kwargs.update({'board_name': os.path.basename(__file__).rstrip('.py')}) - super().__init__(**kwargs) - self.max_elec = MUX_CONFIG['max_elec'] - - def switch_one(self, elec, role, state='off'): - self.tca = adafruit_tca9548a.TCA9548A(i2c, self.addresses[role]) - # find I2C address of the electrode and corresponding relay - # considering that one MCP23017 can cover 16 electrodes - i2c_address = 7 - (elec - 1) // 16 # quotient without rest of the division - relay = (elec - 1) - ((elec - 1) // 16) * 16 - - if i2c_address is not None: - # select the MCP23017 of the selected MUX board - mcp = MCP23017(self.tca[i2c_address]) - mcp.get_pin(relay - 1).direction = digitalio.Direction.OUTPUT - if state == 'on': - mcp.get_pin(relay - 1).value = True - else: - mcp.get_pin(relay - 1).value = False - # exec_logger.debug(f'Switching relay {relay} ' - # f'({str(hex(self.addresses[role]))}) on:{on} for electrode {elec}') - else: - raise ValueError('No I2C address found for the electrode' - ' {:d} on board {:s}'.format(elec, self.addresses[role])) - # exec_logger.warning(f'Unable to address electrode nr {elec}') - - def switch(self, elecdic={}, state='on'): - """Switch a given list of electrodes with different roles. - Electrodes with a value of 0 will be ignored. - - Parameters - ---------- - elecdic : dictionary, optional - Dictionnary of the form: role: [list of electrodes]. - state : str, optional - Either 'on' or 'off'. - """ - # check to prevent A == B (SHORT-CIRCUIT) - if 'A' in elecdic and 'B' in elecdic: - out = np.in1d(elecdic['A'], elecdic['B']) - if out.any(): - raise ValueError('Some electrodes have A == B -> SHORT-CIRCUIT') - return - - # check none of M and N are the same A or B - # as to prevent burning the MN part which cannot take - # the full voltage of the DPS - if 'A' in elecdic and 'B' in elecdic and 'M' in elecdic and 'N' in elecdic: - if (np.in1d(elecdic['M'], elecdic['A']).any() - or np.in1d(elecdic['M'], elecdic['B']).any() - or np.in1d(elecdic['N'], elecdic['A']).any() - or np.in1d(elecdic['N'], elecdic['B']).any()): - raise ValueError('Some electrodes M and N are on A and B -> cannot be with DPS') - return - - # if all ok, then switch the electrodes - for role in elecdic: - for elec in elecdic[role]: - if elec > 0: - self.switch_one(elec, role, state) - - def reset(self): - for role in self.addresses: - for elec in range(self.nelec): - self.switch_one(elec, role, 'off') \ No newline at end of file diff --git a/ohmpi/hardware_components/mb_2024_rev_0_0.py b/ohmpi/hardware_components/mb_2024_rev_0_0.py index caa5811bf0dcae52bc33ef404e231fdac7bb8dac..4c1d7ca48083e706a2eb6f0f6b5e45c95a3d87e0 100644 --- a/ohmpi/hardware_components/mb_2024_rev_0_0.py +++ b/ohmpi/hardware_components/mb_2024_rev_0_0.py @@ -9,7 +9,7 @@ import time import numpy as np import os from ohmpi.hardware_components import TxAbstract, RxAbstract -ctl_module = importlib.import_module(f'OhmPi.hardware_components.{HARDWARE_CONFIG["hardware"]["ctl"]["model"]}') +ctl_module = importlib.import_module(f'ohmpi.hardware_components.{HARDWARE_CONFIG["hardware"]["ctl"]["model"]}') TX_CONFIG = HARDWARE_CONFIG['tx'] RX_CONFIG = HARDWARE_CONFIG['rx'] diff --git a/ohmpi/hardware_components/ohmpi_card_3_15.py b/ohmpi/hardware_components/ohmpi_card_3_15.py index b0678bfe3d2e35fd926093ae78f65da97fb89f0f..63630605e0e8d87330d7460376a9cbb4bcd23378 100644 --- a/ohmpi/hardware_components/ohmpi_card_3_15.py +++ b/ohmpi/hardware_components/ohmpi_card_3_15.py @@ -11,7 +11,7 @@ import numpy as np import os from ohmpi.hardware_components import TxAbstract, RxAbstract ctl_name = HARDWARE_CONFIG['ctl'].pop('board_name', 'raspberry_pi_i2c') -ctl_module = importlib.import_module(f'OhmPi.hardware_components.{ctl_name}') +ctl_module = importlib.import_module(f'ohmpi.hardware_components.{ctl_name}') TX_CONFIG = HARDWARE_CONFIG['tx'] RX_CONFIG = HARDWARE_CONFIG['rx']