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

laser af init bug fix #113

Merged
merged 2 commits into from
Feb 21, 2025
Merged
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
21 changes: 15 additions & 6 deletions software/control/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4607,8 +4607,8 @@ def initialize_auto(self) -> bool:

# Move to first position and measure
if self.piezo is not None:
self._move_z(-self.PIXEL_TO_UM_CALIBRATION_DISTANCE/2)
time.sleep(MULTIPOINT_PIEZO_DELAY_MS/1000)
self._move_z(-self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 2)
time.sleep(MULTIPOINT_PIEZO_DELAY_MS / 1000)
else:
# TODO: change to _move_z after backlash correction is absorbed into firmware
self.stage.move_z(-1.5 * self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 1000)
Expand All @@ -4623,8 +4623,8 @@ def initialize_auto(self) -> bool:
x0, y0 = result

# Move to second position and measure
self._move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE/2)
time.sleep(MULTIPOINT_PIEZO_DELAY_MS/1000)
self._move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE)
time.sleep(MULTIPOINT_PIEZO_DELAY_MS / 1000)

result = self._get_laser_spot_centroid()
if result is None:
Expand All @@ -4637,6 +4637,15 @@ def initialize_auto(self) -> bool:
self.microcontroller.turn_off_AF_laser()
self.microcontroller.wait_till_operation_is_completed()

# move back to initial position
if self.piezo is not None:
self._move_z(-self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 2)
time.sleep(MULTIPOINT_PIEZO_DELAY_MS / 1000)
else:
# TODO: change to _move_z after backlash correction is absorbed into firmware
self.stage.move_z(-1.5 * self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 1000)
self.stage.move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 1000)

# Calculate conversion factor
if x1 - x0 == 0:
self.pixel_to_um = 0.4 # Simulation value
Expand Down Expand Up @@ -4794,10 +4803,10 @@ def _verify_spot_alignment(self) -> bool:
self.microcontroller.wait_till_operation_is_completed()

# TODO: create a function to get the current image (taking care of trigger mode checking and laser on/off switching)
'''
"""
self.camera.send_trigger()
current_image = self.camera.read_frame()
'''
"""
self._get_laser_spot_centroid()
current_image = self.image

Expand Down
Loading