|
发表于 2015-3-12 17:26:24
|
显示全部楼层
楼主,增量式PID,增加量跟PI没有关系,跟PD有关。
比如我做温度控制,设置温度100;P = 0; D = 5; I = 0;
DEBUG:
实际温度90
Error 10 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 50 Uk 6765
Error 10 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 50 Uk 6815
Error 10 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 50 Uk 6865
Error 10 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 50 Uk 6915
Error 10 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 50 Uk 6965
实际温度91
Error 9 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 45 Uk- 5030
Error 9 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 45 Uk- 4985
Error 9 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 45 Uk- 4940
Error 9 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 45 Uk- 4895
Error 9 pError 0 dError 0 Proportion 0 Integral 5 Derivative 0 Incpid_out 45 Uk- 4850
Incpid_out一直是有输出的,刚刚那个朋友估计采用了他的增量,没有用控制量。
增量PID:
int incPIDCalc( struct PID *pp, unsigned int NextPoint )
{
int dError,Error,pError;
//增量法计算公式:
//Pdt=Kp*[E(t)-E(t-1)]+Ki*E(t)+Kd*[E(t)-2*E(t-1)+E(t-2)]
Error = guiSetTMP - NextPoint; // 偏差E(t)
pError = Error - pp->LastError; //E(t)-E(t-1)
dError = Error - 2*pp->LastError + pp->PrevError; //E(t)-2*E(t-1)+E(t-2)
#if 1
PrintfASCII(" Error", Error);
PrintfASCII(" pError", pError);
PrintfASCII(" dError", dError);
PrintfASCII(" Proportion", pp->Proportion);
PrintfASCII(" Integral", pp->Integral);
PrintfASCII(" Derivative", pp->Derivative);
#endif
pp->PrevError = pp->LastError;
pp->LastError = Error;
return ( pp->Proportion * pError //比例
+ pp->Integral * Error //积分项
+ pp->Derivative * dError); // 微分项
}
|
|