From 6bbe32b79ef179976e3cdb679618bc06b9b4115b Mon Sep 17 00:00:00 2001 From: lange50 Date: Thu, 24 Apr 2025 12:35:21 -0400 Subject: [PATCH] Fixed timing issue (hopefully). Still need to update this and terascon_logic (and cfg) to note that you can use finer resolutions now for the integration time. --- src/qudi/hardware/timetagger/swabian_tagger.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/qudi/hardware/timetagger/swabian_tagger.py b/src/qudi/hardware/timetagger/swabian_tagger.py index bdef915..1151179 100644 --- a/src/qudi/hardware/timetagger/swabian_tagger.py +++ b/src/qudi/hardware/timetagger/swabian_tagger.py @@ -21,6 +21,7 @@ """ import numpy as np +import time import TimeTagger as tt from typing import Dict @@ -75,8 +76,9 @@ def on_activate(self): self.statusvar = 0 self.__timer = QtCore.QTimer() - self.__timer.setSingleShot(True) + self.__timer.setSingleShot(False) self.__timer.timeout.connect(self.__update_data) + self.__timer.start(0) # call as often as possible def get_constraints(self): """ Retrieve the hardware constrains from the Fast counting device. @@ -180,9 +182,8 @@ def start_measure(self): """ Start the fast counter. """ self.module_state.lock() self.counter.clear() - self.counter.start() + self.counter.startFor(self._bin_width * 1000) # in ps, should be stored as such #TODO - self.__timer.start(int(self._record_length_s*1000)) self.sigScanStarted.emit() self.statusvar = 2 @@ -213,7 +214,7 @@ def continue_measure(self): If fast counter is in pause state, then fast counter will be continued. """ if self.module_state() == 'locked': - self.counter.start() + self.counter.startFor(self._bin_width * 1000) # in ps, should be stored as such #TODO self.statusvar = 2 return 0 @@ -260,5 +261,10 @@ def get_binwidth(self): def __update_data(self): with self._thread_lock: - self.__timer.start(int(self._record_length_s*1000)) - self.sigScanFinished.emit(np.squeeze(self.get_data_trace())) + if self.module_state() == 'locked': + self.counter.waitUntilFinished(self._bin_width * 1e-6 * 100) # in ms, should never reach this limit, but just in case + self.sigScanFinished.emit( + np.array([time.time(), np.squeeze(self.get_data_trace())]) + ) + + self.counter.startFor(self._bin_width * 1000) # in ps, should be stored as such #TODO