From 81b411d16d86b2ce5008ba25c1d2391a6aa54c29 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Mon, 8 Nov 2021 16:11:21 -0500 Subject: [PATCH] Updating to be more clear about how AI_start_delay is calculated, particularly in the case of devices that use AI_start_delay_ticks. --- labscript_devices/NI_DAQmx/blacs_workers.py | 2 +- labscript_devices/NI_DAQmx/labscript_devices.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/labscript_devices/NI_DAQmx/blacs_workers.py b/labscript_devices/NI_DAQmx/blacs_workers.py index 384efa3f..61dff2fc 100644 --- a/labscript_devices/NI_DAQmx/blacs_workers.py +++ b/labscript_devices/NI_DAQmx/blacs_workers.py @@ -537,7 +537,7 @@ def transition_to_buffered(self, device_name, h5file, initial_values, fresh): self.h5_file = h5file self.buffered_rate = device_properties['acquisition_rate'] if device_properties['start_delay_ticks']: - # delay is defined in sample clock ticks + # delay is defined in sample clock ticks, calculate in sec and save for later self.AI_start_delay = self.AI_start_delay_ticks*self.buffered_rate self.acquired_data = [] # Stop the manual mode task and start the buffered mode task: diff --git a/labscript_devices/NI_DAQmx/labscript_devices.py b/labscript_devices/NI_DAQmx/labscript_devices.py index 8f655713..2bb1fc8a 100644 --- a/labscript_devices/NI_DAQmx/labscript_devices.py +++ b/labscript_devices/NI_DAQmx/labscript_devices.py @@ -97,7 +97,7 @@ def __init__( AI_range=None, AI_range_Diff=None, AI_start_delay=0, - AI_start_delay_ticks=0, + AI_start_delay_ticks=None, AI_term='RSE', AI_term_cfg=None, AO_range=None, @@ -231,8 +231,14 @@ def __init__( raise LabscriptError(dedent(msg.format(AI_term))) if AI_term == 'Diff': self.AI_range = AI_range_Diff - # define AI_start_delay in ticks, assumes AI_start_delay_ticks is defined - self.start_delay_ticks = (AI_start_delay != None) + if AI_start_delay is None: + if AI_start_delay_ticks is not None: + # Tell blacs_worker to use AI_start_delay_ticks to define delay + self.start_delay_ticks = True + else: + self.start_delay_ticks = False + else: + raise LabscriptError("You have specified `AI_start_delay = None` but have not provided `AI_start_delay_ticks`.") self.num_AO = num_AO self.num_CI = num_CI self.ports = ports if ports is not None else {}