|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
#include "sdk/os/zos.hpp"
|
|
|
#include "sdk/os/zos.hpp"
|
|
|
#include "sdk\components\step_motor_45\step_motor_45_scheduler.hpp"
|
|
|
#include "sdk\components\step_motor_45\step_motor_45_scheduler.hpp"
|
|
|
|
|
|
#include "sdk\components\zprotocols\zcancmder_v2\api\api.hpp"
|
|
|
|
|
|
|
|
|
namespace iflytop { |
|
|
namespace iflytop { |
|
|
using namespace std; |
|
|
using namespace std; |
|
@ -11,7 +12,7 @@ using namespace std; |
|
|
* https://iflytop1.feishu.cn/wiki/MtaawWm8yijb0tkpWoic1IhsnZc
|
|
|
* https://iflytop1.feishu.cn/wiki/MtaawWm8yijb0tkpWoic1IhsnZc
|
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
class StepMotor45 { |
|
|
|
|
|
|
|
|
class StepMotor45 : public ZIModule, public ZIMotor { |
|
|
public: |
|
|
public: |
|
|
typedef enum { |
|
|
typedef enum { |
|
|
kstop, |
|
|
kstop, |
|
@ -60,21 +61,24 @@ class StepMotor45 { |
|
|
ZGPIO *m_driverPinZGPIO[4]; |
|
|
ZGPIO *m_driverPinZGPIO[4]; |
|
|
ZGPIO *m_zeroPinZGPIO; |
|
|
ZGPIO *m_zeroPinZGPIO; |
|
|
|
|
|
|
|
|
cfg_t m_cfg; |
|
|
|
|
|
|
|
|
cfg_t m_cfg; |
|
|
|
|
|
int32_t m_module_id; |
|
|
|
|
|
|
|
|
int defaultspeed = 1000; |
|
|
int defaultspeed = 1000; |
|
|
|
|
|
|
|
|
public: |
|
|
public: |
|
|
void initialize(StepMotor45Scheduler *scheduler, cfg_t cfg); |
|
|
|
|
|
|
|
|
void initialize(int32_t module_id, StepMotor45Scheduler *scheduler, cfg_t cfg); |
|
|
|
|
|
|
|
|
int32_t rotate(int direction) { rotate(direction, defaultspeed); } |
|
|
|
|
|
|
|
|
int32_t rotate(int direction) { return rotate(direction, defaultspeed); } |
|
|
int32_t rotate(int direction, int speed); |
|
|
int32_t rotate(int direction, int speed); |
|
|
int32_t move_by(int pos, int speed); |
|
|
int32_t move_by(int pos, int speed); |
|
|
int32_t move_by(int pos) { move_by(pos, defaultspeed); } |
|
|
|
|
|
|
|
|
int32_t move_by(int pos) {return move_by(pos, defaultspeed); } |
|
|
|
|
|
|
|
|
int32_t move_to(int to, int speed); |
|
|
int32_t move_to(int to, int speed); |
|
|
int32_t move_to(int to); |
|
|
int32_t move_to(int to); |
|
|
int32_t set_default_speed(int speed) { defaultspeed = speed; } |
|
|
|
|
|
|
|
|
int32_t set_default_speed(int speed) { defaultspeed = speed; |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
int32_t get_default_speed(int32_t &speed) { |
|
|
int32_t get_default_speed(int32_t &speed) { |
|
|
speed = defaultspeed; |
|
|
speed = defaultspeed; |
|
|
return (int32_t)0; |
|
|
return (int32_t)0; |
|
@ -82,7 +86,9 @@ class StepMotor45 { |
|
|
int32_t is_reach_target_pos(bool &reach); |
|
|
int32_t is_reach_target_pos(bool &reach); |
|
|
int32_t stop(); |
|
|
int32_t stop(); |
|
|
int32_t zero_calibration(); |
|
|
int32_t zero_calibration(); |
|
|
int32_t set_pos(int32_t pos) { m_pos = pos; } |
|
|
|
|
|
|
|
|
int32_t set_pos(int32_t pos) { m_pos = pos; |
|
|
|
|
|
|
|
|
|
|
|
return int32_t(0);} |
|
|
|
|
|
|
|
|
int32_t get_zero_pin_state(int32_t &state); |
|
|
int32_t get_zero_pin_state(int32_t &state); |
|
|
|
|
|
|
|
@ -91,6 +97,44 @@ class StepMotor45 { |
|
|
return (int32_t)0; |
|
|
return (int32_t)0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
* OVERRIDE MODULE * |
|
|
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t getid(int32_t *id) override; |
|
|
|
|
|
virtual int32_t module_stop() override; |
|
|
|
|
|
virtual int32_t module_break() override; |
|
|
|
|
|
virtual int32_t module_get_last_exec_status(int32_t *status) override; |
|
|
|
|
|
virtual int32_t module_get_status(int32_t *status) override; |
|
|
|
|
|
virtual int32_t module_get_error(int32_t *iserror) override; |
|
|
|
|
|
virtual int32_t module_clear_error() override; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t module_set_param(int32_t param_id, int32_t param_value) override; |
|
|
|
|
|
virtual int32_t module_get_param(int32_t param_id, int32_t *param_value) override; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t module_readio(int32_t *io) override; |
|
|
|
|
|
virtual int32_t module_writeio(int32_t io) override; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t module_read_adc(int32_t adcindex, int32_t *adc) override; |
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
* Motor * |
|
|
|
|
|
*******************************************************************************/ |
|
|
|
|
|
virtual int32_t motor_enable(int32_t enable) override; |
|
|
|
|
|
virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) override; |
|
|
|
|
|
virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) override; |
|
|
|
|
|
virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) override; |
|
|
|
|
|
virtual int32_t motor_move_to_with_torque(int32_t pos, int32_t torque) override; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) override; |
|
|
|
|
|
virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override; |
|
|
|
|
|
virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) override; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|
|
|
|
|
virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t motor_read_pos(int32_t *pos); |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
bool getzeropinstate(); |
|
|
bool getzeropinstate(); |
|
|
void setdriverpinstate(bool s1, bool s2, bool s3, bool s4); |
|
|
void setdriverpinstate(bool s1, bool s2, bool s3, bool s4); |
|
@ -102,4 +146,4 @@ class StepMotor45 { |
|
|
void onTimIRQ1ms(); |
|
|
void onTimIRQ1ms(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
} // namespace iflytop
|
|
|
|
|
|
|
|
|
} // namespace iflytop
|