From 3062f53dc903beaaa8ccbb0151d95a2da731f78e Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 19 Jul 2025 17:57:05 +0800 Subject: [PATCH] Auto-commit: 6 modified files --- .vscode/settings.json | 3 ++- .../step_motor_ctrl_module.cpp | 31 ++++++++++++++++------ .../step_motor_ctrl_module.hpp | 2 ++ usrc/a8000_protocol/protocol/reg_index.cpp | 3 +++ usrc/a8000_protocol/protocol/reg_index.hpp | 3 ++- usrc/version.h | 2 +- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7d46de6..d1222ff 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -54,5 +54,6 @@ "typeinfo": "cpp" }, "files.autoGuessEncoding": false, - "files.encoding": "utf8" + "files.encoding": "utf8", + "autoGitCopilot.enabled": true } \ No newline at end of file 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 95371ec..7ebdaac 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 @@ -16,7 +16,6 @@ void StepMotorCtrlModule::initialize(int moduleid, TMC51X0* stepM, ZGPIO iotable m_iotable = iotable; m_nio = nio; - m_thread.init(TAG, 1024, osPriorityNormal); m_cfg = *cfg; m_default_cfg = *cfg; @@ -442,13 +441,13 @@ bool StepMotorCtrlModule::exec_move_to_io_task(int32_t ioindex, int32_t directio if (!check_when_run()) return false; - if (!getIOState(ioindex)) { + if (isIORelease(ioindex)) { ZLOGI(TAG, "---------STEP1-------- move to point"); rotate(direction, runToPointSpeed); bool xreach_io = false; while (!m_thread.getExitFlag()) { - if (getIOState(ioindex)) { + if (isIOTrigger(ioindex)) { xreach_io = true; m_stepM1->stop(); break; @@ -474,13 +473,13 @@ bool StepMotorCtrlModule::exec_move_to_io_task(int32_t ioindex, int32_t directio // 如果设备已经在零点,则反向移动一定距离远离零点 - if (getIOState(ioindex)) { + if (isIOTrigger(ioindex)) { ZLOGI(TAG, "---------STEP2-------- find edge"); rotate(-direction, lookPointVelocity); bool reach_edge = false; while (!m_thread.getExitFlag()) { - if (!getIOState(ioindex)) { + if (isIORelease(ioindex)) { reach_edge = true; m_stepM1->stop(); break; @@ -503,13 +502,13 @@ bool StepMotorCtrlModule::exec_move_to_io_task(int32_t ioindex, int32_t directio if (!check_when_run()) return false; // 如果设备已经在零点,则反向移动一定距离远离零点 - if (!getIOState(ioindex)) { + if (isIORelease(ioindex)) { ZLOGI(TAG, "---------STEP3-------- bak to gpio trigger edge"); rotate(direction, lookPointVelocity); bool reach_edge = false; while (!m_thread.getExitFlag()) { - if (getIOState(ioindex)) { + if (isIOTrigger(ioindex)) { reach_edge = true; m_stepM1->stop(); break; @@ -632,7 +631,6 @@ int32_t StepMotorCtrlModule::step_motor_easy_move_to_zero() { return err::kstep_motor_ioindex_out_of_range; } - return do_step_motor_easy_move_to_zero(); } int32_t StepMotorCtrlModule::step_motor_easy_move_to_io(int32_t ioindex, int32_t direction) { @@ -997,3 +995,20 @@ bool StepMotorCtrlModule::getIOState(int32_t ioindex) { return m_iotable[ioindex].getState(); } } + +bool StepMotorCtrlModule::isIOTrigger(int32_t ioindex) { + for (int i = 0; i < 10; i++) { + bool state = getIOState(ioindex); + if (!state) return false; + zos_early_delayus(100); + } + return true; +} +bool StepMotorCtrlModule::isIORelease(int32_t ioindex) { + for (int i = 0; i < 10; i++) { + bool state = getIOState(ioindex); + if (state) return false; + zos_early_delayus(100); + } + return true; +} 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 f2cf14a..8928a06 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 @@ -165,5 +165,7 @@ class StepMotorCtrlModule : public ZIModule { private: int32_t getspeed(int32_t speedlevel); bool getIOState(int32_t ioindex); + bool isIOTrigger(int32_t ioindex); + bool isIORelease(int32_t ioindex); }; } // namespace iflytop \ No newline at end of file diff --git a/usrc/a8000_protocol/protocol/reg_index.cpp b/usrc/a8000_protocol/protocol/reg_index.cpp index 3548746..64ae375 100644 --- a/usrc/a8000_protocol/protocol/reg_index.cpp +++ b/usrc/a8000_protocol/protocol/reg_index.cpp @@ -194,6 +194,9 @@ static reginfo_t table[] = { REG_ITERM(kreg_step_motor_dzero_pos), REG_ITERM(kreg_step_motor_pos_devi_tolerance), REG_ITERM(kreg_step_motor_io_trigger_append_distance), + REG_ITERM(kreg_step_motor_zero_io_mirror), + REG_ITERM(kreg_step_motor_limit_io_mirror), + REG_ITERM(kreg_step_motor_io_filter_times), REG_ITERM(kreg_mini_servo_pos), REG_ITERM(kreg_mini_servo_is_enable), diff --git a/usrc/a8000_protocol/protocol/reg_index.hpp b/usrc/a8000_protocol/protocol/reg_index.hpp index ba7e769..b67e937 100644 --- a/usrc/a8000_protocol/protocol/reg_index.hpp +++ b/usrc/a8000_protocol/protocol/reg_index.hpp @@ -218,7 +218,8 @@ typedef enum { kreg_step_motor_pos_devi_tolerance = 10192, // 位置偏差容忍度 kreg_step_motor_io_trigger_append_distance = 10193, // 移动到IO时,会在原点触发的边沿,稍稍里面移动一点,用来保证IO稳定触发 kreg_step_motor_zero_io_mirror = 10194, // 零点IO有效位是否翻转 - kreg_step_motor_limit_io_mirror = 10195, // 零点IO有效位是否翻转 + kreg_step_motor_limit_io_mirror = 10195, // 限位IO有效位是否翻转 + kreg_step_motor_io_filter_times = 10196, // IO过滤次数 /*********************************************************************************************************************** * step_motor * diff --git a/usrc/version.h b/usrc/version.h index 4a3f824..d6d51dc 100644 --- a/usrc/version.h +++ b/usrc/version.h @@ -1,2 +1,2 @@ #pragma once -#define APP_VERSION 1212 +#define APP_VERSION 1213