| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- #ifndef __MOTOR_DEFINE_H
- #define __MOTOR_DEFINE_H
- typedef enum{
- MOTOR_CW = 0,
- MOTOR_CCW = 1,
-
- }MotorDirection;
- typedef enum{
- MOTOR_SENSOR_LESS = 0,
- MOTOR_SENSOR_HALL = 1,
- MOTOR_SENSOR_ENCODER = 2,
- }MotorSensor;
- // 状态枚举
- typedef enum {
- CTRL_STATE_IDLE = 0,
- CTRL_STATE_STARTUP_RAMP = 1 , // 启动电流斜坡
- CTRL_STATE_OPENLOOP_RUN = 2, // 开环运行等待达到速度
- CTRL_STATE_ALIGNMENT = 3, // 角度对齐阶段
- CTRL_STATE_TRANSITION_BLENDING = 4, // 过渡融合阶段
- CTRL_STATE_HALL_CLOSED_LOOP = 5, // 霍尔闭环运行
- CTRL_STATE_STOPPING = 6 // 停车处理
- } ControlState_e;
- typedef struct{
- MotorDirection direction; // 电机旋转方向 0 CW 1 CCW
- unsigned char poles; // 电机极数
- MotorSensor sensor; // 传感器类型 0 无感 1 霍尔 2 编码器
- float eleangle; // 电机当前电角度
- ControlState_e ctrl_state; // 当前电机状态
-
- }MotorParam_t;
- extern MotorParam_t* get_motor(void);
- #endif
|