From 53e3bbe729da17e48b33b15cb231bf80e0251bdc Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 3 Jun 2025 14:40:02 +0800 Subject: [PATCH 01/21] add move_xy_to API into firmware & change the CMD length from 8 to 24 --- .../main_controller_teensy41.ino | 26 +++++++++++++++---- software/control/_def.py | 4 ++- software/control/core/core.py | 9 +++---- software/control/core/multi_point_worker.py | 19 +++++++++----- software/control/microcontroller.py | 18 +++++++++++++ software/squid/stage/cephla.py | 12 +++++++++ 6 files changed, 69 insertions(+), 19 deletions(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index 7433b72bd..8a231dd65 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -25,7 +25,7 @@ // byte[2]: how many micro steps - upper 8 bits // byte[3]: how many micro steps - lower 8 bits -static const int CMD_LENGTH = 8; +static const int CMD_LENGTH = 24; static const int MSG_LENGTH = 24; byte buffer_rx[512]; byte buffer_tx[MSG_LENGTH]; @@ -67,6 +67,8 @@ static const int SET_PID_ARGUMENTS = 29; static const int SEND_HARDWARE_TRIGGER = 30; static const int SET_STROBE_DELAY = 31; static const int SET_AXIS_DISABLE_ENABLE = 32; +static const int MOVE_XY = 33; +static const int MOVETO_XY = 34; static const int SET_PIN_LEVEL = 41; static const int INITFILTERWHEEL = 253; static const int INITIALIZE = 254; @@ -911,6 +913,21 @@ void loop() { } break; } + case MOVETO_XY: + { + long x_absolute_position = int32_t(uint32_t(buffer_rx[2]) << 24 | uint32_t(buffer_rx[3]) << 16 | uint32_t(buffer_rx[4]) << 8 | uint32_t(buffer_rx[5])); + X_direction = sgn(x_absolute_position - tmc4361A_currentPosition(&tmc4361[x])); + X_commanded_target_position = x_absolute_position; + if (tmc4361A_moveTo(&tmc4361[x], X_commanded_target_position) == 0) + X_commanded_movement_in_progress = true; + long y_absolute_position = int32_t(uint32_t(buffer_rx[6]) << 24 | uint32_t(buffer_rx[7]) << 16 | uint32_t(buffer_rx[8]) << 8 | uint32_t(buffer_rx[9])); + Y_direction = sgn(y_absolute_position - tmc4361A_currentPosition(&tmc4361[y])); + Y_commanded_target_position = y_absolute_position; + if (tmc4361A_moveTo(&tmc4361[y], Y_commanded_target_position) == 0) + Y_commanded_movement_in_progress = true; + mcu_cmd_execution_in_progress = true; + break; + } case MOVETO_Z: { long absolute_position = int32_t(uint32_t(buffer_rx[2]) << 24 | uint32_t(buffer_rx[3]) << 16 | uint32_t(buffer_rx[4]) << 8 | uint32_t(buffer_rx[5])); @@ -2181,9 +2198,9 @@ void loop() { buffer_tx[18] &= ~ (1 << BIT_POS_JOYSTICK_BUTTON); // clear the joystick button bit buffer_tx[18] = buffer_tx[18] | joystick_button_pressed << BIT_POS_JOYSTICK_BUTTON; - // Calculate and fill out the checksum. NOTE: This must be after all other buffer_tx modifications are done! - uint8_t checksum = crc8ccitt(buffer_tx, MSG_LENGTH - 1); - buffer_tx[MSG_LENGTH - 1] = checksum; + // Calculate and fill out the checksum. NOTE: This must be after all other buffer_tx modifications are done! + uint8_t checksum = crc8ccitt(buffer_tx, MSG_LENGTH - 1); + buffer_tx[MSG_LENGTH - 1] = checksum; if(!DEBUG_MODE) SerialUSB.write(buffer_tx,MSG_LENGTH); @@ -2202,7 +2219,6 @@ void loop() { SerialUSB.println(digitalRead(pin_PG)); } flag_send_pos_update = false; - } // keep checking position process at suitable frequence diff --git a/software/control/_def.py b/software/control/_def.py index 2c4c639c0..ab1b2da09 100644 --- a/software/control/_def.py +++ b/software/control/_def.py @@ -86,7 +86,7 @@ class PosUpdate: class MicrocontrollerDef: MSG_LENGTH = 24 - CMD_LENGTH = 8 + CMD_LENGTH = 24 N_BYTES_POS = 4 @@ -145,6 +145,8 @@ class CMD_SET: SEND_HARDWARE_TRIGGER = 30 SET_STROBE_DELAY = 31 SET_AXIS_DISABLE_ENABLE = 32 + MOVE_XY = 33 + MOVETO_XY = 34 SET_PIN_LEVEL = 41 INITFILTERWHEEL = 253 INITIALIZE = 254 diff --git a/software/control/core/core.py b/software/control/core/core.py index 159c33009..c4f99c459 100644 --- a/software/control/core/core.py +++ b/software/control/core/core.py @@ -1173,8 +1173,7 @@ def gen_focus_map(self, coord1, coord2, coord3): for coord in [coord1, coord2, coord3]: print(f"Navigating to coordinates ({coord[0]},{coord[1]}) to sample for focus map") - self.stage.move_x_to(coord[0]) - self.stage.move_y_to(coord[1]) + self.stage.move_xy_to(coord[0], coord[1]) print("Autofocusing") self.autofocus(True) @@ -2372,8 +2371,7 @@ def run_acquisition(self, acquire_current_fov=False): self.autofocusController.set_focus_map_use(True) # Return to center position - self.stage.move_x_to(x_center) - self.stage.move_y_to(y_center) + self.stage.move_xy_to(x_center, y_center) except ValueError: self._log.exception("Invalid coordinates for autofocus plane, aborting.") @@ -2453,8 +2451,7 @@ def _on_acquisition_completed(self): if "current" in self.scanCoordinates.region_centers: region_center = self.scanCoordinates.region_centers["current"] try: - self.stage.move_x_to(region_center[0]) - self.stage.move_y_to(region_center[1]) + self.stage.move_xy_to(region_center[0], region_center[1]) self.stage.move_z_to(region_center[2]) except: self._log.error("Failed to move to center of current region") diff --git a/software/control/core/multi_point_worker.py b/software/control/core/multi_point_worker.py index e7988eeb9..d42e62b56 100644 --- a/software/control/core/multi_point_worker.py +++ b/software/control/core/multi_point_worker.py @@ -267,19 +267,24 @@ def update_coordinates_dataframe(self, region_id, z_level, fov=None): def move_to_coordinate(self, coordinate_mm): print("moving to coordinate", coordinate_mm) - x_mm = coordinate_mm[0] - self.stage.move_x_to(x_mm) - time.sleep(SCAN_STABILIZATION_TIME_MS_X / 1000) - - y_mm = coordinate_mm[1] - self.stage.move_y_to(y_mm) - time.sleep(SCAN_STABILIZATION_TIME_MS_Y / 1000) # check if z is included in the coordinate if len(coordinate_mm) == 3: + x_mm = coordinate_mm[0] + y_mm = coordinate_mm[1] z_mm = coordinate_mm[2] + + self.stage.move_xy_to(x_mm, y_mm, blocking=False) self.move_to_z_level(z_mm) + time.sleep(SCAN_STABILIZATION_TIME_MS_Y / 1000) + else: + x_mm = coordinate_mm[0] + y_mm = coordinate_mm[1] + + self.stage.move_xy_to(x_mm, y_mm) + time.sleep(SCAN_STABILIZATION_TIME_MS_Y / 1000) + def move_to_z_level(self, z_mm): print("moving z") self.stage.move_z_to(z_mm) diff --git a/software/control/microcontroller.py b/software/control/microcontroller.py index fc1a11c0c..39506dea5 100644 --- a/software/control/microcontroller.py +++ b/software/control/microcontroller.py @@ -684,6 +684,24 @@ def move_y_to_usteps(self, usteps): cmd[5] = payload & 0xFF self.send_command(cmd) + def move_xy_to_usteps(self, xusteps, yusteps): + xpayload = self._int_to_payload(xusteps, 4) + ypayload = self._int_to_payload(yusteps, 4) + + cmd = bytearray(self.tx_buffer_length) + cmd[1] = CMD_SET.MOVETO_XY + cmd[2] = xpayload >> 24 + cmd[3] = (xpayload >> 16) & 0xFF + cmd[4] = (xpayload >> 8) & 0xFF + cmd[5] = xpayload & 0xFF + + cmd[6] = ypayload >> 24 + cmd[7] = (ypayload >> 16) & 0xFF + cmd[8] = (ypayload >> 8) & 0xFF + cmd[9] = ypayload & 0xFF + + self.send_command(cmd) + def move_z_usteps(self, usteps): self._move_axis_usteps(usteps, CMD_SET.MOVE_Z) diff --git a/software/squid/stage/cephla.py b/software/squid/stage/cephla.py index eeef8fbc6..151bdd197 100644 --- a/software/squid/stage/cephla.py +++ b/software/squid/stage/cephla.py @@ -107,6 +107,18 @@ def move_y_to(self, abs_mm: float, blocking: bool = True): self._calc_move_timeout(abs_mm - self.get_pos().y_mm, self.get_config().Y_AXIS.MAX_SPEED) ) + def move_xy_to(self, x_abs_mm: float, y_abs_mm: float, blocking: bool = True): + self._microcontroller.move_xy_to_usteps(self._config.X_AXIS.convert_real_units_to_ustep(x_abs_mm), + self._config.Y_AXIS.convert_real_units_to_ustep(y_abs_mm)) + + if blocking: + x_timeout = self._calc_move_timeout(x_abs_mm - self.get_pos().x_mm, self.get_config().X_AXIS.MAX_SPEED) + y_timeout = self._calc_move_timeout(y_abs_mm - self.get_pos().y_mm, self.get_config().Y_AXIS.MAX_SPEED) + + self._microcontroller.wait_till_operation_is_completed( + max(x_timeout, y_timeout) + ) + def move_z_to(self, abs_mm: float, blocking: bool = True): # From Hongquan, we want the z axis to rest on the "up" (wrt gravity) direction of gravity. So if we # are moving in the negative (down) z direction, we need to move past our mark a bit then From 7f696ed26c121c0917d66cd69988b90a3f108d8f Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Wed, 4 Jun 2025 17:37:17 +0800 Subject: [PATCH 02/21] switch Z value tuning direction --- .../main_controller_teensy41/main_controller_teensy41.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index 8a231dd65..e9bf783f9 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -358,7 +358,7 @@ void onJoystickPacketReceived(const uint8_t* buffer, size_t size) } else { - focusPosition = focusPosition + (int32_t(uint32_t(buffer[0]) << 24 | uint32_t(buffer[1]) << 16 | uint32_t(buffer[2]) << 8 | uint32_t(buffer[3])) - focuswheel_pos); + focusPosition = focusPosition - (int32_t(uint32_t(buffer[0]) << 24 | uint32_t(buffer[1]) << 16 | uint32_t(buffer[2]) << 8 | uint32_t(buffer[3])) - focuswheel_pos); focuswheel_pos = int32_t(uint32_t(buffer[0]) << 24 | uint32_t(buffer[1]) << 16 | uint32_t(buffer[2]) << 8 | uint32_t(buffer[3])); } From 28f0684675aa1a1c26d739c1102c0df29a2cf801 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Fri, 6 Jun 2025 15:47:23 +0800 Subject: [PATCH 03/21] cancel waiting logic for turn on illumination --- software/control/core/multi_point_worker.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/software/control/core/multi_point_worker.py b/software/control/core/multi_point_worker.py index d42e62b56..989737ff2 100644 --- a/software/control/core/multi_point_worker.py +++ b/software/control/core/multi_point_worker.py @@ -484,7 +484,6 @@ def acquire_camera_image(self, config, file_ID, current_path, current_round_imag camera_illumination_time = self.camera.get_exposure_time() if self.liveController.trigger_mode == TriggerMode.SOFTWARE: self.liveController.turn_on_illumination() - self.wait_till_operation_is_completed() camera_illumination_time = None elif self.liveController.trigger_mode == TriggerMode.HARDWARE: if "Fluorescence" in config.name and ENABLE_NL5 and NL5_USE_DOUT: @@ -549,7 +548,6 @@ def acquire_rgb_image(self, config, file_ID, current_path, current_round_images, if self.liveController.trigger_mode == TriggerMode.SOFTWARE: # TODO(imo): use illum controller self.liveController.turn_on_illumination() - self.wait_till_operation_is_completed() # read camera frame self.camera.send_trigger(illumination_time=self.camera.get_exposure_time()) From 860725fd54670f25bd1bec841321aeba7a9b894b Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Fri, 6 Jun 2025 16:25:12 +0800 Subject: [PATCH 04/21] Update information as soon as the axis arrives at the destination --- .../main_controller_teensy41/main_controller_teensy41.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index e9bf783f9..b6d37f7bb 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -308,7 +308,7 @@ volatile bool flag_send_pos_update = false; static const int interval_send_pos_update = 10000; // in us elapsedMicros us_since_last_pos_update; -static const int interval_check_position = 10000; // in us +static const int interval_check_position = 5000; // in us elapsedMicros us_since_last_check_position; static const int interval_send_joystick_update = 30000; // in us @@ -2229,22 +2229,26 @@ void loop() { { X_commanded_movement_in_progress = false; mcu_cmd_execution_in_progress = false || Y_commanded_movement_in_progress || Z_commanded_movement_in_progress || W_commanded_movement_in_progress; + us_since_last_check_position = interval_check_position + 1; } if (Y_commanded_movement_in_progress && tmc4361A_currentPosition(&tmc4361[y]) == Y_commanded_target_position && !is_homing_Y && !tmc4361A_isRunning(&tmc4361[y], stage_PID_enabled[y])) { Y_commanded_movement_in_progress = false; mcu_cmd_execution_in_progress = false || X_commanded_movement_in_progress || Z_commanded_movement_in_progress || W_commanded_movement_in_progress; + us_since_last_check_position = interval_check_position + 1; } if (Z_commanded_movement_in_progress && tmc4361A_currentPosition(&tmc4361[z]) == Z_commanded_target_position && !is_homing_Z && !tmc4361A_isRunning(&tmc4361[z], stage_PID_enabled[z])) { Z_commanded_movement_in_progress = false; mcu_cmd_execution_in_progress = false || X_commanded_movement_in_progress || Y_commanded_movement_in_progress || W_commanded_movement_in_progress; + us_since_last_check_position = interval_check_position + 1; } if (enable_filterwheel == true) { if (W_commanded_movement_in_progress && tmc4361A_currentPosition(&tmc4361[w]) == W_commanded_target_position && !is_homing_W && !tmc4361A_isRunning(&tmc4361[w], stage_PID_enabled[w])) { W_commanded_movement_in_progress = false; mcu_cmd_execution_in_progress = false || X_commanded_movement_in_progress || Y_commanded_movement_in_progress || Z_commanded_movement_in_progress; + us_since_last_check_position = interval_check_position + 1; } } } From d3d0b32d089b67713b692e119cd2b60c60ec00b9 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Wed, 11 Jun 2025 17:21:10 +0800 Subject: [PATCH 05/21] cancel useless code --- .../main_controller_teensy41.ino | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index b6d37f7bb..986891d6f 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -303,7 +303,6 @@ uint16_t home_safety_margin[4] = {4, 4, 4, 4}; // IntervalTimer does not work on teensy with SPI, the below lines are to be removed static const int TIMER_PERIOD = 500; // in us volatile int counter_send_pos_update = 0; -volatile bool flag_send_pos_update = false; static const int interval_send_pos_update = 10000; // in us elapsedMicros us_since_last_pos_update; @@ -2218,7 +2217,6 @@ void loop() { SerialUSB.print(", PG:"); SerialUSB.println(digitalRead(pin_PG)); } - flag_send_pos_update = false; } // keep checking position process at suitable frequence @@ -2290,28 +2288,6 @@ void loop() { } } -/*************************************************** - - timer interrupt - - ***************************************************/ - -// timer interrupt -/* - // IntervalTimer stops working after SPI.begin() - void timer_interruptHandler() - { - SerialUSB.println("timer event"); - counter_send_pos_update = counter_send_pos_update + 1; - if(counter_send_pos_update==interval_send_pos_update/TIMER_PERIOD) - { - flag_send_pos_update = true; - counter_send_pos_update = 0; - SerialUSB.println("send pos update"); - } - } -*/ - /***************************************************************************************************/ /********************************************* utils *********************************************/ /***************************************************************************************************/ From c901147a52b3f593e058996b397b0c22353fe2ea Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Fri, 13 Jun 2025 09:43:35 +0800 Subject: [PATCH 06/21] reformat code --- software/squid/stage/cephla.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/software/squid/stage/cephla.py b/software/squid/stage/cephla.py index 151bdd197..779b8a3dd 100644 --- a/software/squid/stage/cephla.py +++ b/software/squid/stage/cephla.py @@ -108,16 +108,16 @@ def move_y_to(self, abs_mm: float, blocking: bool = True): ) def move_xy_to(self, x_abs_mm: float, y_abs_mm: float, blocking: bool = True): - self._microcontroller.move_xy_to_usteps(self._config.X_AXIS.convert_real_units_to_ustep(x_abs_mm), - self._config.Y_AXIS.convert_real_units_to_ustep(y_abs_mm)) + self._microcontroller.move_xy_to_usteps( + self._config.X_AXIS.convert_real_units_to_ustep(x_abs_mm), + self._config.Y_AXIS.convert_real_units_to_ustep(y_abs_mm), + ) if blocking: x_timeout = self._calc_move_timeout(x_abs_mm - self.get_pos().x_mm, self.get_config().X_AXIS.MAX_SPEED) y_timeout = self._calc_move_timeout(y_abs_mm - self.get_pos().y_mm, self.get_config().Y_AXIS.MAX_SPEED) - self._microcontroller.wait_till_operation_is_completed( - max(x_timeout, y_timeout) - ) + self._microcontroller.wait_till_operation_is_completed(max(x_timeout, y_timeout)) def move_z_to(self, abs_mm: float, blocking: bool = True): # From Hongquan, we want the z axis to rest on the "up" (wrt gravity) direction of gravity. So if we From c6fbcca8c564d9e875040dd683caf7639a01a52f Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Fri, 13 Jun 2025 11:03:42 +0800 Subject: [PATCH 07/21] change S-ramp to Trapezoidal ramp of Z axis --- .../octopi_firmware_v2/main_controller_teensy41/TMC4361A.h | 1 + .../main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp | 5 ++++- .../main_controller_teensy41/main_controller_teensy41.ino | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A.h b/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A.h index e4fa92c56..df5cfff7e 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A.h +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A.h @@ -71,6 +71,7 @@ typedef struct int target_tolerance; int pid_tolerance; + int ramp_mode; } TMC4361ATypeDef; typedef void (*tmc4361A_callback)(TMC4361ATypeDef*, ConfigState); diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp b/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp index 37193e820..cf748f839 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp @@ -468,6 +468,9 @@ void tmc4361A_tmc2660_init(TMC4361ATypeDef *tmc4361A, uint32_t clk_Hz_TMC4361) { // microstepping setting tmc4361A_writeMicrosteps(tmc4361A); tmc4361A_writeSPR(tmc4361A); + + // default value is S-ramp + tmc4361A->ramp_mode = TMC4361A_RAMP_SSHAPE; return; } @@ -983,7 +986,7 @@ void tmc4361A_moveToExtreme(TMC4361ATypeDef *tmc4361A, int32_t vel, int8_t dir) ----------------------------------------------------------------------------- */ void tmc4361A_sRampInit(TMC4361ATypeDef *tmc4361A) { - tmc4361A_setBits(tmc4361A, TMC4361A_RAMPMODE, TMC4361A_RAMP_POSITION | TMC4361A_RAMP_SSHAPE); // positioning mode, s-shaped ramp + tmc4361A_setBits(tmc4361A, TMC4361A_RAMPMODE, TMC4361A_RAMP_POSITION | tmc4361A->ramp_mode); // positioning mode tmc4361A_rstBits(tmc4361A, TMC4361A_GENERAL_CONF, TMC4361A_USE_ASTART_AND_VSTART_MASK); // keep astart, vstart = 0 tmc4361A_writeInt(tmc4361A, TMC4361A_BOW1, tmc4361A->rampParam[BOW1_IDX]); // determines the value which increases the absolute acceleration value. tmc4361A_writeInt(tmc4361A, TMC4361A_BOW2, tmc4361A->rampParam[BOW2_IDX]); // determines the value which decreases the absolute acceleration value. diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index 986891d6f..d66d03b0c 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -1697,6 +1697,7 @@ void loop() { // initilize TMC4361 and TMC2660 for (int i = 0; i < STAGE_AXES; i++) tmc4361A_tmc2660_init(&tmc4361[i], clk_Hz_TMC4361); // set up ICs with SPI control and other parameters + tmc4361[z].ramp_mode = TMC4361A_RAMP_TRAPEZ; // enable limit switch reading tmc4361A_enableLimitSwitch(&tmc4361[x], lft_sw_pol[x], LEFT_SW, flip_limit_switch_x); From b7a9ce2f71d74fc9bba87b752671c75867978f05 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Wed, 18 Jun 2025 10:35:48 +0800 Subject: [PATCH 08/21] make sramp mode to configure method --- .../TMC4361A_TMC2660_Utils.cpp | 3 --- .../main_controller_teensy41.ino | 17 ++++++++++++- software/control/_def.py | 8 ++++++ software/control/microcontroller.py | 25 +++++++++++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp b/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp index cf748f839..00ab67393 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A_TMC2660_Utils.cpp @@ -468,9 +468,6 @@ void tmc4361A_tmc2660_init(TMC4361ATypeDef *tmc4361A, uint32_t clk_Hz_TMC4361) { // microstepping setting tmc4361A_writeMicrosteps(tmc4361A); tmc4361A_writeSPR(tmc4361A); - - // default value is S-ramp - tmc4361A->ramp_mode = TMC4361A_RAMP_SSHAPE; return; } diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index d66d03b0c..673ea74d7 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -69,6 +69,7 @@ static const int SET_STROBE_DELAY = 31; static const int SET_AXIS_DISABLE_ENABLE = 32; static const int MOVE_XY = 33; static const int MOVETO_XY = 34; +static const int SET_SRAMP_MOD = 36; static const int SET_PIN_LEVEL = 41; static const int INITFILTERWHEEL = 253; static const int INITIALIZE = 254; @@ -954,6 +955,21 @@ void loop() { } break; } + case SET_SRAMP_MOD: + { + uint8_t axis = buffer_rx[2]; + uint8_t mode = buffer_rx[3]; + // map to w axis, in the host w axis index is 5 + if (axis == 5) + axis = 3; + + // guard code + if (axis > STAGE_AXES) + return; + + tmc4361[axis].ramp_mode = mode; + break; + } case SET_LIM: { switch (buffer_rx[2]) @@ -1697,7 +1713,6 @@ void loop() { // initilize TMC4361 and TMC2660 for (int i = 0; i < STAGE_AXES; i++) tmc4361A_tmc2660_init(&tmc4361[i], clk_Hz_TMC4361); // set up ICs with SPI control and other parameters - tmc4361[z].ramp_mode = TMC4361A_RAMP_TRAPEZ; // enable limit switch reading tmc4361A_enableLimitSwitch(&tmc4361[x], lft_sw_pol[x], LEFT_SW, flip_limit_switch_x); diff --git a/software/control/_def.py b/software/control/_def.py index 1932529c1..9883d958a 100644 --- a/software/control/_def.py +++ b/software/control/_def.py @@ -147,6 +147,7 @@ class CMD_SET: SET_AXIS_DISABLE_ENABLE = 32 MOVE_XY = 33 MOVETO_XY = 34 + SET_SRAMP_MOD = 36 SET_PIN_LEVEL = 41 INITFILTERWHEEL = 253 INITIALIZE = 254 @@ -428,6 +429,13 @@ def convert_to_enum(option: Union[str, "FocusMeasureOperator"]) -> "FocusMeasure DEFAULT_SAVING_PATH = str(Path.home()) + "/Downloads" FILE_ID_PADDING = 0 +# 0: RAMP_HOLD +# 1: RAMP_TRAPEZ +# 2: RAMP_SSHAPE +X_AXIS_SRAMP_MODE = 2 +Y_AXIS_SRAMP_MODE = 2 +Z_AXIS_SRAMP_MODE = 2 +W_AXIS_SRAMP_MODE = 2 class PLATE_READER: NUMBER_OF_ROWS = 8 diff --git a/software/control/microcontroller.py b/software/control/microcontroller.py index 39506dea5..967fc400a 100644 --- a/software/control/microcontroller.py +++ b/software/control/microcontroller.py @@ -505,6 +505,10 @@ def __init__(self, serial_device: AbstractCephlaMicroSerial, reset_and_initializ self.log.debug("Resetting and initializing microcontroller.") self.reset() time.sleep(0.5) + + # Need set the parameter before initialization + self.initizlize_sramp_of_axes() + if USE_SQUID_FILTERWHEEL: self.init_filter_wheel() time.sleep(0.5) @@ -561,6 +565,17 @@ def reset(self): # here. self._cmd_id = 0 + def initizlize_sramp_of_axes(self): + # initialize axes sramp mode + self.set_sramp_mode(AXIS.X, X_AXIS_SRAMP_MODE) + self.wait_till_operation_is_completed() + self.set_sramp_mode(AXIS.Y, Y_AXIS_SRAMP_MODE) + self.wait_till_operation_is_completed() + self.set_sramp_mode(AXIS.Z, Z_AXIS_SRAMP_MODE) + self.wait_till_operation_is_completed() + self.set_sramp_mode(AXIS.W, W_AXIS_SRAMP_MODE) + self.wait_till_operation_is_completed() + def initialize_drivers(self): self._cmd_id = 0 cmd = bytearray(self.tx_buffer_length) @@ -979,6 +994,9 @@ def configure_squidfilter(self): self.wait_till_operation_is_completed() self.set_max_velocity_acceleration(AXIS.W, MAX_VELOCITY_W_mm, MAX_ACCELERATION_W_mm) self.wait_till_operation_is_completed() + # initialize axes sramp mode + self.set_sramp_mode(AXIS.W, W_AXIS_SRAMP_MODE) + self.wait_till_operation_is_completed() def ack_joystick_button_pressed(self): cmd = bytearray(self.tx_buffer_length) @@ -1012,6 +1030,13 @@ def set_pin_level(self, pin, level): cmd[3] = level self.send_command(cmd) + def set_sramp_mode(self, axis, mode): + cmd = bytearray(self.tx_buffer_length) + cmd[1] = CMD_SET.SET_SRAMP_MOD + cmd[2] = axis + cmd[3] = mode + self.send_command(cmd) + def turn_on_AF_laser(self): self.set_pin_level(MCU_PINS.AF_LASER, 1) From 1c1f88562c9d9351729dd13e5c2db82e9657e250 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Fri, 20 Jun 2025 13:34:07 +0800 Subject: [PATCH 09/21] reformat code --- software/control/_def.py | 1 + 1 file changed, 1 insertion(+) diff --git a/software/control/_def.py b/software/control/_def.py index 9883d958a..3749691f6 100644 --- a/software/control/_def.py +++ b/software/control/_def.py @@ -437,6 +437,7 @@ def convert_to_enum(option: Union[str, "FocusMeasureOperator"]) -> "FocusMeasure Z_AXIS_SRAMP_MODE = 2 W_AXIS_SRAMP_MODE = 2 + class PLATE_READER: NUMBER_OF_ROWS = 8 NUMBER_OF_COLUMNS = 12 From 5cb40c7fd6d49971572fa1a3c07abe8b3e7c7898 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 15 Jul 2025 13:40:47 +0800 Subject: [PATCH 10/21] restore to CMD_LENGTH to 10 --- .../main_controller_teensy41/main_controller_teensy41.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index 673ea74d7..d7442b8fb 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -25,7 +25,7 @@ // byte[2]: how many micro steps - upper 8 bits // byte[3]: how many micro steps - lower 8 bits -static const int CMD_LENGTH = 24; +static const int CMD_LENGTH = 10; static const int MSG_LENGTH = 24; byte buffer_rx[512]; byte buffer_tx[MSG_LENGTH]; From c42791943ece3bae812778273922cfe6deed2087 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 15 Jul 2025 13:52:57 +0800 Subject: [PATCH 11/21] initialize the ramp_mode with TMC4361A_RAMP_SSHAP value --- .../octopi_firmware_v2/main_controller_teensy41/TMC4361A.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A.cpp b/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A.cpp index 2e8b16272..6bcdd8f83 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A.cpp +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/TMC4361A.cpp @@ -29,6 +29,7 @@ */ #include "TMC4361A.h" +#include "TMC4361A_Constants.h" // => SPI wrapper // Send [length] bytes stored in the [data] array over SPI and overwrite [data] @@ -158,6 +159,8 @@ void tmc4361A_init(TMC4361ATypeDef *tmc4361A, uint8_t channel, ConfigurationType tmc4361A->config->configIndex = 0; tmc4361A->config->state = CONFIG_READY; + tmc4361A->ramp_mode = TMC4361A_RAMP_SSHAPE; + int i; for (i = 0; i < TMC4361A_REGISTER_COUNT; i++) { From 3a1aa648ffc74834769eee51dc76401b71d38f72 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 15 Jul 2025 14:06:08 +0800 Subject: [PATCH 12/21] make the code more easy to understand --- .../main_controller_teensy41/main_controller_teensy41.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index d7442b8fb..9cded4e2d 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -960,8 +960,8 @@ void loop() { uint8_t axis = buffer_rx[2]; uint8_t mode = buffer_rx[3]; // map to w axis, in the host w axis index is 5 - if (axis == 5) - axis = 3; + if (axis == AXIS_W) + axis = w; // guard code if (axis > STAGE_AXES) From 8ebcf2c5ffd5ee903ac7a70884bd662e2189c422 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 15 Jul 2025 14:20:04 +0800 Subject: [PATCH 13/21] add comment --- .../main_controller_teensy41/main_controller_teensy41.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index 9cded4e2d..a44cbd7ec 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -2243,6 +2243,9 @@ void loop() { { X_commanded_movement_in_progress = false; mcu_cmd_execution_in_progress = false || Y_commanded_movement_in_progress || Z_commanded_movement_in_progress || W_commanded_movement_in_progress; + // It's important that we check positions next time around because + // once the axis reaches the target position, we need the PC to be notified instantly. + // Other axes are the same reason. us_since_last_check_position = interval_check_position + 1; } if (Y_commanded_movement_in_progress && tmc4361A_currentPosition(&tmc4361[y]) == Y_commanded_target_position && !is_homing_Y && !tmc4361A_isRunning(&tmc4361[y], stage_PID_enabled[y])) From 2f93b688a3e90d2ba0eb0ec9de6d04dc18761f1a Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 15 Jul 2025 14:51:52 +0800 Subject: [PATCH 14/21] slight update --- software/control/_def.py | 1 + software/control/core/multi_point_worker.py | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/software/control/_def.py b/software/control/_def.py index 3749691f6..8c4f18f2b 100644 --- a/software/control/_def.py +++ b/software/control/_def.py @@ -413,6 +413,7 @@ def convert_to_enum(option: Union[str, "FocusMeasureOperator"]) -> "FocusMeasure # end of actuator specific configurations +SCAN_STABILIZATION_TIME_MS = 160 SCAN_STABILIZATION_TIME_MS_X = 160 SCAN_STABILIZATION_TIME_MS_Y = 160 SCAN_STABILIZATION_TIME_MS_Z = 20 diff --git a/software/control/core/multi_point_worker.py b/software/control/core/multi_point_worker.py index a07bb6e2e..278c94981 100644 --- a/software/control/core/multi_point_worker.py +++ b/software/control/core/multi_point_worker.py @@ -328,24 +328,16 @@ def update_coordinates_dataframe(self, region_id, z_level, pos: squid.abc.Pos, f self.coordinates_pd = pd.concat([self.coordinates_pd, new_row], ignore_index=True) def move_to_coordinate(self, coordinate_mm): - print("moving to coordinate", coordinate_mm) + x_mm = coordinate_mm[0] + y_mm = coordinate_mm[1] + have_z = len(coordinate_mm) >= 3 + self.stage.move_xy_to(x_mm, y_mm, blocking=not have_z) - # check if z is included in the coordinate - if len(coordinate_mm) == 3: - x_mm = coordinate_mm[0] - y_mm = coordinate_mm[1] + if have_z: z_mm = coordinate_mm[2] - - self.stage.move_xy_to(x_mm, y_mm, blocking=False) self.move_to_z_level(z_mm) - time.sleep(SCAN_STABILIZATION_TIME_MS_Y / 1000) - else: - x_mm = coordinate_mm[0] - y_mm = coordinate_mm[1] - - self.stage.move_xy_to(x_mm, y_mm) - time.sleep(SCAN_STABILIZATION_TIME_MS_Y / 1000) + time._sleep(SCAN_STABILIZATION_TIME_MS / 1000) def move_to_z_level(self, z_mm): print("moving z") From 6a3c3aca7a4448a0859c3e887e2e860f234f0203 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 15 Jul 2025 15:00:53 +0800 Subject: [PATCH 15/21] remove MOVE_XY temporarily --- .../main_controller_teensy41/main_controller_teensy41.ino | 1 - software/control/_def.py | 1 - 2 files changed, 2 deletions(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index a44cbd7ec..31162e696 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -67,7 +67,6 @@ static const int SET_PID_ARGUMENTS = 29; static const int SEND_HARDWARE_TRIGGER = 30; static const int SET_STROBE_DELAY = 31; static const int SET_AXIS_DISABLE_ENABLE = 32; -static const int MOVE_XY = 33; static const int MOVETO_XY = 34; static const int SET_SRAMP_MOD = 36; static const int SET_PIN_LEVEL = 41; diff --git a/software/control/_def.py b/software/control/_def.py index 8c4f18f2b..f4d993aa3 100644 --- a/software/control/_def.py +++ b/software/control/_def.py @@ -145,7 +145,6 @@ class CMD_SET: SEND_HARDWARE_TRIGGER = 30 SET_STROBE_DELAY = 31 SET_AXIS_DISABLE_ENABLE = 32 - MOVE_XY = 33 MOVETO_XY = 34 SET_SRAMP_MOD = 36 SET_PIN_LEVEL = 41 From b5ee8a5487bf0d5c12213cbc85fba81ac95c925f Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 15 Jul 2025 15:13:06 +0800 Subject: [PATCH 16/21] modify code into AbstractStage class --- software/squid/abc.py | 4 ++++ software/squid/stage/prior.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/software/squid/abc.py b/software/squid/abc.py index dd54e5ef2..0d64d5c57 100644 --- a/software/squid/abc.py +++ b/software/squid/abc.py @@ -162,6 +162,10 @@ def move_x_to(self, abs_mm: float, blocking: bool = True): @abc.abstractmethod def move_y_to(self, abs_mm: float, blocking: bool = True): pass + + @abc.abstractmethod + def move_xy_to(self, x_abs_mm: float, y_abs_mm: float, blocking: bool = True): + pass @abc.abstractmethod def move_z_to(self, abs_mm: float, blocking: bool = True): diff --git a/software/squid/stage/prior.py b/software/squid/stage/prior.py index 04a4d4766..564d546b9 100644 --- a/software/squid/stage/prior.py +++ b/software/squid/stage/prior.py @@ -229,6 +229,9 @@ def move_y_to(self, abs_mm: float, blocking: bool = True): else: threading.Thread(target=self.wait_for_stop, daemon=True).start() + def move_xy_to(self, x_abs_mm: float, y_abs_mm: float, blocking: bool = True): + pass + def move_z_to(self, abs_mm: float, blocking: bool = True): pass From b1e393e87c7335dc276dfdc1343fba5b0a772649 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Tue, 15 Jul 2025 15:15:36 +0800 Subject: [PATCH 17/21] reformat --- software/squid/abc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/squid/abc.py b/software/squid/abc.py index 0d64d5c57..5e945d7f2 100644 --- a/software/squid/abc.py +++ b/software/squid/abc.py @@ -162,7 +162,7 @@ def move_x_to(self, abs_mm: float, blocking: bool = True): @abc.abstractmethod def move_y_to(self, abs_mm: float, blocking: bool = True): pass - + @abc.abstractmethod def move_xy_to(self, x_abs_mm: float, y_abs_mm: float, blocking: bool = True): pass From 10e8ebe391f3f645636d894847b13be28586cd74 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Wed, 16 Jul 2025 16:47:07 +0800 Subject: [PATCH 18/21] bug fixed for CMD_LENGTH change from 24 to 10 --- software/control/_def.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/control/_def.py b/software/control/_def.py index f4d993aa3..8770b2889 100644 --- a/software/control/_def.py +++ b/software/control/_def.py @@ -86,7 +86,7 @@ class PosUpdate: class MicrocontrollerDef: MSG_LENGTH = 24 - CMD_LENGTH = 24 + CMD_LENGTH = 10 N_BYTES_POS = 4 From a9acc9c42fa1639186fdc8158bba9a3527034c2c Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Wed, 16 Jul 2025 16:53:31 +0800 Subject: [PATCH 19/21] bug fixed after self-testing --- software/control/core/multi_point_worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/control/core/multi_point_worker.py b/software/control/core/multi_point_worker.py index 278c94981..f305916d3 100644 --- a/software/control/core/multi_point_worker.py +++ b/software/control/core/multi_point_worker.py @@ -337,7 +337,7 @@ def move_to_coordinate(self, coordinate_mm): z_mm = coordinate_mm[2] self.move_to_z_level(z_mm) - time._sleep(SCAN_STABILIZATION_TIME_MS / 1000) + self._sleep(SCAN_STABILIZATION_TIME_MS / 1000) def move_to_z_level(self, z_mm): print("moving z") From 7d53cc3d3135c67d702f6cd3626d71c87489e194 Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Wed, 16 Jul 2025 18:07:05 +0800 Subject: [PATCH 20/21] bug fix --- .../main_controller_teensy41/main_controller_teensy41.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index 31162e696..dd457351d 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -2245,26 +2245,26 @@ void loop() { // It's important that we check positions next time around because // once the axis reaches the target position, we need the PC to be notified instantly. // Other axes are the same reason. - us_since_last_check_position = interval_check_position + 1; + us_since_last_pos_update = interval_send_pos_update + 1; } if (Y_commanded_movement_in_progress && tmc4361A_currentPosition(&tmc4361[y]) == Y_commanded_target_position && !is_homing_Y && !tmc4361A_isRunning(&tmc4361[y], stage_PID_enabled[y])) { Y_commanded_movement_in_progress = false; mcu_cmd_execution_in_progress = false || X_commanded_movement_in_progress || Z_commanded_movement_in_progress || W_commanded_movement_in_progress; - us_since_last_check_position = interval_check_position + 1; + us_since_last_pos_update = interval_send_pos_update + 1; } if (Z_commanded_movement_in_progress && tmc4361A_currentPosition(&tmc4361[z]) == Z_commanded_target_position && !is_homing_Z && !tmc4361A_isRunning(&tmc4361[z], stage_PID_enabled[z])) { Z_commanded_movement_in_progress = false; mcu_cmd_execution_in_progress = false || X_commanded_movement_in_progress || Y_commanded_movement_in_progress || W_commanded_movement_in_progress; - us_since_last_check_position = interval_check_position + 1; + us_since_last_pos_update = interval_send_pos_update + 1; } if (enable_filterwheel == true) { if (W_commanded_movement_in_progress && tmc4361A_currentPosition(&tmc4361[w]) == W_commanded_target_position && !is_homing_W && !tmc4361A_isRunning(&tmc4361[w], stage_PID_enabled[w])) { W_commanded_movement_in_progress = false; mcu_cmd_execution_in_progress = false || X_commanded_movement_in_progress || Y_commanded_movement_in_progress || Z_commanded_movement_in_progress; - us_since_last_check_position = interval_check_position + 1; + us_since_last_pos_update = interval_send_pos_update + 1; } } } From 68869a58be0ab28715b1d80203aeaa3046fddc4e Mon Sep 17 00:00:00 2001 From: "kevin.wang" Date: Thu, 17 Jul 2025 09:40:48 +0800 Subject: [PATCH 21/21] bug fixed for CMD_LENGTH change from 10 to 12 --- .../main_controller_teensy41/main_controller_teensy41.ino | 2 +- software/control/_def.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino index dd457351d..4d769c867 100644 --- a/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino +++ b/firmware/octopi_firmware_v2/main_controller_teensy41/main_controller_teensy41.ino @@ -25,7 +25,7 @@ // byte[2]: how many micro steps - upper 8 bits // byte[3]: how many micro steps - lower 8 bits -static const int CMD_LENGTH = 10; +static const int CMD_LENGTH = 12; static const int MSG_LENGTH = 24; byte buffer_rx[512]; byte buffer_tx[MSG_LENGTH]; diff --git a/software/control/_def.py b/software/control/_def.py index 8770b2889..6074d8473 100644 --- a/software/control/_def.py +++ b/software/control/_def.py @@ -86,7 +86,7 @@ class PosUpdate: class MicrocontrollerDef: MSG_LENGTH = 24 - CMD_LENGTH = 10 + CMD_LENGTH = 12 N_BYTES_POS = 4