table-only map fallback (#46)

* table-only map fallback

* InSequence

(cherry picked from commit 4cd08fbc4b)
This commit is contained in:
Matthew Kennedy 2023-02-23 18:05:56 -05:00 committed by rusefillc
parent 08cdc748a0
commit 3d1dc5a442
5 changed files with 12 additions and 25 deletions

View File

@ -51,13 +51,7 @@ float SpeedDensityAirmass::getAirflow(float rpm, float map) {
}
float SpeedDensityAirmass::getMap(int rpm) const {
float fallbackMap;
if (engineConfiguration->enableMapEstimationTableFallback) {
// if the map estimation table is enabled, estimate map based on the TPS and RPM
fallbackMap = m_mapEstimationTable->getValue(rpm, Sensor::getOrZero(SensorType::Tps1));
} else {
fallbackMap = engineConfiguration->failedMapFallback;
}
float fallbackMap = m_mapEstimationTable->getValue(rpm, Sensor::getOrZero(SensorType::Tps1));
#if EFI_TUNER_STUDIO
engine->outputChannels.fallbackMap = fallbackMap;

View File

@ -58,8 +58,7 @@ void setDefaultBaseEngine() {
engineConfiguration->cutFuelOnHardLimit = true;
engineConfiguration->cutSparkOnHardLimit = true;
engineConfiguration->failedMapFallback = 60;
engineConfiguration->enableMapEstimationTableFallback = false;
setTable(config->mapEstimateTable, 60);
// engineConfiguration->totalGearsCount = 5;
// engineConfiguration->gearRatio[0] = 3.35f;

View File

@ -443,7 +443,6 @@ bit antiLagEnabled;
bit useRunningMathForCranking,"Fuel Map","Fixed";For cranking either use the specified fixed base fuel mass, or use the normal running math (VE table).
bit displayLogicLevelsInEngineSniffer;Shall we display real life signal or just the part consumed by trigger decoder.\nApplies to both trigger and cam/vvt input.\n\nenable logic_level_trigger
bit useTLE8888_stepper
bit enableMapEstimationTableFallback;If enabled, the MAP estimate table will be used if the MAP sensor fails to estimate manifold pressure based on RPM and TPS.
bit usescriptTableForCanSniffingFiltering
bit verboseCan,"Print all","Do not print";Print incoming and outgoing first bus CAN messages in rusEFI console
bit artificialTestMisfire,"Danger Mode","No thank you";Experimental setting that will cause a misfire\nDO NOT ENABLE.
@ -564,7 +563,6 @@ trigger_config_s trigger;
custom spi_device_e 1 bits, U08, @OFFSET@, [0:2], "Off", "SPI1", "SPI2", "SPI3", "SPI4"
spi_device_e hip9011SpiDevice;
uint8_t failedMapFallback;Single value to be used in event of a failed MAP sensor \nThis value is only used for speed density fueling calculations.;"kPa", 1, 0, 0, 100, 0
uint8_t boostControlSafeDutyCycle;Duty cycle to use in case of a sensor failure. This duty cycle should produce the minimum possible amount of boost. This duty is also used in case any of the minimum RPM/TPS/MAP conditions are not met.;"%", 1, 0, 0, 100, 0
adc_channel_e mafAdcChannel

View File

@ -1696,7 +1696,7 @@ menuDialog = main
subMenu = tChargeSettings, "Charge temperature estimation", 0, {isInjectionEnabled == 1}
subMenu = baroCorrTbl, "Barometric pressure correction", 0, {isInjectionEnabled == 1 && fuelAlgorithm == @@engine_load_mode_e_LM_SPEED_DENSITY@@}
subMenu = mapEstimateTableTbl, "MAP estimate table", 0, { enableMapEstimationTableFallback }
subMenu = mapEstimateTableTbl, "MAP estimate table"
subMenu = std_separator
# Fuel model
@ -3750,15 +3750,10 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
field = "Soft limiter start", etbRevLimitStart
field = "Soft limiter range", etbRevLimitRange
dialog = fallbacks, "Fallbacks"
field = "Use MAP estimation table as fallback", enableMapEstimationTableFallback
field = "Failed MAP sensor fallback", failedMapFallback, { !enableMapEstimationTableFallback }
dialog = limitsAndFallbackLeft
panel = limitsSettings
panel = softRpmLimitSettings, West, { (cutFuelOnHardLimit || cutSparkOnHardLimit) && !useCltBasedRpmLimit }
panel = etbLimits
panel = fallbacks
dialog = limitsAndFallbackCenter, "CLT-based RPM Limit"
panel = cltRevLimitCurve

View File

@ -138,7 +138,15 @@ TEST(AirmassModes, FallbackMap) {
StrictMock<MockVp3d> mapFallback;
// Failed map -> use 75
EXPECT_CALL(mapFallback, getValue(5678, 20)).WillOnce(Return(75));
{
InSequence is;
// Working map -> return 33 (should be unused)
EXPECT_CALL(mapFallback, getValue(1234, 20)).WillOnce(Return(33));
// Failed map -> use 75
EXPECT_CALL(mapFallback, getValue(5678, 20)).WillOnce(Return(75));
}
EngineTestHelper eth(TEST_ENGINE);
@ -151,15 +159,8 @@ TEST(AirmassModes, FallbackMap) {
Sensor::setMockValue(SensorType::Map, 40);
EXPECT_FLOAT_EQ(dut.getMap(1234), 40);
// Failed MAP sensor, should use fixed value
Sensor::resetMockValue(SensorType::Map);
engineConfiguration->enableMapEstimationTableFallback = false;
engineConfiguration->failedMapFallback = 33;
EXPECT_FLOAT_EQ(dut.getMap(2345), 33);
// Failed MAP sensor, should use table
Sensor::resetMockValue(SensorType::Map);
engineConfiguration->enableMapEstimationTableFallback = true;
EXPECT_FLOAT_EQ(dut.getMap(5678), 75);
}