diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 9cedaf8be2..e908a823e7 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -438,6 +438,9 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->tpsAccelEnrichmentThreshold = 10; engineConfiguration->tpsAccelEnrichmentMultiplier = 0.15; +// engineConfiguration->suckedOffCoef = 0.05; +// engineConfiguration->addedToWallCoef = 0.40; + } #endif /* EFI_SUPPORT_DODGE_NEON */ diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 6101bc8dea..07d957e085 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -198,7 +198,6 @@ static void printSensors(Logging *log, bool fileFormat) { if (fileFormat) { reportSensorF(log, fileFormat, "tpsacc", "ms", engine->tpsAccelEnrichment.getTpsEnrichment(PASS_ENGINE_PARAMETER_F), 2); reportSensorF(log, fileFormat, "advance", "deg", engine->tpsAccelEnrichment.getTpsEnrichment(PASS_ENGINE_PARAMETER_F), 2); - reportSensorF(log, fileFormat, "advance", "deg", getFuelMs(rpm PASS_ENGINE_PARAMETER), 2); } if (engineConfiguration->hasCltSensor) { @@ -261,7 +260,7 @@ static void printState(void) { // debugFloat(&logger, "fuel_iat", getIatCorrection(getIntakeAirTemperature()), 2); // debugFloat(&logger, "fuel_clt", getCltCorrection(getCoolantTemperature()), 2); debugFloat(&logger, "fuel_lag", engine->injectorLagMs, 2); - debugFloat(&logger, "fuel", getFuelMs(rpm PASS_ENGINE_PARAMETER), 2); + debugFloat(&logger, "fuel", ENGINE(actualLastInjection), 2); debugFloat(&logger, "timing", engine->engineState.timingAdvance, 2); @@ -600,7 +599,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->fuelLevel = engine->engineState.fuelLevel; tsOutputChannels->hasFatalError = hasFirmwareError(); tsOutputChannels->totalTriggerErrorCounter = triggerCentral.triggerState.totalTriggerErrorCounter; - tsOutputChannels->wallFuelAmount = wallFuel.getWallFuel(); + tsOutputChannels->wallFuelAmount = wallFuel.getWallFuel(0); tsOutputChannels->checkEngine = hasErrorCodes(); #if EFI_PROD_CODE || defined(__DOXYGEN__) @@ -642,7 +641,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->ignitionAdvance = timing > 360 ? timing - 720 : timing; tsOutputChannels->sparkDwell = ENGINE(engineState.sparkDwell); tsOutputChannels->baseFuel = baseFuelMs; - tsOutputChannels->pulseWidthMs = getFuelMs(rpm PASS_ENGINE_PARAMETER); + tsOutputChannels->pulseWidthMs = ENGINE(actualLastInjection); tsOutputChannels->crankingFuelMs = getCrankingFuel(PASS_ENGINE_PARAMETER_F); } diff --git a/firmware/controllers/algo/accel_enrichment.cpp b/firmware/controllers/algo/accel_enrichment.cpp index 48bd4d12f4..1b08bf4fce 100644 --- a/firmware/controllers/algo/accel_enrichment.cpp +++ b/firmware/controllers/algo/accel_enrichment.cpp @@ -35,24 +35,23 @@ static Logging *logger; WallFuel wallFuel; WallFuel::WallFuel() { - wallFuel = 0; + memset(wallFuel, 0, sizeof(wallFuel)); } -floatms_t WallFuel::adjust(floatms_t target DECLARE_ENGINE_PARAMETER_S) { - float suckedOffCoef = 0; - float addedToWallCoef = 0; +floatms_t WallFuel::adjust(int injectorIndex, floatms_t target DECLARE_ENGINE_PARAMETER_S) { + float addedToWallCoef = engineConfiguration->addedToWallCoef; - floatms_t suckedOffWallsAmount = wallFuel * suckedOffCoef; + floatms_t suckedOffWallsAmount = wallFuel[injectorIndex] * engineConfiguration->suckedOffCoef; floatms_t result = (target - suckedOffWallsAmount) / (1 - addedToWallCoef); float addedToWallsAmount = result * addedToWallCoef; - wallFuel = wallFuel + addedToWallsAmount - suckedOffWallsAmount; + wallFuel[injectorIndex] = wallFuel[injectorIndex] + addedToWallsAmount - suckedOffWallsAmount; return result; } -floatms_t WallFuel::getWallFuel() { - return wallFuel; +floatms_t WallFuel::getWallFuel(int injectorIndex) { + return wallFuel[injectorIndex]; } float AccelEnrichmemnt::getDelta() { diff --git a/firmware/controllers/algo/accel_enrichment.h b/firmware/controllers/algo/accel_enrichment.h index 75c776aa71..7437bf09b5 100644 --- a/firmware/controllers/algo/accel_enrichment.h +++ b/firmware/controllers/algo/accel_enrichment.h @@ -43,14 +43,14 @@ private: class WallFuel { public: WallFuel(); - floatms_t adjust(floatms_t target DECLARE_ENGINE_PARAMETER_S); - floatms_t getWallFuel(); + floatms_t adjust(int injectorIndex, floatms_t target DECLARE_ENGINE_PARAMETER_S); + floatms_t getWallFuel(int injectorIndex); private: /** - * Amount of fuel on the wall, in injector open time scale + * Amount of fuel on the wall, in injector open time scale, for specific injector. */ - floatms_t wallFuel; + floatms_t wallFuel[INJECTION_PIN_COUNT]; }; void initAccelEnrichment(Logging *sharedLogger); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index bbff08e0ac..d6bada8048 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -89,6 +89,9 @@ public: float iat; float clt; + /** + * that's fuel in tank - just a gauge + */ percent_t fuelLevel; ThermistorMath iatCurve; @@ -185,10 +188,15 @@ public: AccelEnrichmemnt tpsAccelEnrichment; /** - * Fuel injection duration for current engine cycle + * Fuel injection duration for current engine cycle, without wall wetting */ floatms_t fuelMs; + /** + * This one with wall wetting accounted for, used for logging. + */ + floatms_t actualLastInjection; + void periodicFastCallback(DECLARE_ENGINE_PARAMETER_F); diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index 70eaddbae7..a07c71cf9c 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -36,6 +36,7 @@ public: InjectionEvent(); event_trigger_position_s injectionStart; OutputSignal actuator; + int injectorIndex; /** * This is a performance optimization - it's more efficient to handle all * injectors together if that's the case diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 5d708f7dd5..c71a55aaca 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -128,6 +128,7 @@ void FuelSchedule::registerInjectionEvent(int injectorIndex, float angle, return; } + ev->injectorIndex = injectorIndex; ev->actuator.output = output; ev->isSimultanious = isSimultanious; diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 3ebcd7d46c..c852ca2ef9 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -101,8 +101,17 @@ static void endSimultaniousInjection(Engine *engine) { } } +extern WallFuel wallFuel; + static ALWAYS_INLINE void handleFuelInjectionEvent(InjectionEvent *event, int rpm DECLARE_ENGINE_PARAMETER_S) { - floatms_t injectionDuration = ENGINE(fuelMs); + /** + * todo: this is a bit tricky with batched injection. is it? Does the same + * wetting coefficient works the same way for any injection mode, or is something + * x2 or /2? + */ + floatms_t injectionDuration = ENGINE(fuelMs);//wallFuel.adjust(event->injectorIndex, ENGINE(fuelMs)); + + ENGINE(actualLastInjection) = injectionDuration; if (cisnan(injectionDuration)) { warning(OBD_PCM_Processor_Fault, "NaN injection pulse"); return;