Add delay to oil pressure engine protection

This commit is contained in:
Josh Stewart 2022-11-23 16:15:01 +11:00
parent 461e632db7
commit 22d2b4e38e
4 changed files with 28 additions and 5 deletions

View File

@ -1252,7 +1252,9 @@ page = 10
spark2InputPolarity = bits , U08, 189, [6:6], "LOW", "HIGH"
spark2InputPullup = bits , U08, 189, [7:7], "No", "Yes"
unused11_190_191 = array, U08, 190, [2], "RPM", 100.0, 0.0, 100, 25500, 0
oilPressureProtTime = scalar, U08, 190, "seconds", 0.1, 0.0, 0.0, 25, 1
unused11_190_191 = array, U08, 191, [1], "RPM", 100.0, 0.0, 100, 25500, 0
;Page 11 is the fuel map and axis bins only
page = 11
@ -2131,6 +2133,7 @@ menuDialog = main
#endif
afrProtectCutTime = "Time delay before activating AFR protection when all conditions has been fulfilled"
afrProtectReactivationTPS = "Going below this throttle position (%) will deactivate this protection"
oilPressureProtTime = "Time delay before activating oil pressure protection when all conditions has been fulfilled"
fuel2InputPin = "The Arduino pin that is being used to trigger the second fuel table to be active"
fuel2InputPolarity = "Whether the 2nd fuel table should be active when input is high or low. This should be LOW for a typical ground switching input"
@ -2992,6 +2995,7 @@ menuDialog = main
dialog = oilPressureProtection, "Oil Pressure"
field = "Oil Pressure Protection", oilPressureProtEnbl, { oilPressureEnable }
field = "Oil Pressure cut delay", oilPressureProtTime, { oilPressureEnable && oilPressureProtEnbl }
panel = oil_pressure_prot_curve, { oilPressureEnable && oilPressureProtEnbl }
; AFR engine protection dialog

View File

@ -2,6 +2,8 @@
#include "globals.h"
#include "engineProtection.h"
byte oilProtStartTime = 0;
byte checkEngineProtect(void)
{
byte protectActive = 0;
@ -93,17 +95,29 @@ byte checkBoostLimit(void)
byte checkOilPressureLimit(void)
{
byte oilProtectActive = 0;
static constexpr char X100_MULTIPLIER = 100;
bool alreadyActive = BIT_CHECK(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_OIL);
BIT_CLEAR(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_OIL); //Will be set true below if required
if (configPage6.engineProtectType != PROTECT_CUT_OFF) {
if (configPage6.engineProtectType != PROTECT_CUT_OFF)
{
if( (configPage10.oilPressureProtEnbl == true) && (configPage10.oilPressureEnable == true) )
{
byte oilLimit = table2D_getValue(&oilPressureProtectTable, currentStatus.RPMdiv100);
if(currentStatus.oilPressure < oilLimit)
{
BIT_SET(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_OIL);
oilProtectActive = 1;
//Check if this is the first time we've been below the limit
if(oilProtStartTime == 0) { oilProtStartTime = (millis() / 100); }
/* Check if countdown has reached its target, if so then instruct to cut */
if( (uint8_t(millis()/100) >= (uint16_t(oilProtStartTime + configPage10.oilPressureProtTime)) ) || (alreadyActive > 0) )
{
BIT_SET(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_OIL);
oilProtectActive = 1;
}
}
else { oilProtStartTime = 0; } //Reset the timer
}
}

View File

@ -1376,7 +1376,9 @@ struct config10 {
byte spark2InputPolarity : 1;
byte spark2InputPullup : 1;
byte unused11_187_191[2]; //Bytes 187-191
byte oilPressureProtTime;
byte unused11_191_191; //Bytes 187-191
#if defined(CORE_AVR)
};

View File

@ -683,6 +683,9 @@ void doUpdates(void)
//Set A/C default values - these line up with the ini file defaults
configPage15.airConEnable = 0;
//Oil Pressure protection delay added. Set to 0 to match existing behaviour
configPage10.oilPressureProtTime = 0;
writeAllConfig();
storeEEPROMVersion(21);
}