Skip to content

Commit 5618445

Browse files
committed
GatedClocks-bugfix: Fixed bug in gated clocks feature
We previously only checked that instructions on clocklines were not too close together for the clock limit (i.e. was an instruction on clockline A too close to the next instruction on clockline A, and was instruction B too close to the next instruction on clockline B). However, this does not catch the case where an instruction on clockline B is close to an instruction on clockline A, thus forcing the pulse on clockline A to be shorter than it would otherwise. This case is now caught in the below patch.
1 parent 932395c commit 5618445

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

labscript.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,24 @@ def collect_change_times(self, all_outputs, outputs_by_clockline):
653653
# Get rid of duplicates if trigger times were already in the list:
654654
change_time_list = list(set(change_time_list))
655655
change_time_list.sort()
656-
656+
657+
# index to keep track of in all_change_times
658+
j = 0
657659
# Check that no two instructions are too close together:
658660
for i, t in enumerate(change_time_list[:-1]):
659661
dt = change_time_list[i+1] - t
660662
if dt < 1.0/clock_line.clock_limit:
661-
raise LabscriptError('Commands have been issued to devices attached to %s at t= %s s and %s s. '%(self.name, str(t),str(change_time_list[i+1])) +
663+
raise LabscriptError('Commands have been issued to devices attached to clockline %s at t= %s s and %s s. '%(clock_line.name, str(t),str(change_time_list[i+1])) +
664+
'One or more connected devices on ClockLine %s cannot support update delays shorter than %s sec.'%(clock_line.name, str(1.0/clock_line.clock_limit)))
665+
666+
# increment j until we reach the current time
667+
while all_change_times[j] < t and j < len(all_change_times)-1:
668+
j += 1
669+
# j should now index all_change_times at "t"
670+
# Check that the next all change_time is not too close (and thus would force this clock tick to be faster than the clock_limit)
671+
dt = all_change_times[j+1] - t
672+
if dt < 1.0/clock_line.clock_limit:
673+
raise LabscriptError('Commands have been issued to devices attached to %s at t= %s s and %s s. '%(self.name, str(t),str(all_change_times[j+1])) +
662674
'One or more connected devices on ClockLine %s cannot support update delays shorter than %s sec.'%(clock_line.name, str(1.0/clock_line.clock_limit)))
663675

664676
# Also add the stop time as as change time. First check that it isn't too close to the time of the last instruction:

0 commit comments

Comments
 (0)