From 2077be052407a1e26a557792e875cce2c6086500 Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Tue, 3 Oct 2023 19:40:19 +0200 Subject: [PATCH] Removes reference to tx_module.TX_CONFIG and rx_module.RX_CONFIG --- ohmpi/hardware_components/mb_2023_0_X.py | 4 +++- ohmpi/hardware_system.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py index 66d295e2..1f5efa98 100644 --- a/ohmpi/hardware_components/mb_2023_0_X.py +++ b/ohmpi/hardware_components/mb_2023_0_X.py @@ -24,7 +24,9 @@ from ohmpi.utils import enforce_specs SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.}, 'data_rate': {'default': 860.}, 'bias': {'min': -5000., 'default': 0., 'max': 5000.}, - 'coef_p2': {'default': 2.50}}, + 'coef_p2': {'default': 2.50}, + 'voltage_min': {'default': 10.0}, + }, 'tx': {'adc_voltage_min': {'default': 10.}, 'adc_voltage_max': {'default': 4500.}, 'voltage_max': {'min': 0., 'default': 12., 'max': 12.}, diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 31b3e998..95eaad9a 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -33,9 +33,14 @@ for k, v in tx_module.SPECS['tx'].items(): try: TX_CONFIG.update({k: TX_CONFIG.pop(k, v['default'])}) except: - print(k, v) + print(f'Cannot set value {v} in TX_CONFIG[{k}]') RX_CONFIG = HARDWARE_CONFIG['rx'] +for k, v in rx_module.SPECS['rx'].items(): + try: + RX_CONFIG.update({k: RX_CONFIG.pop(k, v['default'])}) + except: + print(f'Cannot set value {v} in RX_CONFIG[{k}]') current_max = np.min([TX_CONFIG['voltage_max']/50/TX_CONFIG['r_shunt'], np.min([MUX_CONFIG[i].pop('current_max', np.inf) for i in MUX_CONFIG.keys()])]) voltage_max = np.min([TX_CONFIG['voltage_max'], np.min([MUX_CONFIG[i].pop('voltage_max', np.inf) for i in MUX_CONFIG.keys()])]) @@ -145,14 +150,14 @@ class OhmPiHardware: self._start_time = None self._pulse = 0 - def _gain_auto(self, polarities=[1, -1]): # TODO: improve _gain_auto + def _gain_auto(self, polarities=(1, -1)): # TODO: improve _gain_auto self.exec_logger.event(f'OhmPiHardware\ttx_rx_gain_auto\tbegin\t{datetime.datetime.utcnow()}') self.tx_sync.wait() current, voltage = 0., 0. for pol in polarities: self.tx.polarity = pol # set gains automatically - injection = Thread(target=self._inject, kwargs={'injection_duration': 0.2, 'polarity': polarity}) + injection = Thread(target=self._inject, kwargs={'injection_duration': 0.2, 'polarity': pol}) readings = Thread(target=self._read_values) readings.start() injection.start() -- GitLab