Skip to content

Commit d4e68c3

Browse files
committed
More tweaks to wait length calculation
1 parent 2a67e79 commit d4e68c3

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

labscript_devices/PrawnBlaster/blacs_workers.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ def init(self):
5858
assert self.prawnblaster.readline().decode() == "ok\r\n"
5959

6060
def check_status(self):
61-
if self.started and self.wait_table is not None and self.current_wait < len(self.wait_table):
61+
if (
62+
self.started
63+
and self.wait_table is not None
64+
and self.current_wait < len(self.wait_table)
65+
):
6266
# Try to read out wait. For now, we're only reading out waits from
6367
# pseudoclock 0 since they should all be the same (requirement imposed by labscript)
6468
self.prawnblaster.write(b"getwait %d %d\r\n" % (0, self.current_wait))
@@ -67,6 +71,7 @@ def check_status(self):
6771
# Parse the response from the PrawnBlaster
6872
wait_remaining = int(response)
6973
clock_resolution = self.device_properties["clock_resolution"]
74+
input_response_time = self.device_properties["input_response_time"]
7075
timeout_length = round(
7176
self.wait_table[self.current_wait]["timeout"] / clock_resolution
7277
)
@@ -80,9 +85,13 @@ def check_status(self):
8085
self.wait_timeout[self.current_wait] = True
8186
else:
8287
# Calculate wait length
88+
# This is a measurement of between the end of the last pulse and the
89+
# retrigger signal. We obtain this by subtracting off the time it takes
90+
# to detect the pulse in the ASM code once the trigger has hit the input
91+
# pin (stored in input_response_time)
8392
self.measured_waits[self.current_wait] = (
84-
timeout_length - wait_remaining
85-
) * clock_resolution
93+
(timeout_length - wait_remaining) * clock_resolution
94+
) - input_response_time
8695
self.wait_timeout[self.current_wait] = False
8796

8897
self.logger.info(
@@ -142,10 +151,12 @@ def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
142151
if fresh:
143152
self.smart_cache = {}
144153

154+
# fmt: off
145155
self.h5_file = h5file # store reference to h5 file for wait monitor
146156
self.current_wait = 0 # reset wait analysis
147157
self.started = False # Prevent status check from detecting previous wait values
148-
# betwen now and when we actually send the start signal
158+
# betwen now and when we actually send the start signal
159+
# fmt: on
149160

150161
# Get data from HDF5 file
151162
pulse_programs = []

labscript_devices/PrawnBlaster/labscript_devices.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class PrawnBlaster(PseudoclockDevice):
107107
clock_resolution = 10e-9
108108
# There appears to be ~50ns buffer on input and then we know there is 80ns between
109109
# trigger detection and first output pulse
110-
trigger_delay = 130e-9
110+
input_response_time = 50e-9
111+
trigger_delay = input_response_time + 80e-9
111112
# Overestimate that covers indefinite waits (which labscript does not yet support)
112113
trigger_minimum_duration = 160e-9
113114
# There are 4 ASM instructions between end of pulse and being ready to detect
@@ -129,6 +130,7 @@ class PrawnBlaster(PseudoclockDevice):
129130
"external_clock_pin",
130131
"clock_limit",
131132
"clock_resolution",
133+
"input_response_time",
132134
"trigger_delay",
133135
"trigger_minimum_duration",
134136
"wait_delay",
@@ -162,6 +164,7 @@ def __init__(
162164
factor = (1 / clock_frequency) / self.clock_resolution
163165
self.clock_limit *= factor
164166
self.clock_resolution *= factor
167+
self.input_response_time *= factor
165168
self.trigger_delay *= factor
166169
self.trigger_minimum_duration *= factor
167170
self.wait_delay *= factor

0 commit comments

Comments
 (0)