Browse Source

驱动模块支持查看编码器数值

master
zhaohe 4 months ago
parent
commit
70d997ee9f
  1. 2
      a8000_protocol
  2. 8
      sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  3. 2
      sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp
  4. 9
      sdk/components/zcancmder/zcan_protocol_parser.cpp
  5. 1
      sdk/components/zcancmder/zcan_protocol_parser.hpp
  6. 2
      usrc/project_configs.h
  7. 2
      usrc/subboards/subboard30_shake_module/pri_board.h

2
a8000_protocol

@ -1 +1 @@
Subproject commit 86281b73f485c01783197227b58d0a19699c7198
Subproject commit 74042ce3f342868ca2bfdb51a09fddd68ab396c1

8
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;

2
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) ;

9
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]);

1
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);

2
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

2
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

Loading…
Cancel
Save