From 28950acf3e37df356d1c964fafc9ebb5bb9b43b1 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Fri, 28 Jan 2022 18:35:23 -0800 Subject: [PATCH] disable fuel trim shortly after DFCO (#3847) * vss based dfco * fix digits while we're here * fix some other digits for fun * don't use custom assert * simplify test * less than or equal, test vss behavior * disable closed loop fuel after dfco1 * I can't type * correct comparison helps * poke --- firmware/controllers/algo/fuel/dfco.cpp | 13 ++++++++++++- firmware/controllers/algo/fuel/dfco.h | 4 ++++ firmware/controllers/math/closed_loop_fuel.cpp | 6 ++++++ firmware/integration/rusefi_config.txt | 2 +- firmware/tunerstudio/rusefi.input | 1 + 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/algo/fuel/dfco.cpp b/firmware/controllers/algo/fuel/dfco.cpp index da25641ec8..8b9bcbd4db 100644 --- a/firmware/controllers/algo/fuel/dfco.cpp +++ b/firmware/controllers/algo/fuel/dfco.cpp @@ -46,9 +46,20 @@ bool DfcoController::getState() const { void DfcoController::update() { // Run state machine - m_isDfco = getState(); + bool newState = getState(); + + // If fuel is cut, reset the timer + if (newState) { + m_timeSinceCut.reset(); + } + + m_isDfco = newState; } bool DfcoController::cutFuel() const { return m_isDfco; } + +float DfcoController::getTimeSinceCut() const { + return m_timeSinceCut.getElapsedSeconds(); +} diff --git a/firmware/controllers/algo/fuel/dfco.h b/firmware/controllers/algo/fuel/dfco.h index 8963152a84..0c9047633a 100644 --- a/firmware/controllers/algo/fuel/dfco.h +++ b/firmware/controllers/algo/fuel/dfco.h @@ -7,7 +7,11 @@ public: bool cutFuel() const; + float getTimeSinceCut() const; + private: bool getState() const; bool m_isDfco = false; + + Timer m_timeSinceCut; }; diff --git a/firmware/controllers/math/closed_loop_fuel.cpp b/firmware/controllers/math/closed_loop_fuel.cpp index 2098f95706..f5ff19892b 100644 --- a/firmware/controllers/math/closed_loop_fuel.cpp +++ b/firmware/controllers/math/closed_loop_fuel.cpp @@ -83,6 +83,12 @@ bool shouldUpdateCorrection(SensorType sensor) { return false; } + // Pause correction if DFCO was active recently + auto timeSinceDfco = engine->module()->getTimeSinceCut(); + if (timeSinceDfco < engineConfiguration->noFuelTrimAfterDfcoTime) { + return false; + } + return true; } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index f17f81509b..e152a63724 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1173,7 +1173,7 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\ uint8_t autoscale tpsAccelLookback;+How long to look back for TPS-based acceleration enrichment. Increasing this time will trigger enrichment for longer when a throttle position change occurs.;"sec", 0.05, 0, 0, 5, 2 uint8_t coastingFuelCutVssLow;+Below this speed, disable DFCO. Use this to prevent jerkiness from fuel enable/disable in low gears.;"kph", 1, 0, 0, 255, 0 uint8_t coastingFuelCutVssHigh;+Above this speed, allow DFCO. Use this to prevent jerkiness from fuel enable/disable in low gears.;"kph", 1, 0, 0, 255, 0 - uint8_t[1] unused1689;;"", 1,0,0,0,0 + uint8_t autoscale noFuelTrimAfterDfcoTime;Pause closed loop fueling after deceleration fuel cut occurs. Set this to a little longer than however long is required for normal fueling behavior to resume after fuel cut.;"sec", 0.1, 0, 0, 10, 1 float tpsAccelEnrichmentThreshold;+Maximum change delta of TPS percentage over the 'length'. Actual TPS change has to be above this value in order for TPS/TPS acceleration to kick in.;"roc", 1, 0, 0, 200, 1 int engineLoadAccelLength;;"cycles", 1, 0, 1, 200, 0 diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 67c9c7426d..d2901a981d 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -3676,6 +3676,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" field = "Vehicle speed restore below", coastingFuelCutVssLow, {coastingFuelCutEnabled == 1} field = "Cut fuel below TPS", coastingFuelCutTps, {coastingFuelCutEnabled == 1} field = "Cut fuel below MAP", coastingFuelCutMap, {coastingFuelCutEnabled == 1} + field = "Inhibit closed loop fuel after cut", noFuelTrimAfterDfcoTime, {coastingFuelCutEnabled == 1} dialog = rotaryDialog, "Rotary" field = "Enable Trailing Sparks", enableTrailingSparks