diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py index 66d295e27b727b353682d9d43d659a03cbb36061..1f5efa983abd5fdf57aff38990a173d72650baf9 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 31b3e99866b86a774840f65728cc9a20ed1c7a45..95eaad9afc5fd7bcc26ff9ee199dc7474bfc11c8 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()