欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 2759|回復(fù): 0
收起左側(cè)

PID增量式 位置式代碼

[復(fù)制鏈接]
ID:301186 發(fā)表于 2019-6-11 08:57 | 顯示全部樓層 |閱讀模式
//位置式PID
int32 PID_Realize(PID *sptr, float *PID, int32 NowData, int32 Point)
{
int32 iError, // 當(dāng)前誤差
   Realize; // 最后得出的實(shí)際增量
iError = Point - NowData; //計(jì)算當(dāng)前誤差
sptr->SumError += PID[KI] * iError; //誤差積分
if (sptr->SumError >= PID[KT])
{
  sptr->SumError = PID[KT];
}
else if (sptr->SumError <= -PID[KT])
{
  sptr->SumError = -PID[KT];
}
Realize = PID[KP] * iError
   + sptr->SumError
   + PID[KD] * (iError - sptr->LastError)*100;
sptr->PrevError = sptr->LastError; // 更新前次誤差
sptr->LastError = iError;     // 更新上次誤差
sptr->LastData  = NowData;   // 更新上次數(shù)據(jù)
return Realize; // 返回實(shí)際值
}
//增量式PID
int32 PID_Increase(PID *sptr, float *PID, int32 NowData, int32 Point)
{
int32 iError, //當(dāng)前誤差
  Increase; //最后得出的實(shí)際增量
iError = Point - NowData; // 計(jì)算當(dāng)前誤差
Increase =  PID[KP] * (iError - sptr->LastError)
     + PID[KI] * iError
     + PID[KD] * (iError - 2 * sptr->LastError + sptr->PrevError);

sptr->PrevError = sptr->LastError; // 更新前次誤差
sptr->LastError = iError;     // 更新上次誤差
sptr->LastData  = NowData;   // 更新上次數(shù)據(jù)
return Increase; // 返回增量
}

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表