Browse Source

Auto-commit: 6 modified files

master
zhaohe 2 weeks ago
parent
commit
3062f53dc9
  1. 3
      .vscode/settings.json
  2. 31
      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. 3
      usrc/a8000_protocol/protocol/reg_index.cpp
  5. 3
      usrc/a8000_protocol/protocol/reg_index.hpp
  6. 2
      usrc/version.h

3
.vscode/settings.json

@ -54,5 +54,6 @@
"typeinfo": "cpp"
},
"files.autoGuessEncoding": false,
"files.encoding": "utf8"
"files.encoding": "utf8",
"autoGitCopilot.enabled": true
}

31
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;
}

2
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

3
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),

3
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 *

2
usrc/version.h

@ -1,2 +1,2 @@
#pragma once
#define APP_VERSION 1212
#define APP_VERSION 1213
Loading…
Cancel
Save