zhaohe 1 year ago
parent
commit
cfac84c0be
  1. 4
      components/step_motor_ctrl_module/tmc51x0_motor.cpp
  2. 4
      components/tmc/ic/ztmc5130.cpp
  3. 6
      components/tmc/ic/ztmc5130.hpp

4
components/step_motor_ctrl_module/tmc51x0_motor.cpp

@ -164,6 +164,7 @@ int32_t TMC51X0Motor::move_to_zero(action_cb_status_t status_cb) {
int32_t erro = _exec_move_to_zero_task(dx);
if (erro == 0) {
m_stepM1->setXACTUAL(0);
m_stepM1->setENCVAL(0);
}
call_exec_status_cb(erro, status_cb);
},
@ -193,6 +194,8 @@ int32_t TMC51X0Motor::move_to_zero_with_calibrate(int32_t nowx, action_cb_status
m_param.motor_shift = calibrate_x;
m_stepM1->setXACTUAL(0);
m_stepM1->setENCVAL(0);
call_exec_status_cb(erro, status_cb);
return;
});
@ -615,6 +618,7 @@ int32_t TMC51X0Motor::motor_calculated_pos_by_move_to_zero() {
m_com_reg.module_last_cmd_exec_status = erro;
set_last_exec_status(erro, -dx + m_param.motor_shift);
m_stepM1->setXACTUAL(0);
m_stepM1->setENCVAL(0);
}
},
[this]() { _motor_stop(); });

4
components/tmc/ic/ztmc5130.cpp

@ -141,7 +141,9 @@ uint8_t TMC5130::reset() {
}
int32_t TMC5130::getXACTUAL() { return to_user_pos(readInt(TMC5130_XACTUAL)); }
void TMC5130::setXACTUAL(int32_t value) { writeInt(TMC5130_XACTUAL, to_motor_pos(value)); }
void TMC5130::setXACTUAL(int32_t value) { writeInt(TMC5130_XACTUAL, to_motor_pos(value)); }
void TMC5130::setENCVAL(int32_t val) { writeInt(TMC5130_XENC, to_motor_pos(val)); }
int32_t TMC5130::getVACTUAL() { return to_user_pos(readInt(TMC5130_VACTUAL)); }
int32_t TMC5130::getENCVAL() { return to_user_pos(readInt(TMC5130_XENC)); }

6
components/tmc/ic/ztmc5130.hpp

@ -112,9 +112,11 @@ class TMC5130 : public IStepperMotor {
uint32_t readICVersion(); // 5130:0x11 5160:0x30
virtual int32_t getXACTUAL(); // 读取电机当前位置,与编码器的位置值不同,该值是电机在不丢步的情况下的位置
virtual void setXACTUAL(int32_t value); // 设置电机当前位置,与编码器的位置值不同,该值是电机在不丢步的情况下的位置
void setENCVAL(int32_t val);
virtual int32_t getVACTUAL(); // 读取电机当前位置,与编码器的位置值不同,该值是电机在不丢步的情况下的位置
virtual int32_t getENCVAL(); //
virtual int32_t getVACTUAL(); // 读取电机当前位置,与编码器的位置值不同,该值是电机在不丢步的情况下的位置
virtual int32_t getENCVAL(); //
uint32_t readXTARGET(); // 读取驱动器目标位置
virtual int32_t getENC_POS() { return 0; } // TODO impl it

Loading…
Cancel
Save