diff --git a/config_ohmpi_card_3_15.py b/config_ohmpi_card_3_15.py index 8ce65319ad240ef7dec4d367c7d73ae520d584d9..b11d7d755ac897e2c56e37fdd67f0b17fe81b87b 100644 --- a/config_ohmpi_card_3_15.py +++ b/config_ohmpi_card_3_15.py @@ -27,6 +27,7 @@ HARDWARE_CONFIG = { }, 'rx' : {'model': 'ohmpi_card_3_15', '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... }, 'mux': {'model' : 'dummy_mux', # 'ohmpi_i2c_mux64_v1.01', diff --git a/hardware/ohmpi_card_3_15.py b/hardware/ohmpi_card_3_15.py index d7798d52005905428a2da7b33a3a0c59a65b2e34..e5175c1beb599e0f11bb43a706b5d9f2a89e349c 100644 --- a/hardware/ohmpi_card_3_15.py +++ b/hardware/ohmpi_card_3_15.py @@ -19,8 +19,10 @@ RX_CONFIG = HARDWARE_CONFIG['rx'] # ADC for voltage voltage_adc_voltage_min = 10. # 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_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 *** # ADC for current diff --git a/measure.py b/measure.py index bc3ef817c4de0d299bb2518a2935aca14d10cbb6..2c1e5f625471a49504bc0f507d731e237520dc43 100644 --- a/measure.py +++ b/measure.py @@ -45,7 +45,7 @@ class OhmPiHardware: 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 """ def inject(duration): @@ -53,14 +53,18 @@ class OhmPiHardware: self.tx.voltage_pulse(length=duration) self.tx_sync.clear() - def read_values(): + def read_values(sampling_rate): _readings = [] self.tx_sync.wait() start_time = time.gmtime() while self.tx_sync.is_set(): + cur_time=start_time _readings.append([time.gmtime() - start_time, self.tx.current, self.rx.voltage]) + time.sleep(cur_time+sampling_rate-time.gmtime()) 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: self.tx.polarity = polarity self.tx.voltage = vab