引用 1176764177:
翠翠你有pid的资料么这坑爹东西无法理解啊
位置式PID
typedef struct PID
{
int SetPoint; // Desired Value
float Kp; // Proportional Const
float Ki; // Integral Const
float Kd; // Derivative Const
int LastError; //
int SumError; //
} PID;
PID Servo_PID;
float PIDCalc( PID *pp, float NextPoint )
{
int32_t dError,Error;
Error = NextPoint-pp->SetPoint; //
pp->SumError += Error; //
dError = Error-pp->LastError; //
// pp->PrevError = pp->LastError; //
pp->LastError = Error;
return (pp->Kp * Error // P
+ pp->Ki * pp->SumError //I
+ pp->Kd * dError// D
);
}