Skip to content

Commit

Permalink
GatedClocks-bugfix: Fixed bug in gated clocks feature
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
philipstarkey committed Jan 15, 2019
1 parent 932395c commit 5618445
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions labscript.py
Expand Up @@ -653,12 +653,24 @@ def collect_change_times(self, all_outputs, outputs_by_clockline):
# Get rid of duplicates if trigger times were already in the list:
change_time_list = list(set(change_time_list))
change_time_list.sort()


# index to keep track of in all_change_times
j = 0
# Check that no two instructions are too close together:
for i, t in enumerate(change_time_list[:-1]):
dt = change_time_list[i+1] - t
if dt < 1.0/clock_line.clock_limit:
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])) +
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])) +
'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)))

# increment j until we reach the current time
while all_change_times[j] < t and j < len(all_change_times)-1:
j += 1
# j should now index all_change_times at "t"
# 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)
dt = all_change_times[j+1] - t
if dt < 1.0/clock_line.clock_limit:
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])) +
'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)))

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

0 comments on commit 5618445

Please sign in to comment.