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

標題: PID增量式 位置式代碼 [打印本頁]

作者: RMLS    時間: 2019-6-11 08:57
標題: PID增量式 位置式代碼
//位置式PID
int32 PID_Realize(PID *sptr, float *PID, int32 NowData, int32 Point)
{
int32 iError, // 當前誤差
   Realize; // 最后得出的實際增量
iError = Point - NowData; //計算當前誤差
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;   // 更新上次數據
return Realize; // 返回實際值
}
//增量式PID
int32 PID_Increase(PID *sptr, float *PID, int32 NowData, int32 Point)
{
int32 iError, //當前誤差
  Increase; //最后得出的實際增量
iError = Point - NowData; // 計算當前誤差
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;   // 更新上次數據
return Increase; // 返回增量
}





歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1