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

Add hyperdaq hook to scanner #99

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ various spin-control experiments on quantum systems, such as NV centers in diamo
* Spin Core PulseBlaster
* Excelitas SPCM for photon detection
* NI-DAQ card (PCIx 6363) for data acquisition and control
* Jena System's Piezo Actuator Stage Control Amplifier
* Jena System's Piezo Actuator Control Amplifier
* [Future] spectrometer

The code in this package facilitates usages of these devices to perform
Expand Down
577 changes: 577 additions & 0 deletions examples/confocal-scan-random-and-hyperdaq.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "A package for performing experiments in the QT3 lab at UW."
readme = "README.md"
requires-python = ">=3.8"
license = {file = "LICENSE"}
keywords = ["qt3", "confocal scan", "nidaqmx", "piezo", "stage", "control", "electron spin control"]
keywords = ["qt3", "confocal scan", "nidaqmx", "electron spin control", "quantum computing", "nitrogen-vacancy center"]

authors = [
{name = "G. Adam Cox", email = "gadamc@gmail.com" },
Expand Down
58 changes: 26 additions & 32 deletions src/applications/piezoscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ def __init__(self, mplcolormap = 'gray'):
self.ax.set_ylabel('y position (um)')
self.log_data = False

def update(self, model):
def update(self, scanner):

if self.log_data:
data = np.log10(model.scanned_count_rate)
data = np.log10(scanner.get_count_rate())
data[np.isinf(data)] = 0 #protect against +-inf
else:
data = model.scanned_count_rate
data = scanner.get_count_rate()

self.artist = self.ax.imshow(data, cmap=self.cmap, extent=[model.xmin,
model.xmax + model.step_size,
model.current_y + model.step_size,
model.ymin])
self.artist = self.ax.imshow(data, cmap=self.cmap, extent=[scanner.xmin,
scanner.xmax + scanner.step_size,
scanner.get_current_position('y') + scanner.step_size,
scanner.ymin])
if self.cbar is None:
self.cbar = self.fig.colorbar(self.artist, ax=self.ax)
else:
Expand Down Expand Up @@ -294,8 +294,8 @@ class MainTkApplication():
def __init__(self, counter_scanner):
self.root = tk.Tk()
self.counter_scanner = counter_scanner
scan_range = [counter_scanner.stage_controller.minimum_allowed_position,
counter_scanner.stage_controller.maximum_allowed_position]
scan_range = [counter_scanner.actuator_controller.minimum_allowed_position,
counter_scanner.actuator_controller.maximum_allowed_position]
self.view = MainApplicationView(self.root, scan_range)
self.view.sidepanel.startButton.bind("<Button>", self.start_scan)
self.view.sidepanel.stopButton.bind("<Button>", self.stop_scan)
Expand All @@ -316,31 +316,31 @@ def __init__(self, counter_scanner):
self.scan_thread = None

self.optimized_position = {'x':0, 'y':0, 'z':-1}
if self.counter_scanner.stage_controller:
self.optimized_position['z'] = self.counter_scanner.stage_controller.get_current_position()[2]
if self.counter_scanner.actuator_controller:
self.optimized_position['z'] = self.counter_scanner.actuator_controller.get_current_position()[2]
else:
self.optimized_position['z'] = 20
self.view.sidepanel.z_entry_text.set(np.round(self.optimized_position['z'],4))


def run(self):
self.root.title("QT3Scan: Piezo Controlled NIDAQ Digital Count Rate Scanner")
self.root.title("QT3Scan: Piezo Control and NIDAQ Digital Signal Counter")
self.root.deiconify()
self.root.mainloop()

def go_to_position(self, event = None):
if self.counter_scanner.stage_controller:
self.counter_scanner.stage_controller.go_to_position(x = self.view.sidepanel.go_to_x_position_text.get(), y = self.view.sidepanel.go_to_y_position_text.get())
if self.counter_scanner.actuator_controller:
self.counter_scanner.actuator_controller.go_to_position(x = self.view.sidepanel.go_to_x_position_text.get(), y = self.view.sidepanel.go_to_y_position_text.get())
else:
print(f'stage_controller would have moved to x,y = {self.view.sidepanel.go_to_x_position_text.get():.2f}, {self.view.sidepanel.go_to_y_position_text.get():.2f}')
print(f'actuator_controller would have moved to x,y = {self.view.sidepanel.go_to_x_position_text.get():.2f}, {self.view.sidepanel.go_to_y_position_text.get():.2f}')
self.optimized_position['x'] = self.view.sidepanel.go_to_x_position_text.get()
self.optimized_position['y'] = self.view.sidepanel.go_to_y_position_text.get()

def go_to_z(self, event = None):
if self.counter_scanner.stage_controller:
self.counter_scanner.stage_controller.go_to_position(z = self.view.sidepanel.z_entry_text.get())
if self.counter_scanner.actuator_controller:
self.counter_scanner.actuator_controller.go_to_position(z = self.view.sidepanel.z_entry_text.get())
else:
print(f'stage_controller would have moved to z = {self.view.sidepanel.z_entry_text.get():.2f}')
print(f'actuator_controller would have moved to z = {self.view.sidepanel.z_entry_text.get():.2f}')
self.optimized_position['z'] = self.view.sidepanel.z_entry_text.get()

def set_color_map(self, event = None):
Expand Down Expand Up @@ -395,17 +395,12 @@ def scan_thread_function(self, xmin, xmax, ymin, ymax, step_size, N):
self.counter_scanner.set_num_data_samples_per_batch(N)

try:
self.counter_scanner.reset() #clears the data
self.counter_scanner.start() #starts the DAQ
self.counter_scanner.set_to_starting_position() #moves the stage to starting position

while self.counter_scanner.still_scanning():
self.counter_scanner.scan_x()
self.view.scan_view.update(self.counter_scanner)
def update_scan_view(counter_scanner):
self.view.scan_view.update(counter_scanner)
self.view.canvas.draw()
self.counter_scanner.move_y()

self.counter_scanner.stop()
self.counter_scanner.run_scan(reset_starting_position=True,
line_scan_callback=update_scan_view)

except nidaqmx.errors.DaqError as e:
logger.info(e)
Expand Down Expand Up @@ -486,7 +481,7 @@ def optimize_thread_function(self, axis, central, range, step_size):
range,
step_size)
self.optimized_position[axis] = opt_pos
self.counter_scanner.stage_controller.go_to_position(**{axis:opt_pos})
self.counter_scanner.actuator_controller.go_to_position(**{axis:opt_pos})
self.view.show_optimization_plot(f'Optimize {axis}',
central,
self.optimized_position[axis],
Expand All @@ -499,7 +494,6 @@ def optimize_thread_function(self, axis, central, range, step_size):
logger.info(e)
logger.info('Check for other applications using resources. If not, you may need to restart the application.')


self.view.sidepanel.startButton['state'] = 'normal'
self.view.sidepanel.stopButton['state'] = 'normal'
self.view.sidepanel.go_to_z_button['state'] = 'normal'
Expand Down Expand Up @@ -545,11 +539,11 @@ def on_closing(self):

def build_data_scanner():
if args.randomtest:
stage_controller = nipiezojenapy.BaseControl()
actuator_controller = nipiezojenapy.BaseControl()
data_acq = datasources.RandomRateCounter(simulate_single_light_source=True,
num_data_samples_per_batch=args.num_data_samples_per_batch)
else:
stage_controller = nipiezojenapy.PiezoControl(device_name = args.daq_name,
actuator_controller = nipiezojenapy.PiezoControl(device_name = args.daq_name,
write_channels = args.piezo_write_channels.split(','),
read_channels = args.piezo_read_channels.split(','))

Expand All @@ -561,7 +555,7 @@ def build_data_scanner():
args.rwtimeout,
args.signal_counter)

scanner = datasources.CounterAndScanner(data_acq, stage_controller)
scanner = datasources.CounterAndScanner(data_acq, actuator_controller)

return scanner

Expand Down
Loading