diff --git a/configs/config_mb_2023_2_mux_2024.py b/configs/config_mb_2023_2_mux_2024.py index dbbf82dfc060775e9d55c3f13f66b235d27c200e..dc3a5f0085c8cb4886dbc52e2245082c51d06996 100644 --- a/configs/config_mb_2023_2_mux_2024.py +++ b/configs/config_mb_2023_2_mux_2024.py @@ -27,8 +27,9 @@ HARDWARE_CONFIG = { 'r_shunt': 2 # Shunt resistance in Ohms }, 'rx': {'model': 'ohmpi_card_3_15', - 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V - 'nb_samples': 20, # Max value 10 # was named integer before... + 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V + 'latency': 0.010 # latency in seconds in continuous mode + # 'nb_samples': 20, # Max value 10 # was named integer before... }, 'mux': # default properties are system properties that will be # overwritten by board properties defined at the board level within the board model file diff --git a/ohmpi/hardware_components/abstract_hardware_components.py b/ohmpi/hardware_components/abstract_hardware_components.py index 47b6a25da3517175c09ec3d2690eb3a4b58f2c93..d3231de1f90747ab88019a9f1facc10d336ebb08 100644 --- a/ohmpi/hardware_components/abstract_hardware_components.py +++ b/ohmpi/hardware_components/abstract_hardware_components.py @@ -260,6 +260,7 @@ class TxAbstract(ABC): self._inj_time = None self._adc_gain = 1. self.inj_time = inj_time + self._latency = kwargs.pop('latency', 0.) self.tx_sync = kwargs.pop('tx_sync', Event()) self.exec_logger.debug(f'{self.board_name} TX initialization') @@ -377,6 +378,7 @@ class RxAbstract(ABC): self._voltage_max = kwargs.pop('voltage_max', 0.) self._adc_gain = 1. self._max_sampling_rate = np.inf + self._latency = kwargs.pop('latency', 0.) self._bias = 0. @property diff --git a/ohmpi/hardware_components/ohmpi_card_3_15.py b/ohmpi/hardware_components/ohmpi_card_3_15.py index f2c83ce84e38a02f1b8c30a2728762398b456281..89a453f515dafd8f1278cf0bb23d4f3fe2e9e5f5 100644 --- a/ohmpi/hardware_components/ohmpi_card_3_15.py +++ b/ohmpi/hardware_components/ohmpi_card_3_15.py @@ -29,6 +29,7 @@ RX_CONFIG['voltage_max'] = np.min([voltage_adc_voltage_max, RX_CONFIG.pop('volta RX_CONFIG['sampling_rate'] = RX_CONFIG.pop('sampling_rate', sampling_rate) RX_CONFIG['data_rate'] = RX_CONFIG.pop('data_rate', data_rate) RX_CONFIG['coef_p2'] = RX_CONFIG.pop('coef_p2', 2.5) +RX_CONFIG['latency'] = RX_CONFIG.pop('latency', 0.01) # *** TX *** # ADC for current @@ -255,6 +256,6 @@ class Rx(RxAbstract): """ Gets the voltage VMN in Volts """ self.exec_logger.event(f'{self.board_name}\trx_voltage\tbegin\t{datetime.datetime.utcnow()}') - u = -AnalogIn(self._ads_voltage, ads.P0, ads.P1).voltage * self._coef_p2 * 1000. - self._bias # TODO: check if it should be negated + u = -AnalogIn(self._ads_voltage, ads.P0, ads.P1).voltage * self._coef_p2 * 1000. - self._bias # TODO: check if it should be negated self.exec_logger.event(f'{self.board_name}\trx_voltage\tend\t{datetime.datetime.utcnow()}') return u diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 044b29c17e40c5128a2431ae2636ce3414055763..f84de68ec5a819ad4ed1c43e72718a0d3314be72 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -178,11 +178,11 @@ class OhmPiHardware: sampling_rate = self.rx.sampling_rate sample = 0 # self.exec_logger.info(f'values when starting pulse {self._pulse} : {self.tx.current} mA, {self.rx.voltage} mV') - _ = self.rx.voltage lap = datetime.datetime.utcnow() # just in case tx_sync is not set immediately after passing wait self.tx_sync.wait() # if not append or self._start_time is None: self._start_time = datetime.datetime.utcnow() + time.sleep(np.max([self.rx._latency, self.tx._latency])) while self.tx_sync.is_set(): lap = datetime.datetime.utcnow() _readings.append([elapsed_seconds(self._start_time), self._pulse, self.tx.polarity, self.tx.current,