diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py index 3ef4fe87f2e1ff4feb492891ee50d0971010936a..9a1fa8a21698c6429d7b47ba993d564045729b6e 100644 --- a/ohmpi/hardware_components/mb_2023_0_X.py +++ b/ohmpi/hardware_components/mb_2023_0_X.py @@ -278,11 +278,11 @@ class Rx(RxAbstract): self.exec_logger.event(f'{self.board_name}\trx_init\tend\t{datetime.datetime.utcnow()}') @property - def adc_gain(self): + def gain(self): return self._adc_gain - @adc_gain.setter - def adc_gain(self, value): + @gain.setter + def gain(self, value): assert value in [2/3, 2, 4, 8, 16] self._adc_gain = value self._ads_voltage = ads.ADS1115(self.connection, gain=self.adc_gain, @@ -297,10 +297,10 @@ class Rx(RxAbstract): gain_2 = _gain_auto(AnalogIn(self._ads_voltage, ads.P2)) gain = np.min([gain_0, gain_2]) self.exec_logger.debug(f'Setting RX ADC gain automatically to {gain}') - self.adc_gain = gain + self.gain = gain self.exec_logger.event(f'{self.board_name}\trx_adc_auto_gain\tend\t{datetime.datetime.utcnow()}') - def gain_auto(self, value): + def gain_auto(self): self._adc_gain_auto() @property def voltage(self): diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index fa439bfa2bde07f8bcb535a646af4f21a4fcd24d..ccec96a70c49dfb6ab58c51a29a4d2b64af4b4d3 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -174,16 +174,20 @@ class OhmPiHardware: self.exec_logger.event(f'OhmPiHardware\ttx_rx_gain_auto\tbegin\t{datetime.datetime.utcnow()}') current, voltage = 0., 0. tx_gains = [] + rx_gains = [] for pol in polarities: self.tx.polarity = pol # self.tx_sync.wait() # set gains automatically injection = Thread(target=self._inject, kwargs={'injection_duration': 0.2, 'polarity': pol}) # readings = Thread(target=self._read_values) - get_gain = Thread(target=self.tx.gain_auto) + get_tx_gain = Thread(target=self.tx.gain_auto) + get_rx_gain = Thread(target=self.rx.gain_auto) injection.start() - get_gain.start() # TODO: add a barrier to synchronize? - get_gain.join() + get_tx_gain.start() # TODO: add a barrier to synchronize? + get_rx_gain.start() + get_tx_gain.join() + get_rx_gain.join() injection.join() tx_gains.append(self.tx.gain)