Skip to content

Commit

Permalink
Updates to daq, scanning laser, and counter. All are working (?) now …
Browse files Browse the repository at this point in the history
…I beleive. Currently the wavemeter is throwing errors (seemingly) at random, so I'm planning to replace the very complicated iqo high-finesse stuff with simpler custom stuff that just gets the wavelength and stores it.
  • Loading branch information
lange50 committed Mar 12, 2025
1 parent d232eb5 commit fddd6ae
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/qudi/gui/terascan/terascan_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def _scan_finished(self) -> None:
@QtCore.Slot(object)
def _receive_data(self, data: List[TerascanData]) -> None:
img = np.zeros((len(data),2))
for i in range(len(data)):
for i in range(len(data) - 1):
# print(np.average(data[i].counts))
#img[i][0] = data[i].wavelength
#img[i][1] = data[i].counts
img[i][0] = 775 + 15 * np.random.rand()
img[i][1] = 100 * np.random.rand()
img[i][0] = data[i].wavelength
img[i][1] = data[i].counts
# img[i][0] = 775 + 15 * np.random.rand()
# img[i][1] = 100 * np.random.rand()

self._mw.data_item.setData(x = img[:, 0], y = img[:, 1])

Expand Down
14 changes: 7 additions & 7 deletions src/qudi/hardware/daq/nidaq.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def on_activate(self):
name=v['name'],
port=v['port'],
description=v['description'],
) for _,v in self._daq_ch_config.items()
) for v in self._daq_ch_config.values()
)

self._analog_channels: List[ReaderVal] = []
Expand All @@ -71,7 +71,7 @@ def on_deactivate(self):

def active_channels(self) -> List[str]:
""" Read-only property returning the currently configured active channel names """
out = self._analog_channels
out = self._analog_channels.copy()
out.extend(self._digital_channels)
temp = (i.description for i in out)
return temp
Expand All @@ -84,10 +84,10 @@ def get_reading(self) -> List[ReaderVal]:
with nidaqmx.Task() as task:
for i in self._analog_channels:
chan = self._get_channel(i)
task.ai_channels.add_ai_chan(chan)
task.ai_channels.add_ai_voltage_chan(chan)

data = task.read()
if len(data) == 1:
if not isinstance(data, list):
data = [data]

self._update_vals(data, self._analog_channels)
Expand All @@ -103,10 +103,10 @@ def get_reading(self) -> List[ReaderVal]:
if not isinstance(data, list):
data = [data]

self._update_vals(data, self._analog_channels)
self._update_vals(data, self._digital_channels)


out = self._analog_channels
out = self._analog_channels.copy()
out.extend(self._digital_channels)
return out

Expand All @@ -120,7 +120,7 @@ def _update_vals(self, vals: List[float], chans: List[ReaderVal]) -> None:
"""

if (len(vals) != len(chans)):
self.__logger.warning('Mismatch between number of configured channels and number of data points read.')
self.log.warning('Mismatch between number of configured channels and number of data points read.')

for v, c in zip(vals, chans):
c.val = v
Expand Down
7 changes: 3 additions & 4 deletions src/qudi/logic/common/fast_counter_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def on_activate(self):
self.__timer = QtCore.QTimer()
self.__timer.setSingleShot(True)
self.__timer.timeout.connect(self.__update_data)
# self.__timer.start(0) # 0-timer to call as often as possible

def on_deactivate(self):
""" Perform required deactivation. """
Expand All @@ -70,8 +69,7 @@ def configure(self,
if record_length_s is not None and record_length_s > 0:
self._record_length_s = record_length_s
if (self._bin_width_s >= self._record_length_s):
# self.__logger.warning('Bin width is greater than or equal to record length')
print('Bin width is greater than or equal to record length')
self.log.warning('Bin width is greater than or equal to record length')

with self._thread_lock:
counter = self._counter()
Expand All @@ -83,7 +81,7 @@ def start_counter(self):
counter = self._counter()
counter.configure(self._bin_width_s, self._record_length_s)
counter.start_measure()
self.__timer.start(int(self._record_length_s*1000) + 1)
self.__timer.start(int(self._record_length_s*1000))
self.sigScanStarted.emit()

@QtCore.Slot()
Expand All @@ -99,4 +97,5 @@ def __update_data(self):
with self._thread_lock:
counter = self._counter()
self._last_data = counter.get_data_trace()
self.__timer.start(int(self._record_length_s*1000))
self.sigScanFinished.emit(self._last_data)
1 change: 0 additions & 1 deletion src/qudi/logic/common/scanning_laser_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def set_wavelengths(self, start: float, stop: float) -> None:
def start_scan(self):
if self.module_state() == 'idle':
with self._thread_lock:
print('starting scan in scanning_laser_logic')
laser = self._laser()
laser.start_scan(self._start_wavelength, self._end_wavelength)
self.sigScanStarted.emit()
Expand Down
6 changes: 2 additions & 4 deletions src/qudi/logic/terascan_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def on_activate(self):
self.sigStopScan.connect(laser.stop_scan, QtCore.Qt.QueuedConnection)
self.sigStopScan.connect(wavemeter.stop_reading, QtCore.Qt.QueuedConnection)

self.sigStopCounting.connect(counter.stop_counter, QtCore.Qt.QueuedConnection)
self.sigStartCounting.connect(counter.start_counter, QtCore.Qt.QueuedConnection)
self.sigStopCounting.connect(counter.stop_counter, QtCore.Qt.QueuedConnection)

# Inputs:
laser.sigScanStarted.connect(self._laser_scan_started)
Expand All @@ -123,11 +123,9 @@ def on_deactivate(self):
@QtCore.Slot()
def start_scan(self):
with self._thread_lock:
print('start_scan in tereascan_logic.py')
if self.module_state() == 'idle':
self.module_state.lock()
self._current_data = []
print('actually start_scan in tereascan_logic.py')
self.sigStartScan.emit()

@QtCore.Slot()
Expand Down Expand Up @@ -176,7 +174,7 @@ def _process_counter_data(self, data: np.ndarray):
self._current_data.append(
TerascanData(
wavelength=self._current_wavelength,
counts=np.sum(data),
counts=data[0][0],
)
)
self.sigCountsUpdated.emit(self._current_data)
Expand Down

0 comments on commit fddd6ae

Please sign in to comment.