Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#005 adding qdlscan and qdlscope first implementation #10

Merged
merged 24 commits into from
Nov 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7c38883
Base implementation of the qdlscan scan controller
nyama8 Oct 26, 2024
666e9e5
Tested and bugfixed application controller
nyama8 Oct 26, 2024
fa8d72e
Created YAML file and controller GUI
nyama8 Oct 26, 2024
459f892
Added backend for single-axis line scans.
nyama8 Oct 26, 2024
bfa70ca
Implemented single line scan and image scan features. Image scan stil…
nyama8 Oct 27, 2024
43bab5d
Implemented save, pause, and continue functions. Tested basic functio…
nyama8 Oct 27, 2024
445cc88
Created example for loading data from qdlscan
nyama8 Oct 27, 2024
9ccc360
Added some basic documentation.
nyama8 Oct 27, 2024
11c1813
Basic implementation of qdlscope controller.
nyama8 Oct 30, 2024
68bbe01
Created basic framework for scope gui and main.
nyama8 Oct 31, 2024
f80b000
Base working version of qdlscope
nyama8 Oct 31, 2024
78d42e5
Testing timing of the sampling loop
nyama8 Oct 31, 2024
1594df1
Basic scope function implementation is complete.
nyama8 Oct 31, 2024
9cd54d9
Removed the int type casting in the save function of qdlscan
nyama8 Oct 31, 2024
99819ad
Added documentation to qdlscope.
nyama8 Oct 31, 2024
979f9eb
Added right click event handling, linked to qdlscope.
nyama8 Nov 1, 2024
b66c776
Added image scan normalization.
nyama8 Nov 1, 2024
5403a9a
Added documentation for new functions.
nyama8 Nov 1, 2024
3ac1859
nick's changes for backscanning
NnguyenHTommy Nov 6, 2024
abc76c2
Fixes to repump and scanning consistency in qdlple
nyama8 Nov 8, 2024
b6a9631
Small bug fix to patch input buffering on qdlmove.
nyama8 Nov 9, 2024
38a1fa4
Removed old test file
nyama8 Nov 12, 2024
0f94779
Updates to QDL scope to fix saving and adjust initial sample rate
nyama8 Nov 12, 2024
60609ca
Fix open scope callback on line scan, created gaussian optimization o…
nyama8 Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tested and bugfixed application controller
  • Loading branch information
nyama8 committed Oct 28, 2024
commit 666e9e5ebdbfc43f87d04a5903ebc518a99b5063
37 changes: 30 additions & 7 deletions src/qdlutils/applications/qdlscan/application_controller.py
Original file line number Diff line number Diff line change
@@ -19,12 +19,14 @@ def __init__(self,
x_axis_controller: NidaqPositionController,
y_axis_controller: NidaqPositionController,
z_axis_controller: NidaqPositionController,
counter_controller: NidaqTimedRateCounter):
counter_controller: NidaqTimedRateCounter,
inter_scan_settle_time: float=0.01):

self.x_axis_controller = x_axis_controller
self.y_axis_controller = y_axis_controller
self.z_axis_controller = z_axis_controller
self.counter_controller = counter_controller
self.inter_scan_settle_time = inter_scan_settle_time

# On initialization move all position controllers to zero.
# WARNING: it is assumed that the zero is a valid position of the DAQ
@@ -90,7 +92,8 @@ def _set_axis(self, axis_controller: NidaqPositionController, position: float):
This avoids logic required to determine which axis is to be moved, for example
in the case of scans where only one axis is used repeatedly.
'''
# Try to move the axis
logger.debug(f'Attempting to move to position {position}.')
# Move the axis
axis_controller.go_to_position(position=position)

def scan_axis(self,
@@ -110,6 +113,9 @@ def scan_axis(self,
raise RuntimeError('Application controller is currently in use.')
# Block the controller from additional external commands
self.busy=True
# Start the counter
logger.info('Starting counter task on DAQ.')
self.counter_controller.start()

# Get the axis controller depending on which axis is requested
if axis == 'x':
@@ -129,6 +135,7 @@ def scan_axis(self,

# Free up the controller
self.busy = False
self.stop()
return data


@@ -205,7 +212,17 @@ def scan_image(self,
raise RuntimeError('Application controller is currently in use.')
# Reserve the controller
self.busy = True


# Get the axis controller depending on which axis is requested
if axis_1 == 'x':
axis_controller_1 = self.x_axis_controller
elif axis_1 == 'y':
axis_controller_1 = self.y_axis_controller
elif axis_1 == 'z':
axis_controller_1 = self.z_axis_controller
else:
raise ValueError(f'Requested axis_1 {axis_1} is invalid.')
# Get the axis controller depending on which axis is requested
if axis_2 == 'x':
axis_controller_2 = self.x_axis_controller
@@ -216,19 +233,25 @@ def scan_image(self,
else:
raise ValueError(f'Requested axis_2 {axis_2} is invalid.')

# Start the counter
logger.info('Starting counter task on DAQ.')
self.counter_controller.start()

# Get the positions for the slow scan axis
positions_2 = np.linspace(start=start_2, stop=stop_2, num=n_pixels_2)

# Then iterate through the positions
for index, position in enumerate(positions_2):
# Move axis 2 to the desired position
self._set_axis(axis_controller=axis_controller_2, position=position)
# Let the axis settle before next scan
time.sleep(self.inter_scan_settle_time)
# Scan axis 1
single_scan = self.scan_axis(axis=axis_1,
start=stop_1,
stop=stop_1,
n_pixels=n_pixels_1,
scan_time=scan_time)
single_scan = self._scan_axis(axis_controller=axis_controller_1,
start=start_1,
stop=stop_1,
n_pixels=n_pixels_1,
scan_time=scan_time)
# Update the buffer
#output[index] = single_scan

333 changes: 330 additions & 3 deletions src/qdlutils/applications/qdlscan/test.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -209,7 +209,7 @@ class docstring.
def start(self) -> None:
'''
Configure the DAQ and start the clock task.
This method is called externally before a measurement is set to begi.
This method is called externally before a measurement is set to begin.
'''
# If currently running, stop the clock task
if self.running:
16 changes: 8 additions & 8 deletions src/qdlutils/hardware/nidaq/counters/nidaqtimedratecounter.py
Original file line number Diff line number Diff line change
@@ -125,14 +125,14 @@ class NidaqTimedRateCounter(NidaqBatchedRateCounter):


def __init__(self,
daq_name = 'Dev1',
signal_terminal = 'PFI0',
clock_rate = 1000000,
sample_time_in_seconds = 1,
clock_terminal = None,
read_write_timeout = 10,
signal_counter = 'ctr2',
trigger_terminal = None,):
daq_name: str = 'Dev1',
signal_terminal: str = 'PFI0',
clock_rate: int = 1000000,
sample_time_in_seconds: float = 1,
clock_terminal: str = None,
read_write_timeout: float = 10,
signal_counter: str = 'ctr2',
trigger_terminal: str = None):

# Save the only new attribute
self.sample_time_in_seconds = sample_time_in_seconds