From 0916e80da67e67192912b6e8bf5a79170d55166f Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 25 Jul 2024 11:20:14 +0800 Subject: [PATCH] update --- a8000_protocol | 2 +- .../step_motor_ctrl_module/step_motor_ctrl_module.cpp | 12 +++++++++++- .../step_motor_ctrl_module/step_motor_ctrl_module.hpp | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/a8000_protocol b/a8000_protocol index 826f059..f27f273 160000 --- a/a8000_protocol +++ b/a8000_protocol @@ -1 +1 @@ -Subproject commit 826f05973b88e7f311373d9f7d1ce74a2554512f +Subproject commit f27f273732bc2e98dbee3ff88897c1db054ae10d diff --git a/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index e80e8e7..2e73e44 100644 --- a/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp @@ -113,6 +113,7 @@ int32_t StepMotorCtrlModule::pri_module_xxx_reg(int32_t param_id, bool read, int PROCESS_REG(kreg_step_motor_dzero_pos, REG_GET(m_cfg.motor_dzero), update_dzero(m_cfg.motor_dzero)); PROCESS_REG(kret_step_motor_pos_devi_tolerance, REG_GET(m_cfg.pos_devi_tolerance), REG_SET(m_cfg.pos_devi_tolerance)); + PROCESS_REG(kret_step_motor_io_trigger_append_distance, REG_GET(m_cfg.io_trigger_append_distance), REG_SET(m_cfg.io_trigger_append_distance)); default: return err::kmodule_not_find_reg; @@ -381,6 +382,14 @@ bool StepMotorCtrlModule::exec_move_to_io_task(int32_t ioindex, int32_t directio if (!check_when_run()) return false; + // + int32_t targetpos = getnowpos() + m_cfg.io_trigger_append_distance; + if (direction < 0) { + targetpos = getnowpos() - m_cfg.io_trigger_append_distance; + } + moveTo(targetpos, m_cfg.motor_default_velocity); + waitforstop(nullptr); + if (m_thread.getExitFlag()) { ZLOGW(TAG, "break move to zero thread exit"); return true; @@ -605,10 +614,11 @@ int32_t StepMotorCtrlModule::do_step_motor_easy_move_to_zero() { break; } moveToZeroSuc = true; + } while (false); after_motor_move(); if (moveToZeroSuc) { - setnowpos(0 + m_cfg.motor_dzero); + setnowpos(0 + m_cfg.motor_dzero - m_cfg.io_trigger_append_distance); } }, [this]() { m_stepM1->stop(); }); diff --git a/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp b/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp index 2bd5d98..0103727 100644 --- a/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp +++ b/sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp @@ -34,6 +34,7 @@ class StepMotorCtrlModule : public ZIModule, public ZIStepMotor { int32_t motor_enable_enc; int32_t motor_dzero; // 零点偏移 int32_t pos_devi_tolerance; + int32_t io_trigger_append_distance; } config_t; typedef struct {