From 70d997ee9fea5007dbba3a12a47e5148b4eda3cb Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 24 Mar 2025 15:39:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A9=B1=E5=8A=A8=E6=A8=A1=E5=9D=97=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=9F=A5=E7=9C=8B=E7=BC=96=E7=A0=81=E5=99=A8=E6=95=B0?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- a8000_protocol | 2 +- sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp | 8 ++++++-- sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp | 2 ++ sdk/components/zcancmder/zcan_protocol_parser.cpp | 9 +++++++++ sdk/components/zcancmder/zcan_protocol_parser.hpp | 1 + usrc/project_configs.h | 2 +- usrc/subboards/subboard30_shake_module/pri_board.h | 2 +- 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/a8000_protocol b/a8000_protocol index 86281b7..74042ce 160000 --- a/a8000_protocol +++ b/a8000_protocol @@ -1 +1 @@ -Subproject commit 86281b73f485c01783197227b58d0a19699c7198 +Subproject commit 74042ce3f342868ca2bfdb51a09fddd68ab396c1 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 9754667..e42363c 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 @@ -138,6 +138,12 @@ int32_t StepMotorCtrlModule::step_motor_enable(int32_t enable) { return 0; } int32_t StepMotorCtrlModule::step_motor_read_pos(int32_t* pos) { return getnowpos(*pos); } + +int32_t StepMotorCtrlModule::step_motor_read_enc_pos(int32_t* pos) { + *pos = m_stepM1->read_enc_val(); + return 0; +} + int32_t StepMotorCtrlModule::step_motor_stop(int32_t breakstop) { ZLOGI(TAG, "m%d motor_stop %d", m_id, breakstop); m_thread.stop(); @@ -637,8 +643,6 @@ int32_t StepMotorCtrlModule::do_step_motor_easy_move_to(int32_t tox) { return 0; } - - int32_t StepMotorCtrlModule::do_step_motor_easy_move_to_zero() { m_thread.stop(); creg.module_status = 1; 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 1856690..ebdd910 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 @@ -84,6 +84,8 @@ class StepMotorCtrlModule : public ZIModule { virtual int32_t step_motor_enable(int32_t enable) ; virtual int32_t step_motor_read_pos(int32_t* pos) ; + virtual int32_t step_motor_read_enc_pos(int32_t* pos) ; + virtual int32_t step_motor_stop(int32_t breakstop) ; virtual int32_t step_motor_easy_rotate(int32_t direction) ; virtual int32_t step_motor_easy_move_by(int32_t distance) ; diff --git a/sdk/components/zcancmder/zcan_protocol_parser.cpp b/sdk/components/zcancmder/zcan_protocol_parser.cpp index 4f024ee..6b05426 100644 --- a/sdk/components/zcancmder/zcan_protocol_parser.cpp +++ b/sdk/components/zcancmder/zcan_protocol_parser.cpp @@ -48,6 +48,7 @@ void ZCanProtocolParser::initialize(ZCanReceiver* cancmder) { REGFN(step_motor_enable); REGFN(step_motor_read_pos); + REGFN(step_motor_read_enc_pos); REGFN(step_motor_easy_rotate); REGFN(step_motor_easy_move_by); REGFN(step_motor_easy_move_to); @@ -336,6 +337,14 @@ int32_t ZCanProtocolParser::step_motor_read_pos(cmdcontxt_t* cxt) { cxt->acklen = 4; return module->step_motor_read_pos(&ack[0]); } + +int32_t ZCanProtocolParser::step_motor_read_enc_pos(cmdcontxt_t* cxt) { + CHECK_AND_GET_MODULE(0); + int32_t* ack = (int32_t*)cxt->ackbuf; + cxt->acklen = 4; + return module->step_motor_read_enc_pos(&ack[0]); +} + int32_t ZCanProtocolParser::step_motor_easy_rotate(cmdcontxt_t* cxt) { CHECK_AND_GET_MODULE(1); return module->step_motor_easy_rotate(cxt->params[0]); diff --git a/sdk/components/zcancmder/zcan_protocol_parser.hpp b/sdk/components/zcancmder/zcan_protocol_parser.hpp index b552333..9650494 100644 --- a/sdk/components/zcancmder/zcan_protocol_parser.hpp +++ b/sdk/components/zcancmder/zcan_protocol_parser.hpp @@ -64,6 +64,7 @@ class ZCanProtocolParser : public IZCanReceiverListener { CMDFN(step_motor_enable); CMDFN(step_motor_stop); CMDFN(step_motor_read_pos); + CMDFN(step_motor_read_enc_pos); CMDFN(step_motor_easy_rotate); CMDFN(step_motor_easy_move_by); CMDFN(step_motor_easy_move_to); diff --git a/usrc/project_configs.h b/usrc/project_configs.h index fce8bbb..1724e62 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -1,5 +1,5 @@ #pragma once -#define PC_VERSION 1000 +#define PC_VERSION 1001 #define PC_MANUFACTURER "http://www.iflytop.com/" #define PC_PROJECT_NAME "a8000_subboard" #define PC_IFLYTOP_ENABLE_OS 1 diff --git a/usrc/subboards/subboard30_shake_module/pri_board.h b/usrc/subboards/subboard30_shake_module/pri_board.h index 0b630f4..118353d 100644 --- a/usrc/subboards/subboard30_shake_module/pri_board.h +++ b/usrc/subboards/subboard30_shake_module/pri_board.h @@ -44,7 +44,7 @@ #define MOTOR1_MOTOR_DEFAULT_VELOCITY 1200 #define MOTOR1_MIN_D TMC5130_DEFAULT__MIN_D #define MOTOR1_MAX_D TMC5130_DEFAULT__MAX_D -#define MOTOR1_MOTOR_RUN_TO_ZERO_SPEED 1000 +#define MOTOR1_MOTOR_RUN_TO_ZERO_SPEED 400 #define MOTOR1_MOTOR_LOOK_ZERO_EDGE_SPEED 100 #define MOTOR1_MOTOR_VSTART TMC5130_DEFAULT__MOTOR_VSTART #define MOTOR1_MOTOR_A1 TMC5130_DEFAULT__MOTOR_A1