bug fix EGO PID controller + some improvements. (#879)
* Fix for EGO pid * Further improvements on ego PID * Stop EGO controllers from calculating while DFCO is active. To prevent integrator windup. * Fix bug in DFCO enable/disable of the controller Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
This commit is contained in:
parent
ce7ea412db
commit
ca2bab0725
|
@ -605,7 +605,7 @@ byte correctionAFRClosedLoop()
|
|||
if( (currentStatus.runSecs > configPage6.ego_sdelay) || (configPage2.incorporateAFR == true) ) { currentStatus.afrTarget = get3DTableValue(&afrTable, currentStatus.fuelLoad, currentStatus.RPM); } //Perform the target lookup
|
||||
}
|
||||
|
||||
if( configPage6.egoType > 0 ) //egoType of 0 means no O2 sensor
|
||||
if((configPage6.egoType > 0) & (BIT_CHECK(currentStatus.status1, BIT_STATUS1_DFCO) != 1 ) ) //egoType of 0 means no O2 sensor. If DFCO is active do not run the ego controllers to prevent interator wind-up.
|
||||
{
|
||||
AFRValue = currentStatus.egoCorrection; //Need to record this here, just to make sure the correction stays 'on' even if the nextCycle count isn't ready
|
||||
|
||||
|
|
|
@ -54,21 +54,21 @@ bool PID::Compute()
|
|||
/*Compute all the working error variables*/
|
||||
long input = *myInput;
|
||||
long error = *mySetpoint - input;
|
||||
ITerm += (ki * error)/100;
|
||||
ITerm += (ki * error);
|
||||
if(ITerm > outMax) ITerm= outMax;
|
||||
else if(ITerm < outMin) ITerm= outMin;
|
||||
else if(ITerm < outMin) ITerm = outMin;
|
||||
long dInput = (input - lastInput);
|
||||
|
||||
/*Compute PID Output*/
|
||||
long output = (kp * error)/100 + ITerm- (kd * dInput)/100;
|
||||
long output = (kp * error) + ITerm- (kd * dInput);
|
||||
|
||||
if(output > outMax) { output = outMax; }
|
||||
else if(output < outMin) { output = outMin; }
|
||||
*myOutput = output;
|
||||
*myOutput = output/1000;
|
||||
|
||||
/*Remember some variables for next time*/
|
||||
lastInput = input;
|
||||
//lastTime = now;
|
||||
lastTime = now;
|
||||
return true;
|
||||
}
|
||||
//else return false;
|
||||
|
@ -90,10 +90,10 @@ void PID::SetTunings(byte Kp, byte Ki, byte Kd)
|
|||
ki = Ki * SampleTimeInSec;
|
||||
kd = Kd / SampleTimeInSec;
|
||||
*/
|
||||
long InverseSampleTimeInSec = 100000 / SampleTime;
|
||||
long InverseSampleTimeInSec = 100;
|
||||
kp = Kp;
|
||||
ki = (Ki * 100) / InverseSampleTimeInSec;
|
||||
kd = (Kd * InverseSampleTimeInSec) / 100;
|
||||
ki = Ki;
|
||||
kd = Kd * 10;
|
||||
|
||||
if(controllerDirection ==REVERSE)
|
||||
{
|
||||
|
@ -129,8 +129,8 @@ void PID::SetSampleTime(int NewSampleTime)
|
|||
void PID::SetOutputLimits(long Min, long Max)
|
||||
{
|
||||
if(Min >= Max) return;
|
||||
outMin = Min;
|
||||
outMax = Max;
|
||||
outMin = Min*1000;
|
||||
outMax = Max*1000;
|
||||
|
||||
if(inAuto)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue