|
|
@@ -46,14 +46,14 @@
|
|
|
double PidCalc(PID* pidStruct, double nextPoint)
|
|
|
{
|
|
|
double dError, Error;
|
|
|
- Error = pidStruct->SetPoint - nextPoint; //Deviation
|
|
|
- pidStruct->SumError += Error; //Integral
|
|
|
- dError = pidStruct->LastError - pidStruct->PrevError; //Current differential
|
|
|
- pidStruct->PrevError = pidStruct->LastError;
|
|
|
+ Error = pidStruct->SetPoint - nextPoint; // Deviation
|
|
|
+ pidStruct->SumError += Error; // Integral
|
|
|
+ dError = pidStruct->LastError - pidStruct->PrevError; // Current differential
|
|
|
+ pidStruct->PrevError = pidStruct->LastError;
|
|
|
pidStruct->LastError = Error;
|
|
|
- return (pidStruct->Proportion * Error //Proportional
|
|
|
- + pidStruct->Integral * pidStruct->SumError //Integral item
|
|
|
- + pidStruct->Derivative * dError); //Differential item
|
|
|
+ return (pidStruct->Proportion * Error // Proportional
|
|
|
+ + pidStruct->Integral * pidStruct->SumError // Integral item
|
|
|
+ + pidStruct->Derivative * dError); // Differential item
|
|
|
}
|
|
|
|
|
|
/**
|