From 3d1dc5a44225fb44962f7121e7dbf01735552ac6 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 23 Feb 2023 18:05:56 -0500 Subject: [PATCH] table-only map fallback (#46) * table-only map fallback * InSequence (cherry picked from commit 4cd08fbc4b8205028c6f4aaa359264f672dd3798) --- .../algo/airmass/speed_density_airmass.cpp | 8 +------- .../algo/defaults/default_base_engine.cpp | 3 +-- firmware/integration/rusefi_config.txt | 2 -- firmware/tunerstudio/rusefi.input | 7 +------ .../tests/ignition_injection/test_fuel_math.cpp | 17 +++++++++-------- 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/firmware/controllers/algo/airmass/speed_density_airmass.cpp b/firmware/controllers/algo/airmass/speed_density_airmass.cpp index d0ee5f52cd..4df377f6a6 100644 --- a/firmware/controllers/algo/airmass/speed_density_airmass.cpp +++ b/firmware/controllers/algo/airmass/speed_density_airmass.cpp @@ -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; diff --git a/firmware/controllers/algo/defaults/default_base_engine.cpp b/firmware/controllers/algo/defaults/default_base_engine.cpp index 18085663c3..308547b1d9 100644 --- a/firmware/controllers/algo/defaults/default_base_engine.cpp +++ b/firmware/controllers/algo/defaults/default_base_engine.cpp @@ -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; diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index c6759d0240..a3c1b477dd 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -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 diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 5fa42de754..44d7e94412 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -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 diff --git a/unit_tests/tests/ignition_injection/test_fuel_math.cpp b/unit_tests/tests/ignition_injection/test_fuel_math.cpp index fdfb2c8cd5..58dfdc38fc 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_math.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_math.cpp @@ -138,7 +138,15 @@ TEST(AirmassModes, FallbackMap) { StrictMock 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); }