Skip to content
Snippets Groups Projects
Commit 04e6f635 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

introduce wait_until so the readout interval is not affected by the communication time

parent c8c1d5dc
No related branches found
No related tags found
No related merge requests found
...@@ -92,6 +92,9 @@ class Measurements: ...@@ -92,6 +92,9 @@ class Measurements:
number_of_soaking_reads = next_soaking / self.sleep_time + 1 number_of_soaking_reads = next_soaking / self.sleep_time + 1
do_another_measurement = True do_another_measurement = True
#next_read_time is the starttime of the second read (i.e. read after this one). The time of
#this read (i.e. the first read in the measurement) is now().
next_read_time = self.clock.time() + self.sleep_time
while do_another_measurement: while do_another_measurement:
# wait until set point is reached (+soaking time) # wait until set point is reached (+soaking time)
magnitudes_queue = [] magnitudes_queue = []
...@@ -148,7 +151,8 @@ class Measurements: ...@@ -148,7 +151,8 @@ class Measurements:
print('SOAKING FINISHED!') print('SOAKING FINISHED!')
break break
else: else:
self.clock.sleep(self.sleep_time) self.sleep_until(next_read_time)
next_read_time += self.sleep_time
# perform the configured number of measurements and check that they are really stable # perform the configured number of measurements and check that they are really stable
# It started running after everything become stable # It started running after everything become stable
...@@ -171,7 +175,8 @@ class Measurements: ...@@ -171,7 +175,8 @@ class Measurements:
if (self.temperature_stable and self.humidity_stable and self.magnitude_stable and if (self.temperature_stable and self.humidity_stable and self.magnitude_stable and
self.phase_stable): self.phase_stable):
print('Stable measurement ' + str(i+1) + '/' + str(next_reads)) print('Stable measurement ' + str(i+1) + '/' + str(next_reads))
self.clock.sleep(self.sleep_time) self.sleep_until(next_read_time)
next_read_time += self.sleep_time
else: else:
all_measurements_stable = False all_measurements_stable = False
print('Measurement not stable. Retrying.') print('Measurement not stable. Retrying.')
...@@ -193,6 +198,11 @@ class Measurements: ...@@ -193,6 +198,11 @@ class Measurements:
standby_response = self.chamber.set_mode('STANDBY') standby_response = self.chamber.set_mode('STANDBY')
print(standby_response) print(standby_response)
def sleep_until(self, wakeup_time):
remaining_sleep_time = wakeup_time - self.clock.time()
if remaining_sleep_time > 0:
self.clock.sleep(remaining_sleep_time)
def read_data(self): def read_data(self):
[temp, hum, mode, alarms] = self.chamber.read_monitor().split(',') [temp, hum, mode, alarms] = self.chamber.read_monitor().split(',')
power = self.vna.get_current_power() power = self.vna.get_current_power()
......
{"delta_temp": 0.1, "delta_hum": 1, "delta_mag": 0.1 , "delta_phase": 0.02, "sleep_time": 1.0, "frequency": 1300000000, "vna_config_file": "climate-lab.znxml"} {"delta_temp": 0.1, "delta_hum": 1, "delta_mag": 0.1 , "delta_phase": 0.02, "sleep_time": 10.0, "frequency": 1300000000, "vna_config_file": "climate-lab.znxml"}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment