完成了LKmotor模块的重构,优化了DJIMotor的反馈计算

This commit is contained in:
NeoZng
2022-12-11 20:48:24 +08:00
parent 78cc27ee1a
commit 2f41e67de0
15 changed files with 274 additions and 245 deletions

View File

@@ -6,32 +6,60 @@
#include "controller.h"
#include "motor_def.h"
#define LK_MOTOR_CNT 2
#define LK_MOTOR_MX_CNT 4
#define I_MIN -2000
#define I_MAX 2000
#define CURRENT_SMOOTH_COEF 0.9f
#define SPEED_SMOOTH_COEF 0.85f
#define REDUCTION_RATIO_DRIVEN 1
#define ECD_ANGLE_COEF (360.0f/65536.0f)
typedef struct // 9025
{
uint16_t last_ecd;
uint16_t ecd;
int16_t speed_rpm;
int16_t real_current;
uint8_t temperate;
uint16_t last_ecd;// 上一次读取的编码器值
uint16_t ecd; //
float angle_single_round; // 单圈角度
float speed_aps; // speed angle per sec(degree:°)
int16_t real_current; // 实际电流
uint8_t temperate; //温度,C°
PIDInstance *pid;
CANInstance *motor_can_instance;
float total_angle; // 总角度
int32_t total_round; //总圈数
} driven_instance;
} LKMotor_Measure_t;
typedef enum
typedef struct
{
unused = 0,
} driven_mode;
LKMotor_Measure_t measure;
driven_instance *LKMotroInit(CAN_Init_Config_s config);
Motor_Control_Setting_s motor_settings;
void DrivenControl(int16_t motor1_current, int16_t motor2_current);
float *other_angle_feedback_ptr; // 其他反馈来源的反馈数据指针
float *other_speed_feedback_ptr;
PIDInstance current_PID;
PIDInstance speed_PID;
PIDInstance angle_PID;
float pid_ref;
Motor_Working_Type_e stop_flag; // 启停标志
CANInstance* motor_can_ins;
}LKMotorInstance;
LKMotorInstance *LKMotroInit(Motor_Init_Config_s* config);
void LKMotorSetRef(LKMotorInstance* motor,float ref);
void LKMotorControl();
void LKMotorStop(LKMotorInstance *motor);
void LKMotorEnable(LKMotorInstance *motor);
void LKMotorSetRef(LKMotorInstance *motor,float ref);
void SetDrivenMode(driven_mode cmd, uint16_t motor_id);
#endif // LK9025_H