PID核心算法:
double PIDCalc( PID *pp, double NextPoint )
{
double dError,Error;
Error = pp->SetPoint - NextPoint; // 偏差
pp->SumError += Error; // 积分
dError = pp->LastError - pp->PrevError; // 当前微分
pp->PrevError = pp->LastError;
pp->LastError = Error;
return (pp->Proportion * Error // 比例项
+ pp->Integral * pp->SumError // 积分项
+ pp->Derivative * dError // 微分项
);
}
整定参数:
sPID.Proportion = 2;
sPID.Integral = 0;
sPID.Derivative = 5;
sPID.SetPoint = 37.0;
实验效果,目标37:
以下是上位机软件介绍--------------------------------------------------------------------------------------------
调PID,遂寻上位机软件,得此佳物,甚喜,同分享:
https://static.assets-stash.eet-china.com/album/old-resources/2010/2/8/cf942757-7ea7-4347-b7d3-f6fbff4c973d.rar
发送格式如下,波特率9600,COM5,程序中的温度值十位,个数需分解出来,转成对应的ASCII值:
u8 str2[6];
sprintf((char*)str2,"%02d ",T);
USART1_SendByte(0x30);
USART1_SendByte(str2[0]);
USART1_SendByte(str2[1]);
USART1_SendByte(0x2e);
USART1_SendByte(0x30);
USART1_SendByte(0x30);
USART1_SendByte(0x0a);
用户239228 2010-7-17 10:25