From 3ca8c387efdc53329423a089115eb42266dab14d Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Thu, 5 Oct 2023 16:44:08 +0200 Subject: [PATCH] Removes reference to tx_module.TX_CONFIG and rx_module.RX_CONFIG --- ohmpi/hardware_components/mb_2023_0_X.py | 10 +++++----- ohmpi/hardware_system.py | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py index 4b6f2b0d..b900f80f 100644 --- a/ohmpi/hardware_components/mb_2023_0_X.py +++ b/ohmpi/hardware_components/mb_2023_0_X.py @@ -144,7 +144,7 @@ class Tx(TxAbstract): self.pin1 = self.mcp_board.get_pin(1) self.pin1.direction = Direction.OUTPUT self.polarity = 0 - self.adc_gain = 2 / 3 + self.gain = 2 / 3 # MCP23008 pins for LEDs self.pin4 = self.mcp_board.get_pin(4) # TODO: Delete me? No LED on this version of the board @@ -154,11 +154,11 @@ class Tx(TxAbstract): self.exec_logger.event(f'{self.board_name}\ttx_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_current = ads.ADS1115(self.connection, gain=self.adc_gain, @@ -171,7 +171,7 @@ class Tx(TxAbstract): self.exec_logger.event(f'{self.board_name}\ttx_adc_auto_gain\tbegin\t{datetime.datetime.utcnow()}') gain = _gain_auto(AnalogIn(self._ads_current, ads.P0)) self.exec_logger.debug(f'Setting TX ADC gain automatically to {gain}') - self.adc_gain = gain + self.gain = gain self.exec_logger.event(f'{self.board_name}\ttx_adc_auto_gain\tend\t{datetime.datetime.utcnow()}') def current_pulse(self, **kwargs): diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 00f2738c..cd9b9bc0 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -173,11 +173,14 @@ class OhmPiHardware: 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()}') current, voltage = 0., 0. + 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}) + self.tx.gain_auto() + gains.append(self.tx.gain) readings = Thread(target=self._read_values) readings.start() injection.start() -- GitLab