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

Adds a sampling_rate key in RX_CONFIG and use it in _vab_pulse

Showing with 9 additions and 2 deletions
+9 -2
...@@ -27,6 +27,7 @@ HARDWARE_CONFIG = { ...@@ -27,6 +27,7 @@ HARDWARE_CONFIG = {
}, },
'rx' : {'model': 'ohmpi_card_3_15', 'rx' : {'model': 'ohmpi_card_3_15',
'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
'sampling_rate': 10., # ms
'nb_samples': 20, # Max value 10 # was named integer before... 'nb_samples': 20, # Max value 10 # was named integer before...
}, },
'mux': {'model' : 'dummy_mux', # 'ohmpi_i2c_mux64_v1.01', 'mux': {'model' : 'dummy_mux', # 'ohmpi_i2c_mux64_v1.01',
......
...@@ -19,8 +19,10 @@ RX_CONFIG = HARDWARE_CONFIG['rx'] ...@@ -19,8 +19,10 @@ RX_CONFIG = HARDWARE_CONFIG['rx']
# ADC for voltage # ADC for voltage
voltage_adc_voltage_min = 10. # mV voltage_adc_voltage_min = 10. # mV
voltage_adc_voltage_max = 4500. # mV voltage_adc_voltage_max = 4500. # mV
sampling_rate = 10. # ms
RX_CONFIG['voltage_min'] = np.min([voltage_adc_voltage_min, RX_CONFIG.pop('voltage_min', np.inf)]) # mV RX_CONFIG['voltage_min'] = np.min([voltage_adc_voltage_min, RX_CONFIG.pop('voltage_min', np.inf)]) # mV
RX_CONFIG['voltage_max'] = np.min([voltage_adc_voltage_max, RX_CONFIG.pop('voltage_max', np.inf)]) # mV RX_CONFIG['voltage_max'] = np.min([voltage_adc_voltage_max, RX_CONFIG.pop('voltage_max', np.inf)]) # mV
RX_CONFIG['sampling_rate'] = RX_CONFIG.pop('sampling_rate', sampling_rate)
# *** TX *** # *** TX ***
# ADC for current # ADC for current
......
...@@ -45,7 +45,7 @@ class OhmPiHardware: ...@@ -45,7 +45,7 @@ class OhmPiHardware:
soh_logger=self.soh_logger)) soh_logger=self.soh_logger))
def _vab_pulse(self, vab, length, polarity=None): def _vab_pulse(self, vab, length, sampling_rate=10., polarity=None):
""" Gets VMN and IAB from a single voltage pulse """ Gets VMN and IAB from a single voltage pulse
""" """
def inject(duration): def inject(duration):
...@@ -53,14 +53,18 @@ class OhmPiHardware: ...@@ -53,14 +53,18 @@ class OhmPiHardware:
self.tx.voltage_pulse(length=duration) self.tx.voltage_pulse(length=duration)
self.tx_sync.clear() self.tx_sync.clear()
def read_values(): def read_values(sampling_rate):
_readings = [] _readings = []
self.tx_sync.wait() self.tx_sync.wait()
start_time = time.gmtime() start_time = time.gmtime()
while self.tx_sync.is_set(): while self.tx_sync.is_set():
cur_time=start_time
_readings.append([time.gmtime() - start_time, self.tx.current, self.rx.voltage]) _readings.append([time.gmtime() - start_time, self.tx.current, self.rx.voltage])
time.sleep(cur_time+sampling_rate-time.gmtime())
return np.array(_readings) return np.array(_readings)
if sampling_rate is None:
sampling_rate = RX_CONFIG['sampling_rate']
if polarity is not None and polarity != self.tx.polarity: if polarity is not None and polarity != self.tx.polarity:
self.tx.polarity = polarity self.tx.polarity = polarity
self.tx.voltage = vab self.tx.voltage = vab
......
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