Commit 5cd5c22b authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Works on issue #101

Showing with 25 additions and 11 deletions
+25 -11
......@@ -30,7 +30,7 @@ HARDWARE_CONFIG = {
'sampling_rate': 10., # ms
'nb_samples': 20, # Max value 10 # was named integer before...
},
'mux': {'model' : 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01',
'mux': {'mux_1':{'model' : 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01',
'tca_address': None, # TODO: This should be part of the system config (cabling of several mux boards)
'tca_channel': 0, # TODO: This should be part of the system config (cabling of several mux boards)
'mcp_0' : '0x22', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user...)
......@@ -38,7 +38,7 @@ HARDWARE_CONFIG = {
# 'addresses': './hardware_components/mux_2024_22_23_4_roles_addressing_table.json',
'voltage_max': 100,
'current_max': 3
}
}}
}
# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS
......
......@@ -41,8 +41,17 @@ class MuxAbstract(ABC):
self.soh_logger = kwargs.pop('soh_logger', None)
if self.soh_logger is None:
self.soh_logger = create_stdout_logger('soh_mux')
self.exec_logger.debug(f'{self.board_name} MUX initialization')
self.board_id = kwargs.pop('id', None)
if self.board_id is None:
self.exec_logger.error(f'MUX {self.board_name} should have an id !')
self.exec_logger.debug(f'MUX {self.board_id} ({self.board_name}) initialization')
self.controller = kwargs.pop('controller', None)
cabling = kwargs.pop('cabling', None)
if cabling is not None:
self._cabling = {}
for k, v in cabling:
if v[0]==self.board_id:
self._cabling.update({k: v[1]})
self.addresses = kwargs.pop('addresses', None)
@abstractmethod
......@@ -82,8 +91,8 @@ class MuxAbstract(ABC):
or np.in1d(elec_dict['M'], elec_dict['B']).any()
or np.in1d(elec_dict['N'], elec_dict['A']).any()
or np.in1d(elec_dict['N'], elec_dict['B']).any()) and state=='on':
self.exec_logger.error('Trying to switch on some electrodes with both M or N roles and A or B roles.'
'This would create an over-voltage in the RX! Switching aborted.')
self.exec_logger.error('Trying to switch on some electrodes with both M or N role and A or B role. '
'This could create an over-voltage in the RX! Switching aborted.')
return
# if all ok, then switch the electrodes
......@@ -208,7 +217,7 @@ class TxAbstract(ABC):
@voltage.setter
@abstractmethod
def voltage(self, value, **kwargs):
def voltage(self, value):
# add actions to set the DPS voltage
pass
......
......@@ -103,10 +103,11 @@ class Mux(MuxAbstract):
self.exec_logger.debug(f'addresses: {self.addresses}')
def _get_addresses(self):
""" Converts inner cabling addressing into (electrodes, role) addressing """
d = inner_cabling[self._mode]
self.addresses = {}
for k, v in d.items():
self.addresses.update({(k[0], self._roles[k[1]]): v})
self.addresses.update({(self._cabling(k[0], self._roles[k[1]])): v})
print(f'addresses: {self.addresses}')
def reset(self):
......
......@@ -19,6 +19,8 @@ current_max = np.min([TX_CONFIG['current_max'], MUX_CONFIG['current_max']])
voltage_max = np.min([TX_CONFIG['voltage_max'], MUX_CONFIG['voltage_max']])
voltage_min = RX_CONFIG['voltage_min']
default_mux_cabling = {(i, j) : ('mux_1', i) for j in ['A', 'B', 'M', 'N'] for i in range(1,9)}
def elapsed_seconds(start_time):
lap = datetime.datetime.utcnow() - start_time
return lap.total_seconds()
......@@ -47,10 +49,12 @@ class OhmPiHardware:
data_logger=self.data_logger,
soh_logger=self.soh_logger,
controller=self.controller))
self.mux = kwargs.pop('mux', mux_module.Mux(exec_logger=self.exec_logger,
self._cabling = kwargs.pop('cabling', default_mux_cabling)
self.mux = kwargs.pop('mux', {'mux_1': mux_module.Mux(exec_logger=self.exec_logger,
data_logger=self.data_logger,
soh_logger=self.soh_logger,
controller=self.controller))
controller=self.controller,
cabling = self._cabling)})
self.readings = np.array([]) # time series of acquired data
self._start_time = None # time of the beginning of a readings acquisition
self._pulse = 0 # pulse number
......
......@@ -2,7 +2,7 @@ import numpy as np
import logging
import matplotlib.pyplot as plt
from utils import change_config
change_config('config_ohmpi_card_3_15.py', verbose=False)
change_config('config_mb_2023_mux_2024.py', verbose=False)
from OhmPi.hardware_system import OhmPiHardware
k = OhmPiHardware()
......
import time
from utils import change_config
change_config('config_ohmpi_card_3_15.py', verbose=False)
change_config('config_mb_2023_mux_2024.py', verbose=False)
from OhmPi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG
from OhmPi.hardware_components import raspberry_pi as controller_module
......
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