1.增量式PID
Error=Set_Value - Current_Value;
result= p * (Error - LastError)
+ i * Error
+ d * (Error - 2*LastError + PrevError);
PrevError = LastError;
LastError = Error;
SumError = SumError + result;
2.位置式PID
Error=Set_Value - Current_Value;
SumError += Error;
dError = LastError - PrevError;
PrevError = LastError;
LastError = Error;
result= p * Error
+ i * SumError
+ d * dError;