|
@ -21,6 +21,7 @@ void XYRobotCtrlModule::initialize(int32_t id, TMC51X0* stepM1, TMC51X0* stepM2, |
|
|
m_thread.init("XYRobotCtrlModule", 1024, osPriorityNormal); |
|
|
m_thread.init("XYRobotCtrlModule", 1024, osPriorityNormal); |
|
|
module_active_cfg(); |
|
|
module_active_cfg(); |
|
|
xymotor_enable(1); |
|
|
xymotor_enable(1); |
|
|
|
|
|
m_state.has_move_to_zero = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void XYRobotCtrlModule::create_default_cfg(config_t& cfg) { |
|
|
void XYRobotCtrlModule::create_default_cfg(config_t& cfg) { |
|
@ -52,6 +53,10 @@ int32_t XYRobotCtrlModule::xymotor_enable(int32_t enable) { |
|
|
m_stepM1->enable(enable); |
|
|
m_stepM1->enable(enable); |
|
|
m_stepM2->enable(enable); |
|
|
m_stepM2->enable(enable); |
|
|
m_state.is_enable = enable; |
|
|
m_state.is_enable = enable; |
|
|
|
|
|
if (enable == 0 && m_cfg.enable_enc == 0) { |
|
|
|
|
|
m_state.has_move_to_zero = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
int32_t XYRobotCtrlModule::do_public_check() { |
|
|
int32_t XYRobotCtrlModule::do_public_check() { |
|
@ -126,6 +131,10 @@ int32_t XYRobotCtrlModule::xymotor_move_to(int32_t x, int32_t y) { |
|
|
return err::kxymotor_target_pos_outof_range; |
|
|
return err::kxymotor_target_pos_outof_range; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_state.has_move_to_zero == 0) { |
|
|
|
|
|
return err::kxymotor_not_move_to_zero; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return do_xymotor_move_to(x, y); |
|
|
return do_xymotor_move_to(x, y); |
|
|
} |
|
|
} |
|
|
int32_t XYRobotCtrlModule::xymotor_move_by(int32_t dx, int32_t dy) { |
|
|
int32_t XYRobotCtrlModule::xymotor_move_by(int32_t dx, int32_t dy) { |
|
@ -151,7 +160,7 @@ int32_t XYRobotCtrlModule::xymotor_read_pos(int32_t* x, int32_t* y) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#define UPDATE_CFG(key) PROCESS_REG(kreg_xyrobot_##key, REG_GET(m_cfg.key), REG_SET(m_cfg.key))
|
|
|
#define UPDATE_CFG(key) PROCESS_REG(kreg_xyrobot_##key, REG_GET(m_cfg.key), REG_SET(m_cfg.key))
|
|
|
#define READ_STATE(key) PROCESS_REG(kreg_xyrobot_##key, REG_GET(m_state.key),ACTION_NONE)
|
|
|
|
|
|
|
|
|
#define READ_STATE(key) PROCESS_REG(kreg_xyrobot_##key, REG_GET(m_state.key), ACTION_NONE)
|
|
|
int32_t XYRobotCtrlModule::module_xxx_reg(int32_t param_id, bool read, int32_t& val) { |
|
|
int32_t XYRobotCtrlModule::module_xxx_reg(int32_t param_id, bool read, int32_t& val) { |
|
|
int32_t ret = __module_xxx_reg(param_id, read, val); |
|
|
int32_t ret = __module_xxx_reg(param_id, read, val); |
|
|
if (ret != 0) { |
|
|
if (ret != 0) { |
|
@ -197,6 +206,8 @@ int32_t XYRobotCtrlModule::__module_xxx_reg(int32_t param_id, bool read, int32_t |
|
|
UPDATE_CFG(pos_devi_tolerance); |
|
|
UPDATE_CFG(pos_devi_tolerance); |
|
|
UPDATE_CFG(io_trigger_append_distance); |
|
|
UPDATE_CFG(io_trigger_append_distance); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
READ_STATE(has_move_to_zero); |
|
|
READ_STATE(is_enable); |
|
|
READ_STATE(is_enable); |
|
|
default: |
|
|
default: |
|
|
return err::kmodule_not_find_reg; |
|
|
return err::kmodule_not_find_reg; |
|
@ -247,6 +258,7 @@ int32_t XYRobotCtrlModule::do_xymotor_move_to_zero() { |
|
|
after_motor_move(); |
|
|
after_motor_move(); |
|
|
if (ecode == 0) { |
|
|
if (ecode == 0) { |
|
|
setnowpos(0, 0); |
|
|
setnowpos(0, 0); |
|
|
|
|
|
m_state.has_move_to_zero = 1; |
|
|
} |
|
|
} |
|
|
return; |
|
|
return; |
|
|
}); |
|
|
}); |
|
|