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

Attemps to use the sampling_rate in _vab_pulse

Showing with 13 additions and 8 deletions
+13 -8
import importlib import importlib
import datetime
import time import time
import numpy as np import numpy as np
...@@ -18,6 +19,10 @@ current_max = np.min([TX_CONFIG['current_max'], MUX_CONFIG['current_max']]) ...@@ -18,6 +19,10 @@ current_max = np.min([TX_CONFIG['current_max'], MUX_CONFIG['current_max']])
voltage_max = np.min([TX_CONFIG['voltage_max'], MUX_CONFIG['voltage_max']]) voltage_max = np.min([TX_CONFIG['voltage_max'], MUX_CONFIG['voltage_max']])
voltage_min = RX_CONFIG['voltage_min'] voltage_min = RX_CONFIG['voltage_min']
def elapsed_seconds(start_time):
lap = datetime.datetime.utcnow() - start_time
return lap.seconds + 0.001 * (lap.microseconds//1000)
class OhmPiHardware: class OhmPiHardware:
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.exec_logger = kwargs.pop('exec_logger', None) self.exec_logger = kwargs.pop('exec_logger', None)
...@@ -53,14 +58,14 @@ class OhmPiHardware: ...@@ -53,14 +58,14 @@ 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(sampling_rate): def read_values(sampling_rate): # noqa
_readings = [] _readings = []
self.tx_sync.wait() self.tx_sync.wait()
start_time = time.gmtime() start_time = datetime.datetime.utcnow()
while self.tx_sync.is_set(): while self.tx_sync.is_set():
cur_time=start_time lap = datetime.datetime.utcnow()
_readings.append([time.gmtime() - start_time, self.tx.current, self.rx.voltage]) _readings.append([elapsed_seconds(start_time), self.tx.current, self.rx.voltage])
time.sleep(cur_time+sampling_rate/1000.-time.gmtime()) time.sleep(sampling_rate/1000.-elapsed_seconds(lap))
return np.array(_readings) return np.array(_readings)
if sampling_rate is None: if sampling_rate is None:
...@@ -73,14 +78,14 @@ class OhmPiHardware: ...@@ -73,14 +78,14 @@ class OhmPiHardware:
# set gains automatically # set gains automatically
self.tx.adc_gain_auto() self.tx.adc_gain_auto()
self.rx.adc_gain_auto() self.rx.adc_gain_auto()
# iab = self.tx.current # measure current
# vmn = self.rx.voltage
data = readings.start() data = readings.start()
injection.start() injection.start()
readings.join() readings.join()
injection.join() injection.join()
print(data) print(data)
return data iab = self.tx.current # measure current
vmn = self.rx.voltage
return iab, vmn
def _compute_tx_volt(self, best_tx_injtime=0.1, strategy='vmax', tx_volt=5, def _compute_tx_volt(self, best_tx_injtime=0.1, strategy='vmax', tx_volt=5,
vab_max=voltage_max, vmn_min=voltage_min): vab_max=voltage_max, vmn_min=voltage_min):
......
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