?? pid.c
字號:
?
+
/*=====================================================================================
File name: PID.C (IQ version)
Originator: ECS Development
Description: The PI controller with anti-windup
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20
-------------------------------------------------------------------------------------*/
#include "IQmathLib.h"
#include "pid.h"
void pid_calc(PID *v)
{
// Compute the error
v->Err = v->Ref - v->Fdb;
// Compute the proportional output
v->Up = _IQmpy(v->Kp,v->Err);
// Compute the integral output
v->Ui = v->Ui + _IQmpy(v->Ki,v->Up) + _IQmpy(v->Kc,v->SatErr);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui;
// Saturate the output
if (v->OutPreSat > v->OutMax)
v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin;
else
v->Out = v->OutPreSat;
// Compute the saturate difference
v->SatErr = v->Out - v->OutPreSat;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -