oil pressure protection (while running) #6780

only:oilPressureProtection submenu
This commit is contained in:
Matthew Kennedy 2024-08-06 16:10:10 -04:00 committed by rusefillc
parent 699ebfc48a
commit fdcd5bf8f6
7 changed files with 94 additions and 7 deletions

View File

@ -292,6 +292,9 @@ void setDefaultBaseEngine() {
setDefaultVrThresholds();
// Oil pressure protection
engineConfiguration->minimumOilPressureTimeout = 0.5f;
setLinearCurve(config->minimumOilPressureBins, 0, 7000);
}
void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2) {

View File

@ -671,6 +671,10 @@ bool validateConfigOnStartUpOrBurn() {
}
#endif
if (engineConfiguration->enableOilPressureProtect) {
ensureArrayIsAscending("Oil pressure protection", config->minimumOilPressureBins);
}
return true;
}

View File

@ -137,17 +137,17 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
}
if (engine->rpmCalculator.isRunning()) {
bool hasOilpSensor = Sensor::hasSensor(SensorType::OilPressure);
auto oilp = Sensor::get(SensorType::OilPressure);
uint16_t minOilPressure = engineConfiguration->minOilPressureAfterStart;
// Only check if the setting is enabled and you have an oil pressure sensor
if (minOilPressure > 0 && Sensor::hasSensor(SensorType::OilPressure)) {
if (minOilPressure > 0 && hasOilpSensor) {
// Has it been long enough we should have pressure?
bool isTimedOut = engine->rpmCalculator.getSecondsSinceEngineStart(nowNt) > 5.0f;
// Only check before timed out
if (!isTimedOut) {
auto oilp = Sensor::get(SensorType::OilPressure);
if (oilp) {
// We had oil pressure! Set the flag.
if (oilp.Value > minOilPressure) {
@ -161,9 +161,23 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
allowFuel.clear(ClearReason::OilPressure);
}
}
if (oilp && engineConfiguration->enableOilPressureProtect) {
float minPressure = interpolate2d(rpm, config->minimumOilPressureBins, config->minimumOilPressureValues);
bool isPressureSufficient = oilp.Value > minPressure;
if (isPressureSufficient) {
m_lowOilPressureTimer.reset(nowNt);
}
if (m_lowOilPressureTimer.hasElapsedSec(engineConfiguration->minimumOilPressureTimeout)) {
allowFuel.clear(ClearReason::OilPressure);
}
}
} else {
// reset state in case of stalled engine
m_hadOilPressureAfterStart = false;
m_lowOilPressureTimer.reset(nowNt);
}
// If we're in engine stop mode, inhibit fuel

View File

@ -167,6 +167,9 @@ private:
// Tracks how long injector duty has been over the sustained limit
Timer m_injectorDutySustainedTimer;
// Tracks how long oil pressure has been below threshold
Timer m_lowOilPressureTimer;
};
#if EFI_ENGINE_CONTROL

View File

@ -1053,7 +1053,7 @@ end_struct
bit canReadEnabled;enable can_read/disable can_read
bit canWriteEnabled;enable can_write/disable can_write. See also can1ListenMode
bit useLinearIatSensor
bit unusedFancy5
bit enableOilPressureProtect
bit tachPulseDurationAsDutyCycle,"Duty cycle","Constant time";Treat milliseconds value as duty cycle value, i.e. 0.5ms would become 50%
bit isAlternatorControlEnabled;This enables smart alternator control and activates the extra alternator settings.
bit invertPrimaryTriggerSignal,"Falling","Rising";https://wiki.rusefi.com/Trigger-Configuration-Guide\nThis setting flips the signal from the primary engine speed sensor.
@ -1700,9 +1700,12 @@ int anotherCiTest
uint16_t minAcPressure;value of A/C pressure in kPa before that compressor is disengaged;"kPa", 1, 0, 0, 500, 0
uint16_t maxAcPressure;value of A/C pressure in kPa after that compressor is disengaged;"kPa", 1, 0, 0, 500, 0
uint8_t autoscale minimumOilPressureTimeout;Delay before cutting fuel due to low oil pressure. Use this to ignore short pressure blips and sensor noise.;"sec", 0.1, 0, 0, 5, 1
@@BOARD_ENGINE_CONFIGURATION_FROM_FILE@@
#define END_OF_CALIBRATION_PADDING 174
#define END_OF_CALIBRATION_PADDING 168
uint8_t[END_OF_CALIBRATION_PADDING] unusedOftenChangesDuringFirmwareUpdate;;"units", 1, 0, 0, 1, 0
! end of engine_configuration_s
@ -2048,6 +2051,9 @@ float[BOOST_CURVE_SIZE] cltBoostAdder;;"", 1, 0, 0, 5, 2
float[BOOST_CURVE_SIZE] iatBoostAdderBins;;"C", 1, 0, -100, @@CLT_UPPER_LIMIT@@, 2
float[BOOST_CURVE_SIZE] iatBoostAdder;;"", 1, 0, 0, 5, 2
uint8_t[8] autoscale minimumOilPressureBins;;"RPM", 100, 0, 0, 25000, 0
uint8_t[8] autoscale minimumOilPressureValues;;"kPa", 10, 0, 0, 1000, 0
@@BOARD_CONFIG_FROM_FILE@@
end_struct

View File

@ -931,6 +931,15 @@ curve = rangeMatrix, "Range Switch Input Matrix"
xBins = gearCountArray, tcuCurrentGear
yBins = gearBasedOpenLoopBoostAdder
curve = minimumOilPressure, "Minimum oil pressure"
columnLabel = "RPM", "min pressure"
xAxis = 0, 8000, 9
yAxis = 0, 500, 6
xBins = minimumOilPressureBins, RPMValue
yBins = minimumOilPressureValues
gauge = OilPressGauge
[TableEditor]
; table_id, map3d_id, "title", page
@@BOARD_TABLES_FROM_FILE@@
@ -4285,6 +4294,12 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
field = "Timing retard", rpmSoftLimitTimingRetard, { cutSparkOnHardLimit }
field = "Fuel added", rpmSoftLimitFuelAdded, { cutFuelOnHardLimit }
dialog = oilPressureProtection, "Oil pressure protection"
field = "Minimum oil pressure after start", minOilPressureAfterStart
field = "Enable low oil pressure protection", enableOilPressureProtect
field = "Oil pressure protection timeout", minimumOilPressureTimeout
panel = minimumOilPressure
dialog = etbLimits, "Electronic Throttle Limiting"
field = "Smoothly close the throttle to limit RPM."
field = "Soft limiter start", etbRevLimitStart

View File

@ -209,7 +209,7 @@ TEST(limp, boostCut) {
EXPECT_TRUE(dut.allowInjection());
}
TEST(limp, oilPressureFailureCase) {
TEST(limp, oilPressureStartupFailureCase) {
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
engineConfiguration->minOilPressureAfterStart = 200;
@ -242,7 +242,7 @@ TEST(limp, oilPressureFailureCase) {
ASSERT_FALSE(dut.allowInjection());
}
TEST(limp, oilPressureSuccessCase) {
TEST(limp, oilPressureStartupSuccessCase) {
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
engineConfiguration->minOilPressureAfterStart = 200;
@ -279,3 +279,45 @@ TEST(limp, oilPressureSuccessCase) {
dut.updateState(1000, getTimeNowNt());
ASSERT_TRUE(dut.allowInjection());
}
TEST(limp, oilPressureRunning) {
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
engineConfiguration->enableOilPressureProtect = true;
engineConfiguration->minimumOilPressureTimeout = 1.0f;
setArrayValues(config->minimumOilPressureValues, 100);
LimpManager dut;
// Oil pressure starts OK
Sensor::setMockValue(SensorType::OilPressure, 110);
// Start the engine
engine->rpmCalculator.setRpmValue(1000);
// update & check: injection should be allowed
dut.updateState(1000, getTimeNowNt());
EXPECT_TRUE(dut.allowInjection());
// A long time later, everything should still be OK
advanceTimeUs(60e6);
dut.updateState(1000, getTimeNowNt());
EXPECT_TRUE(dut.allowInjection());
// Now oil pressure drops below threshold
Sensor::setMockValue(SensorType::OilPressure, 90);
// 0.9 second later, injection should continue as timeout isn't hit yet
advanceTimeUs(0.9e6);
dut.updateState(1000, getTimeNowNt());
ASSERT_TRUE(dut.allowInjection());
// 0.2 second later (1.1s since low pressure starts), injection should cut
advanceTimeUs(1.0e6);
dut.updateState(1000, getTimeNowNt());
ASSERT_FALSE(dut.allowInjection());
// Oil pressure is restored, and fuel should be restored too
Sensor::setMockValue(SensorType::OilPressure, 110);
dut.updateState(1000, getTimeNowNt());
ASSERT_TRUE(dut.allowInjection());
}