From 830e96e1f57e2f92dd4c9fdf2ca49303b23cdcb1 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 24 May 2017 23:48:03 -0400 Subject: [PATCH] better location for global fuel correction --- firmware/controllers/algo/engine.cpp | 2 +- firmware/controllers/algo/fuel_math.cpp | 2 +- firmware/controllers/trigger/main_trigger_callback.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index dd30575e01..88a4ce2b67 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -376,7 +376,7 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); engine->m.beforeFuelCalc = GET_TIMESTAMP(); - ENGINE(fuelMs) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX) * engineConfiguration->globalFuelCorrection; + ENGINE(fuelMs) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX); engine->m.fuelCalcTime = GET_TIMESTAMP() - engine->m.beforeFuelCalc; } diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 10ed027de5..17df6a57d6 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -158,7 +158,7 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { warning(CUSTOM_ERR_INJECTOR_LAG, "injectorLag not ready"); return 0; // we can end up here during configuration reset } - return theoreticalInjectionLength + injectorLag; + return theoreticalInjectionLength * engineConfiguration->globalFuelCorrection + injectorLag; } floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) { diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index fc7e100c21..9ab442895a 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -381,7 +381,7 @@ static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIn ENGINE(tpsAccelEnrichment.onNewValue(getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX)); ENGINE(engineLoadAccelEnrichment.onEngineCycle(PASS_ENGINE_PARAMETER_SIGNATURE)); - ENGINE(fuelMs) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX) * CONFIG(globalFuelCorrection); + ENGINE(fuelMs) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX); for (int injEventIndex = 0; injEventIndex < CONFIG(specs.cylindersCount); injEventIndex++) { InjectionEvent *event = &fs->elements[injEventIndex];