From 05b93b8bb6d503d2d6cdacb045cb8bfca995d84f Mon Sep 17 00:00:00 2001 From: zhaohe Date: Fri, 7 Jun 2024 09:51:55 +0800 Subject: [PATCH] update --- components/step_motor_ctrl_module/step_motor_ctrl_module.cpp | 2 ++ components/tmc/ic/ztmc5130.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index 1f4f033..b8fb62e 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp @@ -497,7 +497,9 @@ bool StepMotorCtrlModule::exec_move_to_io_task(int32_t ioindex, int32_t directio void StepMotorCtrlModule::_rotate(int32_t velocity, int32_t acc) { if (velocity > 0) { m_stepM1->moveToEnd(1, abs(velocity)); + // m_stepM1->rotate(velocity); } else { + // m_stepM1->rotate(velocity); m_stepM1->moveToEnd(-1, abs(velocity)); } } diff --git a/components/tmc/ic/ztmc5130.cpp b/components/tmc/ic/ztmc5130.cpp index b279d5e..94c251e 100644 --- a/components/tmc/ic/ztmc5130.cpp +++ b/components/tmc/ic/ztmc5130.cpp @@ -199,14 +199,15 @@ void TMC51X0::moveTo(int32_t position, uint32_t velocityMax) { writeInt(TMC5130_XTARGET, position); } void TMC51X0::moveToEnd(int32_t direction, uint32_t velocityMax) { - if (direction > 0) { + ZLOGI("TMC5130", "moveToEnd %d %d", direction, velocityMax); + if (direction >= 0) { writeInt(TMC5130_RAMPMODE, TMC5130_MODE_POSITION); writeInt(TMC5130_VMAX, to_motor_vel(velocityMax)); - writeInt(TMC5130_XTARGET, INT32_MAX); + writeInt(TMC5130_XTARGET, INT32_MAX / 2 - 1000); } else { writeInt(TMC5130_RAMPMODE, TMC5130_MODE_POSITION); writeInt(TMC5130_VMAX, to_motor_vel(velocityMax)); - writeInt(TMC5130_XTARGET, INT32_MIN); + writeInt(TMC5130_XTARGET, INT32_MIN / 2 + 1000); } }