Skip to content

Commit

Permalink
Updated to remove data from when a mode hop ocurrs. Also fixed a mino…
Browse files Browse the repository at this point in the history
…r bug in the photon_counts gui where something had the wrong name.
  • Loading branch information
lange50 committed Mar 31, 2025
1 parent ddaec16 commit e8e4f09
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cfg/terascan.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ logic:
options:
record_length_ms: 1 # Length of data (in ms) to take at each wavelength. Only integers.
laser_timeout_s: 10 # time in seconds before we automatically restart the laser scan

mode_hop_overlap_med: 0.001 # in nm, from the SolsTiS control panel. This is how far back we go to discard data every time a mode hop occurs
mode_hop_overlap_fine: 0.00025 # ""

# daq_reader_logic:
# module.Class: 'common.daq_reader_logic.DAQReaderLogic'
Expand Down
2 changes: 1 addition & 1 deletion src/qudi/gui/swabian/photon_counts_time_average_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def on_activate(self) -> None:
def on_deactivate(self) -> None:
# When you call a connector, you should do it as a function, as shown here. Noone knows why.
# For some reason, when connecting to an external connector, you also need to specify which function you are disconnecting
self._photon_counts_logic().sigPhotonCounts.disconnect(self._counts_changed)
self._photon_counts_logic().sigScanFinished.disconnect(self._counts_changed)

self._mw.start_button.clicked.disconnect()

Expand Down
41 changes: 39 additions & 2 deletions src/qudi/logic/terascan_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class TerascanLogic(LogicBase):
options:
record_length_ms: 1 # Length of data (in ms) to take at each wavelength. Only integers.
laser_timeout_s: 10 # Time in seconds to wait for the laser to lock before automatically restarting the scan
mode_hop_overlap_med: 0.001 # in nm, from the SolsTiS control panel. This is how far back we go to discard data every time a mode hop occurs
mode_hop_overlap_fine: 0.00025 # ""
"""

# declare connectors
Expand All @@ -55,6 +57,9 @@ class TerascanLogic(LogicBase):
missing='info')

_laser_timeout_s = ConfigOption(name='laser_timeout_s', default=10)

_mode_hop_overlap_med = ConfigOption(name='mode_hop_overlap_med', default=0.001)
_mode_hop_overlap_fine = ConfigOption(name='mode_hop_overlap_fine', default=0.00025)

# status variables:
_start_wavelength = StatusVar('start_wavelength', default=0.75)
Expand All @@ -65,7 +70,7 @@ class TerascanLogic(LogicBase):
_scan_type = StatusVar('scan_type', default=2) # SCAN_TYPE_FINE

_laser_locked = StatusVar('laser_locked', default=False)
_current_data = StatusVar('current_data', default=[]) # list of TerascanData
_current_data = [] # list of TerascanData

_last_locked: float = 0

Expand Down Expand Up @@ -255,11 +260,43 @@ def _new_daq_data(self, data: List[ReaderVal]):
# self.sigStartCounting.emit()

if not i.val and self._laser_locked:
# We just mode hopped and are now unlocked
self._laser_locked = False
# self.sigStopCounting.emit()
self._remove_mode_hop()


self.sigLaserLocked.emit(self._laser_locked)


### Internal Functions ###
def _remove_mode_hop(self):
""" Function to remove previous data when a mode hop occurs.
Assumes we are locked externally.
"""
target = -1
scan_up = self._start_wavelength < self._end_wavelength

if self._scan_type == 1: # MEDIUM Scan
target = self._current_wavelength - self._mode_hop_overlap_med \
if scan_up else self._current_wavelength + self._mode_hop_overlap_med
elif self._scan_type == 2: # FINE Scan
target = self._current_wavelength - self._mode_hop_overlap_fine \
if scan_up else self._current_wavelength + self._mode_hop_overlap_fine
else:
self.log.warning('Unknown scan type. Not removing data.')
return

while len(self._current_data) > 0:
if (scan_up and \
self._current_data[-1].wavelength > target) or \
(not scan_up and \
self._current_data[-1].wavelength < target):
# We need to check if we are scanning up or down
self._current_data.pop()
else:
break



#### Watchdog Timer ####
def __watchdog(self):
Expand Down

0 comments on commit e8e4f09

Please sign in to comment.