From 41ac8a921cc90c3b485a3ae637d07d0536471926 Mon Sep 17 00:00:00 2001 From: Patryk Chmura <79016748+pchmura4@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:02:41 +0200 Subject: [PATCH] Fixes confirmed on the real car (#5638) Co-authored-by: pchmura4 <> --- firmware/config/engines/honda_k_dbc.cpp | 2 +- .../controllers/actuators/idle_thread.cpp | 22 +++++++++---------- .../algo/defaults/default_cranking.cpp | 4 ++-- firmware/integration/rusefi_config.txt | 10 +++++---- firmware/tunerstudio/rusefi.input | 2 +- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/firmware/config/engines/honda_k_dbc.cpp b/firmware/config/engines/honda_k_dbc.cpp index 512a2b931a..d3039b8529 100644 --- a/firmware/config/engines/honda_k_dbc.cpp +++ b/firmware/config/engines/honda_k_dbc.cpp @@ -44,7 +44,7 @@ void setHondaK() { engineConfiguration->crankingIACposition = 70; static const uint16_t defaultPostCrankinDurationBins[] = { - 0, 35, 65, 100, 125, 150, 200, 250 + 0, 65, 100, 125, 150, 250 }; copyArray(engineConfiguration->postCrankingDurationBins, defaultPostCrankinDurationBins); setTable(engineConfiguration->postCrankingFactor, 1.25f); diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 7dfecba244..2d4bd468d3 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -76,6 +76,12 @@ IIdleController::Phase IdleController::determinePhase(int rpm, int targetRpm, Se } #endif // EFI_SHAFT_POSITION_INPUT + // If we are entering idle, and the PID settings are aggressive, it's good to make a soft entry upon entering closed loop + if (m_crankTaperEndTime == 0.0f) { + m_crankTaperEndTime = engine->fuelComputer.running.timeSinceCrankingInSecs; + m_idleTimingSoftEntryEndTime = m_crankTaperEndTime + engineConfiguration->idleTimingSoftEntryTime; + } + // No other conditions met, we are idling! return Phase::Idling; } @@ -187,18 +193,12 @@ float IdleController::getIdleTimingAdjustment(int rpm, int targetRpm, Phase phas if (phase != Phase::Idling) { m_timingPid.reset(); return 0; - } else { - // If we are entering idle, and the PID settings are aggressive, it's good to make a soft entry upon entering closed loop - if (m_lastPhase == Phase::CrankToIdleTaper) { - m_crankTaperEndTime = engine->fuelComputer.running.timeSinceCrankingInSecs; - m_idleTimingSoftEntryEndTime = m_crankTaperEndTime + engineConfiguration->idleTimingSoftEntryTime; - } - if (engineConfiguration->idleTimingSoftEntryTime > 0.0f) { - // Use interpolation for correction taper - m_timingPid.setErrorAmplification(interpolateClamped(m_crankTaperEndTime, 0.0f, m_idleTimingSoftEntryEndTime, 1.0f, engine->fuelComputer.running.timeSinceCrankingInSecs)); - } } - + + if (engineConfiguration->idleTimingSoftEntryTime > 0.0f) { + // Use interpolation for correction taper + m_timingPid.setErrorAmplification(interpolateClamped(m_crankTaperEndTime, 0.0f, m_idleTimingSoftEntryEndTime, 1.0f, engine->fuelComputer.running.timeSinceCrankingInSecs)); + } // We're now in the idle mode, and RPM is inside the Timing-PID regulator work zone! return m_timingPid.getOutput(targetRpm, rpm, FAST_CALLBACK_PERIOD_MS / 1000.0f); diff --git a/firmware/controllers/algo/defaults/default_cranking.cpp b/firmware/controllers/algo/defaults/default_cranking.cpp index 2f06bcbbbd..d154212d74 100644 --- a/firmware/controllers/algo/defaults/default_cranking.cpp +++ b/firmware/controllers/algo/defaults/default_cranking.cpp @@ -24,10 +24,10 @@ void setDefaultCranking() { #if !EFI_UNIT_TEST // don't set this for unit tests, as it makes things more complicated to test static const float defaultPostCrankingCLTBins[] = { - -20.0f, 0.0f, 30.0f, 60.0f + -20.0f, 0.0f, 20.0f, 40.0f, 60.0f, 80.0f }; static const uint16_t defaultPostCrankinDurationBins[] = { - 0, 15, 35, 50, 65, 100, 125, 150 + 0, 15, 35, 65, 100, 150 }; copyArray(engineConfiguration->postCrankingCLTBins, defaultPostCrankingCLTBins); copyArray(engineConfiguration->postCrankingDurationBins, defaultPostCrankinDurationBins); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 2d1af3dea3..7df43d6c15 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -177,6 +177,8 @@ struct_no_prefix engine_configuration_s #define CRANKING_CURVE_SIZE 8 +#define CRANKING_ENRICH_COUNT 6 + #define IGN_LOAD_COUNT 16 #define IGN_RPM_COUNT 16 @@ -1247,9 +1249,9 @@ tle8888_mode_e tle8888mode; pin_output_mode_e fan2PinMode; float fuelReferencePressure;This is the pressure at which your injector flow is known.\nFor example if your injectors flow 400cc/min at 3.5 bar, enter 350kpa here.;"kPa", 1, 0, 50, 700000, 0 - float[CRANKING_ADVANCE_CURVE_SIZE x DWELL_CURVE_SIZE] postCrankingFactor;;"mult", 1, 0, 1, 3, 2 - float[CRANKING_ADVANCE_CURVE_SIZE] postCrankingCLTBins;;"C", 1, 0, -100, 100, 0 - float[DWELL_CURVE_SIZE] postCrankingDurationBins;;"count", 1, 0, 0, 1000, 0 + float[CRANKING_ENRICH_COUNT x CRANKING_ENRICH_COUNT] postCrankingFactor;;"mult", 1, 0, 1, 3, 2 + float[CRANKING_ENRICH_COUNT] postCrankingDurationBins;;"count", 1, 0, 0, 1000, 0 + float[CRANKING_ENRICH_COUNT] postCrankingCLTBins;;"C", 1, 0, -100, 100, 0 ThermistorConf auxTempSensor1 ThermistorConf auxTempSensor2 @@ -1356,7 +1358,7 @@ tChargeMode_e tChargeMode; int16_t etb_iTermMax;iTerm max value;"", 1, 0, -30000, 30000, 0 pid_s idleTimingPid;See useIdleTimingPidControl - float idleTimingSoftEntryTime + float idleTimingSoftEntryTime;When entering idle, and the PID settings are aggressive, it's good to make a soft entry upon entering closed loop;"", 1, 0, 0, 100, 1 int16_t etbRocExpAverageLength;By the way ETB PID runs at 500hz, length in 1/500 of second here. diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 164931372d..6bcafffaa0 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1305,7 +1305,7 @@ curve = rangeMatrix, "Range Switch Input Matrix" zBins = hpfpCompensation table = postCrankingEnrichmentTbl, postCrankingEnrichmentMap, "After start enrichment", 1 - xBins = postCrankingDurationBins, engineCycles + xBins = postCrankingDurationBins, seconds ; TODO "engineCycles" should be there yBins = postCrankingCLTBins, coolant zBins = postCrankingFactor