#ifndef _PID_CONTROLLER_H #define _PID_CONTROLLER_H #include "zf_common_typedef.h" // PID 优化环节使能标志位,通过位与可以判断启用的优化环节;也可以改成位域的形式 typedef enum { PID_IMPROVE_NONE = 0b00000000, // 0000 0000 PID_Integral_Limit = 0b00000001, // 0000 0001 PID_Derivative_On_Measurement = 0b00000010, // 0000 0010 PID_Trapezoid_Intergral = 0b00000100, // 0000 0100 PID_Yaw_Error_Corretion = 0b00001000, // 0000 1000 PID_OutputFilter = 0b00010000, // 0001 0000 PID_ChangingIntegrationRate = 0b00100000, // 0010 0000 PID_DerivativeFilter = 0b01000000, // 0100 0000 PID_ErrorHandle = 0b10000000, // 1000 0000 } PID_Improvement_e; /* PID 报错类型枚举*/ typedef enum errorType_e { PID_ERROR_NONE = 0x00U, PID_MOTOR_BLOCKED_ERROR = 0x01U } ErrorType_e; typedef struct { uint64_t ERRORCount; ErrorType_e ERRORType; } PID_ErrorHandler_t; /* PID结构体 */ typedef struct { //---------------------------------- init config block // config parameter float Kp; float Ki; float Kd; float MaxOut; float DeadBand; // improve parameter PID_Improvement_e Improve; float IntegralLimit; // 积分限幅 float CoefA; // 变速积分 For Changing Integral float CoefB; // 变速积分 ITerm = Err*((A-abs(err)+B)/A) when B<|err|