From 9694e296d06a4d9db4f054ff817c0fb073c4fe30 Mon Sep 17 00:00:00 2001 From: Hongquan Li Date: Thu, 20 Feb 2025 16:31:09 -0800 Subject: [PATCH 1/2] laser af init bug fix --- software/control/core/core.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/software/control/core/core.py b/software/control/core/core.py index e7d8bb6e..3a09b74e 100644 --- a/software/control/core/core.py +++ b/software/control/core/core.py @@ -4623,7 +4623,7 @@ def initialize_auto(self) -> bool: x0, y0 = result # Move to second position and measure - self._move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE/2) + self._move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE) time.sleep(MULTIPOINT_PIEZO_DELAY_MS/1000) result = self._get_laser_spot_centroid() @@ -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 From 68a1092ca9d42be4a09600451dcef45ef3890f44 Mon Sep 17 00:00:00 2001 From: Hongquan Li Date: Thu, 20 Feb 2025 16:33:49 -0800 Subject: [PATCH 2/2] run black --- software/control/core/core.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/software/control/core/core.py b/software/control/core/core.py index 3a09b74e..5994a08f 100644 --- a/software/control/core/core.py +++ b/software/control/core/core.py @@ -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) @@ -4624,7 +4624,7 @@ def initialize_auto(self) -> bool: # Move to second position and measure self._move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE) - time.sleep(MULTIPOINT_PIEZO_DELAY_MS/1000) + time.sleep(MULTIPOINT_PIEZO_DELAY_MS / 1000) result = self._get_laser_spot_centroid() if result is None: @@ -4639,8 +4639,8 @@ def initialize_auto(self) -> bool: # 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) + 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) @@ -4803,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