Commit 2bf86ce3 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Attemps to use the sampling_rate in _vab_pulse

No related merge requests found
Showing with 6 additions and 4 deletions
+6 -4
...@@ -21,7 +21,7 @@ voltage_min = RX_CONFIG['voltage_min'] ...@@ -21,7 +21,7 @@ voltage_min = RX_CONFIG['voltage_min']
def elapsed_seconds(start_time): def elapsed_seconds(start_time):
lap = datetime.datetime.utcnow() - start_time lap = datetime.datetime.utcnow() - start_time
return lap.seconds + 0.001 * (lap.microseconds//1000) return lap.total_seconds()
class OhmPiHardware: class OhmPiHardware:
def __init__(self, **kwargs): def __init__(self, **kwargs):
...@@ -59,12 +59,14 @@ class OhmPiHardware: ...@@ -59,12 +59,14 @@ class OhmPiHardware:
_readings = [] _readings = []
self.tx_sync.wait() self.tx_sync.wait()
start_time = datetime.datetime.utcnow() start_time = datetime.datetime.utcnow()
sample=0
while self.tx_sync.is_set(): while self.tx_sync.is_set():
lap = datetime.datetime.utcnow() lap = datetime.datetime.utcnow()
_readings.append([elapsed_seconds(start_time), self.tx.current, self.rx.voltage]) _readings.append([elapsed_seconds(start_time), self.tx.current, self.rx.voltage])
sleep_time = sampling_rate / 1000. - elapsed_seconds(lap) sample+=1
print(f'sleep_time: {sleep_time}') sleep_time = start_time + datetime.timedelta(seconds = sample * sampling_rate / 1000) - lap
time.sleep(np.min([sleep_time, np.abs(sleep_time)])) print(f'sleep_time: {sleep_time.total_seconds()} seconds')
time.sleep(sleep_time.total_seconds())
self.readings = np.array(_readings) self.readings = np.array(_readings)
def _vab_pulse(self, vab, length, sampling_rate=None, polarity=None): def _vab_pulse(self, vab, length, sampling_rate=None, polarity=None):
......
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