📄 pid.c
字号:
#include "DSP281x_Device.h"
#include "pid.h"
//PID Calculation Program
Uint32 PIDCalc(struct STRUCT_PID *pp,Uint32 NextPoint,Uint32 SetPoint)
{
Uint32 dError,Error;
pp->SetPoint=SetPoint;
Error=pp->SetPoint-NextPoint; //deviation
pp->SumError+=Error; //Integral
dError=pp->LastError-pp->PrevError; //Current Derivative
pp->PrevError=pp->LastError;
pp->LastError=Error;
return(pp->Proportion*Error //proprotion term
+pp->Integral*pp->SumError //Integral term
+pp->Derivative*dError); //Derivative term
}
//PID intialization Program
void PID_Init(struct STRUCT_PID *pp)
{
struct STRUCT_PID *pid;
pid=pp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -