Commit de0af66c authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Adds a latency for RX and TX

Showing with 8 additions and 4 deletions
+8 -4
......@@ -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
......
......@@ -251,6 +251,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')
......@@ -346,6 +347,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
......
......@@ -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
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment