Browse Source

v1011 | 修复step_motor_ctrl_module 编码器不同步的BUG

master
zhaohe 4 months ago
parent
commit
a17dc72426
  1. 8
      sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  2. 1
      sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp
  3. 2
      usrc/version.h

8
sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp

@ -610,7 +610,7 @@ int32_t StepMotorCtrlModule::do_step_motor_easy_rotate(int32_t direction) {
befor_motor_move(); befor_motor_move();
{ {
// rotate(direction, m_cfg.motor_default_velocity); // rotate(direction, m_cfg.motor_default_velocity);
m_stepM1->rotate(direction >= 0 ? m_cfg.motor_default_velocity : -m_cfg.motor_default_velocity);
rotateInVelocityMode(direction >= 0 ? m_cfg.motor_default_velocity : -m_cfg.motor_default_velocity);
while (true) { while (true) {
if (m_thread.getExitFlag()) break; if (m_thread.getExitFlag()) break;
@ -790,9 +790,15 @@ int32_t StepMotorCtrlModule::moveTo(int32_t x, int32_t v) {
return 0; return 0;
} }
int32_t StepMotorCtrlModule::rotate(int32_t direction, int32_t v) { int32_t StepMotorCtrlModule::rotate(int32_t direction, int32_t v) {
trysyncpos();
m_stepM1->moveToEnd(direction, v); m_stepM1->moveToEnd(direction, v);
return 0; return 0;
} }
int32_t StepMotorCtrlModule::rotateInVelocityMode(int32_t v) {
trysyncpos();
m_stepM1->rotate(v);
return 0;
}
int32_t StepMotorCtrlModule::update_dzero(int32_t dzero) { int32_t StepMotorCtrlModule::update_dzero(int32_t dzero) {
int32_t now; int32_t now;

1
sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp

@ -149,6 +149,7 @@ class StepMotorCtrlModule : public ZIModule {
int32_t moveTo(int32_t x, int32_t v); int32_t moveTo(int32_t x, int32_t v);
int32_t moveBy(int32_t dx, int32_t v); int32_t moveBy(int32_t dx, int32_t v);
int32_t rotate(int32_t direction, int32_t v); int32_t rotate(int32_t direction, int32_t v);
int32_t rotateInVelocityMode(int32_t v);
int32_t update_dzero(int32_t dzero); int32_t update_dzero(int32_t dzero);
bool waitforstop(function<bool()> checkstop, int checkperiod = 20); bool waitforstop(function<bool()> checkstop, int checkperiod = 20);

2
usrc/version.h

@ -1,2 +1,2 @@
#pragma once #pragma once
#define PC_VERSION 1010
#define PC_VERSION 1011
Loading…
Cancel
Save