Fix problem with the AFR correction ignition count not being checked correctly
This commit is contained in:
parent
575c9d0334
commit
cfb8d20f4e
|
@ -462,7 +462,7 @@ page = 6
|
|||
; Begin fan control vairables
|
||||
fanInv = bits, U08, 120, [0:0], "No", "Yes"
|
||||
fanEnable = bits, U08, 120, [1:1], "Off", "On/Off"
|
||||
fanPin = bits , U08, 120, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
fanPin = bits, U08, 120, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
#if CELSIUS
|
||||
fanSP = scalar, U08, 121, "C", 1.0, -40, -40, 215.0, 0
|
||||
fanHyster = scalar, U08, 122, "C", 1.0, 0.0, 0.0, 40, 0
|
||||
|
|
|
@ -23,6 +23,7 @@ void initialiseCorrections()
|
|||
{
|
||||
egoPID.SetMode(AUTOMATIC); //Turn O2 PID on
|
||||
currentStatus.flexIgnCorrection = 0;
|
||||
currentStatus.egoCorrection = 100; //Default value of no adjustment must be set to avoid randomness on first correction cycle after startup
|
||||
AFRnextCycle = 0;
|
||||
}
|
||||
|
||||
|
@ -314,49 +315,53 @@ static inline byte correctionAFRClosedLoop()
|
|||
currentStatus.afrTarget = get3DTableValue(&afrTable, yValue, currentStatus.RPM); //Perform the target lookup
|
||||
|
||||
//Check all other requirements for closed loop adjustments
|
||||
if( (ignitionCount >= AFRnextCycle) && (currentStatus.coolant > (int)(configPage3.egoTemp - CALIBRATION_TEMPERATURE_OFFSET)) && (currentStatus.RPM > (unsigned int)(configPage3.egoRPM * 100)) && (currentStatus.TPS < configPage3.egoTPSMax) && (currentStatus.O2 < configPage3.ego_max) && (currentStatus.O2 > configPage3.ego_min) && (currentStatus.runSecs > configPage3.ego_sdelay) )
|
||||
if( (currentStatus.coolant > (int)(configPage3.egoTemp - CALIBRATION_TEMPERATURE_OFFSET)) && (currentStatus.RPM > (unsigned int)(configPage3.egoRPM * 100)) && (currentStatus.TPS < configPage3.egoTPSMax) && (currentStatus.O2 < configPage3.ego_max) && (currentStatus.O2 > configPage3.ego_min) && (currentStatus.runSecs > configPage3.ego_sdelay) )
|
||||
{
|
||||
AFRnextCycle = ignitionCount + configPage3.egoCount; //Set the target ignition event for the next calculation
|
||||
AFRValue = currentStatus.egoCorrection; //Need to record this here, just to make sure the correction stays 'on' even if the nextCycle count isn't ready
|
||||
|
||||
//Check which algorithm is used, simple or PID
|
||||
if (configPage3.egoAlgorithm == EGO_ALGORITHM_SIMPLE)
|
||||
if(ignitionCount >= AFRnextCycle)
|
||||
{
|
||||
//*************************************************************************************************************************************
|
||||
//Simple algorithm
|
||||
if(currentStatus.O2 > currentStatus.afrTarget)
|
||||
AFRnextCycle = ignitionCount + configPage3.egoCount; //Set the target ignition event for the next calculation
|
||||
|
||||
//Check which algorithm is used, simple or PID
|
||||
if (configPage3.egoAlgorithm == EGO_ALGORITHM_SIMPLE)
|
||||
{
|
||||
//Running lean
|
||||
if(currentStatus.egoCorrection < (100 + configPage3.egoLimit) ) //Fueling adjustment must be at most the egoLimit amount (up or down)
|
||||
//*************************************************************************************************************************************
|
||||
//Simple algorithm
|
||||
if(currentStatus.O2 > currentStatus.afrTarget)
|
||||
{
|
||||
if(currentStatus.egoCorrection >= 100) { AFRValue = (currentStatus.egoCorrection + 1); } //Increase the fueling by 1%
|
||||
else { AFRValue = 100; } //This means that the last reading had been rich, so simply return back to no adjustment (100%)
|
||||
//Running lean
|
||||
if(currentStatus.egoCorrection < (100 + configPage3.egoLimit) ) //Fueling adjustment must be at most the egoLimit amount (up or down)
|
||||
{
|
||||
if(currentStatus.egoCorrection >= 100) { AFRValue = (currentStatus.egoCorrection + 1); } //Increase the fueling by 1%
|
||||
else { AFRValue = 100; } //This means that the last reading had been rich, so simply return back to no adjustment (100%)
|
||||
}
|
||||
else { AFRValue = currentStatus.egoCorrection; } //Means we're at the maximum adjustment amount, so simply return then again
|
||||
}
|
||||
else { AFRValue = currentStatus.egoCorrection; } //Means we're at the maximum adjustment amount, so simply return then again
|
||||
else
|
||||
//Running Rich
|
||||
if(currentStatus.egoCorrection > (100 - configPage3.egoLimit) ) //Fueling adjustment must be at most the egoLimit amount (up or down)
|
||||
{
|
||||
if(currentStatus.egoCorrection <= 100) { AFRValue = (currentStatus.egoCorrection - 1); } //Increase the fueling by 1%
|
||||
else { AFRValue = 100; } //This means that the last reading had been lean, so simply return back to no adjustment (100%)
|
||||
}
|
||||
else { AFRValue = currentStatus.egoCorrection; } //Means we're at the maximum adjustment amount, so simply return then again
|
||||
}
|
||||
else
|
||||
//Running Rich
|
||||
if(currentStatus.egoCorrection > (100 - configPage3.egoLimit) ) //Fueling adjustment must be at most the egoLimit amount (up or down)
|
||||
{
|
||||
if(currentStatus.egoCorrection <= 100) { AFRValue = (currentStatus.egoCorrection - 1); } //Increase the fueling by 1%
|
||||
else { AFRValue = 100; } //This means that the last reading had been lean, so simply return back to no adjustment (100%)
|
||||
}
|
||||
else { AFRValue = currentStatus.egoCorrection; } //Means we're at the maximum adjustment amount, so simply return then again
|
||||
}
|
||||
else if(configPage3.egoAlgorithm == EGO_ALGORITHM_PID)
|
||||
{
|
||||
//*************************************************************************************************************************************
|
||||
//PID algorithm
|
||||
egoPID.SetOutputLimits((long)(-configPage3.egoLimit), (long)(configPage3.egoLimit)); //Set the limits again, just incase the user has changed them since the last loop. Note that these are sent to the PID library as (Eg:) -15 and +15
|
||||
egoPID.SetTunings(configPage3.egoKP, configPage3.egoKI, configPage3.egoKD); //Set the PID values again, just incase the user has changed them since the last loop
|
||||
PID_O2 = (long)(currentStatus.O2);
|
||||
PID_AFRTarget = (long)(currentStatus.afrTarget);
|
||||
|
||||
egoPID.Compute();
|
||||
//currentStatus.egoCorrection = 100 + PID_output;
|
||||
AFRValue = 100 + PID_output;
|
||||
}
|
||||
else { AFRValue = 100; } // Occurs if the egoAlgorithm is set to 0 (No Correction)
|
||||
else if(configPage3.egoAlgorithm == EGO_ALGORITHM_PID)
|
||||
{
|
||||
//*************************************************************************************************************************************
|
||||
//PID algorithm
|
||||
egoPID.SetOutputLimits((long)(-configPage3.egoLimit), (long)(configPage3.egoLimit)); //Set the limits again, just incase the user has changed them since the last loop. Note that these are sent to the PID library as (Eg:) -15 and +15
|
||||
egoPID.SetTunings(configPage3.egoKP, configPage3.egoKI, configPage3.egoKD); //Set the PID values again, just incase the user has changed them since the last loop
|
||||
PID_O2 = (long)(currentStatus.O2);
|
||||
PID_AFRTarget = (long)(currentStatus.afrTarget);
|
||||
|
||||
egoPID.Compute();
|
||||
//currentStatus.egoCorrection = 100 + PID_output;
|
||||
AFRValue = 100 + PID_output;
|
||||
}
|
||||
else { AFRValue = 100; } // Occurs if the egoAlgorithm is set to 0 (No Correction)
|
||||
} //Ignition count check
|
||||
} //Multi variable check
|
||||
} //egoType
|
||||
|
||||
|
|
Loading…
Reference in New Issue