louis7592003 发表于 2018-1-6 12:02:57

有STM32 PID 自動調整的程序參考嗎

數學公式也可以,我是用位置式來表達的
我看過很多例子,有自適應PID,模糊PID,神經PID

dsjsjf 发表于 2018-3-21 11:40:54

int8_t IncPIDCalc(void)
{
int pError, iError, dError;                                 //当前误差
float Incpid;                                                 //增量
iError = sPID.SetPoint - sPID.CurrentTemp;                  //E项
pError = iError - sPID.LastError;                           //E - E项
dError = pError - (sPID.LastError - sPID.PrevError);          //(E - E) - (E - E)项
                                                                //存储误差,用于下次计算
sPID.PrevError = sPID.LastError;                              //E项
sPID.LastError = iError;                                    //E项
Incpid = (float)(sPID.Proportion * pError                  //
            + sPID.Integral * iError                     
            + sPID.Derivative * dError);                        
sPID.Result += Incpid;
if(sPID.Result < 0)
{
    sPID.Result = 0;
}
else if(sPID.Result > 100)
{
    sPID.Result = 100;
}

return (int8_t)sPID.Result;                                 //返回PID值
}
页: [1]
查看完整版本: 有STM32 PID 自動調整的程序參考嗎