From a8f7a8965b2629692dcc5db3b50b6f9397f02cc3 Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 26 Aug 2019 23:41:04 -0400 Subject: [PATCH] cranking fuel live data #911 --- firmware/console/status_loop.cpp | 22 ++-- firmware/controllers/algo/engine.cpp | 2 +- firmware/controllers/algo/engine2.cpp | 12 +-- firmware/controllers/algo/engine_state.h | 26 ----- firmware/controllers/algo/fuel_math.cpp | 101 ++++++++++-------- firmware/controllers/core/common_headers.h | 1 + firmware/controllers/engine_controller.cpp | 2 +- .../generated/engine_state_generated.h | 95 +++++++++++++++- .../trigger/main_trigger_callback.cpp | 8 +- firmware/gen_config2.bat | 1 + firmware/integration/engine_state.txt | 44 +++++++- .../rusefi/config/generated/EngineState.java | 30 +++++- .../rusefi/ldmp/generated/FuelMathMeta.java | 17 +++ .../com/rusefi/ldmp/LiveDocsMetaParser.java | 10 +- unit_tests/tests/test_trigger_decoder.cpp | 6 +- 15 files changed, 272 insertions(+), 105 deletions(-) create mode 100644 java_console/ui/src/com/rusefi/ldmp/generated/FuelMathMeta.java diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index df60ee5644..90d4debbb3 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -296,9 +296,9 @@ static void printSensors(Logging *log) { floatms_t fuelBase = getBaseFuel(rpm PASS_ENGINE_PARAMETER_SUFFIX); reportSensorF(log, GAUGE_NAME_FUEL_BASE, "ms", fuelBase, 2); reportSensorF(log, GAUGE_NAME_FUEL_LAST_INJECTION, "ms", ENGINE(actualLastInjection), 2); - reportSensorF(log, GAUGE_NAME_INJECTOR_LAG, "ms", engine->engineState.injectorLag, 2); - reportSensorF(log, GAUGE_NAME_FUEL_RUNNING, "ms", ENGINE(engineState.runningFuel), 2); - reportSensorF(log, GAUGE_NAME_FUEL_PID_CORR, "ms", ENGINE(engineState.fuelPidCorrection), 2); + reportSensorF(log, GAUGE_NAME_INJECTOR_LAG, "ms", engine->engineState.running.injectorLag, 2); + reportSensorF(log, GAUGE_NAME_FUEL_RUNNING, "ms", ENGINE(engineState.running.fuel), 2); + reportSensorF(log, GAUGE_NAME_FUEL_PID_CORR, "ms", ENGINE(engineState.running.pidCorrection), 2); reportSensorF(log, GAUGE_NAME_FUEL_WALL_AMOUNT, "v", ENGINE(wallFuel).getWallFuel(0), 2); reportSensorF(log, GAUGE_NAME_FUEL_WALL_CORRECTION, "v", ENGINE(wallFuel).wallFuelCorrection, 2); @@ -521,9 +521,9 @@ static void showFuelInfo2(float rpm, float engineLoad) { scheduleMsg(&logger2, "cranking fuel: %.2f", getCrankingFuel(PASS_ENGINE_PARAMETER_SIGNATURE)); if (!engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) { - float iatCorrection = engine->engineState.iatFuelCorrection; - float cltCorrection = engine->engineState.cltFuelCorrection; - floatms_t injectorLag = engine->engineState.injectorLag; + float iatCorrection = engine->engineState.running.intakeTemperatureCoefficient; + float cltCorrection = engine->engineState.running.coolantTemperatureCoefficient; + floatms_t injectorLag = engine->engineState.running.injectorLag; scheduleMsg(&logger2, "rpm=%.2f engineLoad=%.2f", rpm, engineLoad); scheduleMsg(&logger2, "baseFuel=%.2f", baseFuelMs); @@ -721,9 +721,9 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->totalTriggerErrorCounter = engine->triggerCentral.triggerState.totalTriggerErrorCounter; tsOutputChannels->injectorDutyCycle = getInjectorDutyCycle(rpm PASS_ENGINE_PARAMETER_SUFFIX); - tsOutputChannels->fuelRunning = ENGINE(engineState.runningFuel); - tsOutputChannels->fuelPidCorrection = ENGINE(engineState.fuelPidCorrection); - tsOutputChannels->injectorLagMs = ENGINE(engineState.injectorLag); + tsOutputChannels->fuelRunning = ENGINE(engineState.running.fuel); + tsOutputChannels->fuelPidCorrection = ENGINE(engineState.running.pidCorrection); + tsOutputChannels->injectorLagMs = ENGINE(engineState.running.injectorLag); tsOutputChannels->fuelBase = engine->engineState.baseFuel; tsOutputChannels->actualLastInjection = ENGINE(actualLastInjection); @@ -872,8 +872,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->engineLoadDelta = engine->engineLoadAccelEnrichment.getMaxDelta(); - tsOutputChannels->iatCorrection = ENGINE(engineState.iatFuelCorrection); - tsOutputChannels->cltCorrection = ENGINE(engineState.cltFuelCorrection); + tsOutputChannels->iatCorrection = ENGINE(engineState.running.intakeTemperatureCoefficient); + tsOutputChannels->cltCorrection = ENGINE(engineState.running.coolantTemperatureCoefficient); tsOutputChannels->checkEngine = hasErrorCodes(); diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 030b8b2cc4..5197774996 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -158,7 +158,7 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { vBattForTle8888 = sensors.vBatt; #endif /* BOARD_TLE8888_COUNT */ - engineState.injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER_SUFFIX); + engineState.running.injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER_SUFFIX); #endif } diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index 61a9dfb0c8..0fd737d25b 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -156,9 +156,9 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } // todo: move this into slow callback, no reason for IAT corr to be here - iatFuelCorrection = getIatFuelCorrection(engine->sensors.iat PASS_ENGINE_PARAMETER_SUFFIX); + running.intakeTemperatureCoefficient = getIatFuelCorrection(engine->sensors.iat PASS_ENGINE_PARAMETER_SUFFIX); // todo: move this into slow callback, no reason for CLT corr to be here - cltFuelCorrection = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); + running.coolantTemperatureCoefficient = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); // update fuel consumption states fuelConsumption.update(nowNt PASS_ENGINE_PARAMETER_SUFFIX); @@ -170,12 +170,12 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // for compatibility reasons, apply only if the factor is greater than zero (0.01 margin used) if (engineConfiguration->postCrankingFactor > 0.01f) { // convert to microsecs and then to seconds - float timeSinceCrankingInSecs = NT2US(timeSinceCranking) / 1000000.0f; + running.timeSinceCrankingInSecs = NT2US(timeSinceCranking) / 1000000.0f; // use interpolation for correction taper - postCrankingFuelCorrection = interpolateClamped(0.0f, engineConfiguration->postCrankingFactor, - engineConfiguration->postCrankingDurationSec, 1.0f, timeSinceCrankingInSecs); + running.postCrankingFuelCorrection = interpolateClamped(0.0f, engineConfiguration->postCrankingFactor, + engineConfiguration->postCrankingDurationSec, 1.0f, running.timeSinceCrankingInSecs); } else { - postCrankingFuelCorrection = 1.0f; + running.postCrankingFuelCorrection = 1.0f; } cltTimingCorrection = getCltTimingCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/algo/engine_state.h b/firmware/controllers/algo/engine_state.h index e3f9511550..6e804abecd 100644 --- a/firmware/controllers/algo/engine_state.h +++ b/firmware/controllers/algo/engine_state.h @@ -72,20 +72,8 @@ public: angle_t cltTimingCorrection = 0; // fuel-related; - float iatFuelCorrection = 0; - float cltFuelCorrection = 0; - float postCrankingFuelCorrection = 0; float fuelCutoffCorrection = 0; efitick_t coastingFuelCutStartTime = 0; - /** - * injectorLag(VBatt) - * - * this value depends on a slow-changing VBatt value, so - * we update it once in a while - */ - floatms_t injectorLag = 0; - - float baroCorrection = 0; efitick_t timeSinceLastTChargeK; @@ -104,20 +92,6 @@ public: */ floatms_t baseFuel = 0; - /** - * closed-loop fuel correction - */ - floatms_t fuelPidCorrection = 0; - - /** - * Total fuel with CLT, IAT and TPS acceleration corrections per cycle, - * as squirt duration. - * Without injector lag. - * @see baseFuel - * @see actualLastInjection - */ - floatms_t runningFuel = 0; - /** * TPS acceleration: extra fuel amount */ diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 7525a1728b..7b8434438f 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -2,14 +2,6 @@ * @file fuel_math.cpp * @brief Fuel amount calculation logic * - * While engine running, fuel amount is an interpolated value from the fuel map by getRpm() and getEngineLoad() - * On top of the value from the fuel map we also apply - *
1) getInjectorLag() correction to account for fuel injector lag - *
2) getCltFuelCorrection() for warm-up - *
3) getIatCorrection() to account for cold weather - * - * getCrankingFuel() depents only on getCoolantTemperature() - * * * @date May 27, 2013 * @author Andrey Belomutskiy, (c) 2012-2018 @@ -49,6 +41,59 @@ extern baroCorr_Map3D_t baroCorrMap; #if EFI_ENGINE_CONTROL +DISPLAY(DISPLAY_IF(isCranking)) floatms_t getCrankingFuel3(float coolantTemperature, + uint32_t revolutionCounterSinceStart DECLARE_ENGINE_PARAMETER_SUFFIX) { + // these magic constants are in Celsius + float baseCrankingFuel = engineConfiguration->cranking.baseFuel; + /** + * Cranking fuel changes over time + */ + engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(durationCoefficient) = interpolate2d("crank", revolutionCounterSinceStart, config->crankingCycleBins, + config->crankingCycleCoef); + + /** + * Cranking fuel is different depending on engine coolant temperature + */ + engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(coolantTemperatureCoefficient) = cisnan(coolantTemperature) ? 1 : interpolate2d("crank", coolantTemperature, config->crankingFuelBins, + config->crankingFuelCoef); + + percent_t tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); + + engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) = cisnan(tps) ? 1 : interpolate2d("crankTps", tps, engineConfiguration->crankingTpsBins, + engineConfiguration->crankingTpsCoef); + + floatms_t crankingFuel = engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(fuel) = baseCrankingFuel + * engine->engineState.cranking.durationCoefficient + * engine->engineState.cranking.coolantTemperatureCoefficient + * engine->engineState.cranking.tpsCoefficient; + + if (crankingFuel <= 0) { + warning(CUSTOM_ERR_ZERO_CRANKING_FUEL, "Cranking fuel value %f", crankingFuel); + } + return crankingFuel; +} + +/* DISPLAY_ELSE */ + +floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) { + float iatCorrection = ENGINE(engineState.running.intakeTemperatureCoefficient); + float cltCorrection = ENGINE(engineState.running.coolantTemperatureCoefficient); + float postCrankingFuelCorrection = ENGINE(engineState.running.postCrankingFuelCorrection); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(iatCorrection), "NaN iatCorrection", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(cltCorrection), "NaN cltCorrection", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(postCrankingFuelCorrection), "NaN postCrankingFuelCorrection", 0); + + floatms_t runningFuel = baseFuel * iatCorrection * cltCorrection * postCrankingFuelCorrection + ENGINE(engineState.running.pidCorrection); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(runningFuel), "NaN runningFuel", 0); + ENGINE(engineState.running.fuel) = runningFuel; + + return runningFuel; +} + + + +/* DISPLAY_ENDIF */ + /** * @return total duration of fuel injection per engine cycle, in milliseconds */ @@ -185,7 +230,7 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { return 0; floatms_t theoreticalInjectionLength = fuelPerCycle / numberOfInjections; - floatms_t injectorLag = ENGINE(engineState.injectorLag); + floatms_t injectorLag = ENGINE(engineState.running.injectorLag); if (cisnan(injectorLag)) { warning(CUSTOM_ERR_INJECTOR_LAG, "injectorLag not ready"); return 0; // we can end up here during configuration reset @@ -196,21 +241,6 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { #endif } -floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) { - float iatCorrection = ENGINE(engineState.iatFuelCorrection); - float cltCorrection = ENGINE(engineState.cltFuelCorrection); - float postCrankingFuelCorrection = ENGINE(engineState.postCrankingFuelCorrection); - efiAssert(CUSTOM_ERR_ASSERT, !cisnan(iatCorrection), "NaN iatCorrection", 0); - efiAssert(CUSTOM_ERR_ASSERT, !cisnan(cltCorrection), "NaN cltCorrection", 0); - efiAssert(CUSTOM_ERR_ASSERT, !cisnan(postCrankingFuelCorrection), "NaN postCrankingFuelCorrection", 0); - - floatms_t runningFuel = baseFuel * iatCorrection * cltCorrection * postCrankingFuelCorrection + ENGINE(engineState.fuelPidCorrection); - efiAssert(CUSTOM_ERR_ASSERT, !cisnan(runningFuel), "NaN runningFuel", 0); - ENGINE(engineState.runningFuel) = runningFuel; - - return runningFuel; -} - /** * @brief Injector lag correction * @param vBatt Battery voltage. @@ -335,29 +365,6 @@ floatms_t getCrankingFuel(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } #endif -floatms_t getCrankingFuel3(float coolantTemperature, - uint32_t revolutionCounterSinceStart DECLARE_ENGINE_PARAMETER_SUFFIX) { - // these magic constants are in Celsius - float baseCrankingFuel = engineConfiguration->cranking.baseFuel; - float durationCoef = interpolate2d("crank", revolutionCounterSinceStart, config->crankingCycleBins, - config->crankingCycleCoef); - - float coolantTempCoef = cisnan(coolantTemperature) ? 1 : interpolate2d("crank", coolantTemperature, config->crankingFuelBins, - config->crankingFuelCoef); - - percent_t tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); - - float tpsCoef = cisnan(tps) ? 1 : interpolate2d("crankTps", tps, engineConfiguration->crankingTpsBins, - engineConfiguration->crankingTpsCoef); - - floatms_t result = baseCrankingFuel * durationCoef * coolantTempCoef * tpsCoef; - - if (result <= 0) { - warning(CUSTOM_ERR_ZERO_CRANKING_FUEL, "Cranking fuel value %f", result); - } - return result; -} - float getFuelRate(floatms_t totalInjDuration, efitick_t timePeriod DECLARE_ENGINE_PARAMETER_SUFFIX) { if (timePeriod <= 0.0f) return 0.0f; diff --git a/firmware/controllers/core/common_headers.h b/firmware/controllers/core/common_headers.h index c76c8339eb..6f3e3ffaac 100644 --- a/firmware/controllers/core/common_headers.h +++ b/firmware/controllers/core/common_headers.h @@ -34,6 +34,7 @@ // See also 'TS_GET_STRUCT' #define DISPLAY_CONFIG(x) x +#define DISPLAY_PREFIX(x) x #define DISPLAY_FIELD(x) x // we use this 'DISPLAY' macro if value is not used by C++ in current context #define DISPLAY(x) diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index c0e340351e..5374b7935d 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -812,6 +812,6 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 20190818; + return 20190826; } #endif /* EFI_UNIT_TEST */ diff --git a/firmware/controllers/generated/engine_state_generated.h b/firmware/controllers/generated/engine_state_generated.h index d8ce16c561..d6c12d9cdd 100644 --- a/firmware/controllers/generated/engine_state_generated.h +++ b/firmware/controllers/generated/engine_state_generated.h @@ -1,4 +1,4 @@ -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sun Jul 21 18:03:23 EDT 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Mon Aug 26 23:28:23 EDT 2019 // by class com.rusefi.output.CHeaderConsumer // begin #ifndef CONTROLLERS_GENERATED_ENGINE_STATE_GENERATED_H @@ -101,6 +101,80 @@ struct idle_state_s { typedef struct idle_state_s idle_state_s; +// start of cranking_fuel_s +struct cranking_fuel_s { + /** + * Duration of injection, in ms. During cranking we do not account for injector flow, so if you change injectors you would need to change settings. + * Deprecated. Please use '1'. + * TODO: maybe account for injector flow? + * offset 0 + */ + floatms_t baseFuel = (floatms_t)0; + /** + * offset 4 + */ + float coolantTemperatureCoefficient = (float)0; + /** + * offset 8 + */ + float tpsCoefficient = (float)0; + /** + * offset 12 + */ + float durationCoefficient = (float)0; + /** + * Actual injection duration based on all above coefficients. + * offset 16 + */ + floatms_t fuel = (floatms_t)0; + /** total size 20*/ +}; + +typedef struct cranking_fuel_s cranking_fuel_s; + +// start of running_fuel_s +struct running_fuel_s { + /** + * offset 0 + */ + float postCrankingFuelCorrection = (float)0; + /** + * offset 4 + */ + float intakeTemperatureCoefficient = (float)0; + /** + * offset 8 + */ + float coolantTemperatureCoefficient = (float)0; + /** + * offset 12 + */ + float timeSinceCrankingInSecs = (float)0; + /** + * injectorLag(VBatt) + * this value depends on a slow-changing VBatt value, so + * we update it once in a while + * offset 16 + */ + floatms_t injectorLag = (floatms_t)0; + /** + * closed-loop fuel correction + * offset 20 + */ + floatms_t pidCorrection = (floatms_t)0; + /** + * Actual injection duration with CLT, IAT and TPS acceleration corrections per cycle, as squirt duration. + * Without injector lag. + * @see baseFuel + * @see actualLastInjection + * offset 24 + */ + floatms_t fuel = (floatms_t)0; + /** total size 28*/ +}; + +typedef struct running_fuel_s running_fuel_s; + // start of engine_state2_s struct engine_state2_s { /** @@ -139,11 +213,26 @@ struct engine_state2_s { * offset 72 */ float currentBaroCorrectedVE = (float)0; - /** total size 76*/ + /** + * offset 76 + */ + float baroCorrection = (float)0; + /** + offset 80 bit 0 */ + bool isCranking : 1; + /** + * offset 84 + */ + cranking_fuel_s cranking; + /** + * offset 104 + */ + running_fuel_s running; + /** total size 132*/ }; typedef struct engine_state2_s engine_state2_s; #endif // end -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sun Jul 21 18:03:23 EDT 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Mon Aug 26 23:28:23 EDT 2019 diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 785eba5755..4026b628b7 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -231,7 +231,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE } // Store 'pure' injection duration (w/o injector lag) for fuel rate calc. - engine->engineState.fuelConsumption.addData(injectionDuration - ENGINE(engineState.injectorLag)); + engine->engineState.fuelConsumption.addData(injectionDuration - ENGINE(engineState.running.injectorLag)); ENGINE(actualLastInjection) = injectionDuration; if (cisnan(injectionDuration)) { @@ -350,15 +350,15 @@ static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) { getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CONFIG(fuelClosedLoopTpsThreshold) || ENGINE(sensors.currentAfr) < CONFIGB(fuelClosedLoopAfrLowThreshold) || ENGINE(sensors.currentAfr) > engineConfiguration->fuelClosedLoopAfrHighThreshold) { - engine->engineState.fuelPidCorrection = 0; + engine->engineState.running.pidCorrection = 0; fuelPid.reset(); return; } - engine->engineState.fuelPidCorrection = fuelPid.getOutput(ENGINE(engineState.targetAFR), ENGINE(sensors.currentAfr), NOT_TIME_BASED_PID); + engine->engineState.running.pidCorrection = fuelPid.getOutput(ENGINE(engineState.targetAFR), ENGINE(sensors.currentAfr), NOT_TIME_BASED_PID); if (engineConfiguration->debugMode == DBG_FUEL_PID_CORRECTION) { #if EFI_TUNER_STUDIO - tsOutputChannels.debugFloatField1 = engine->engineState.fuelPidCorrection; + tsOutputChannels.debugFloatField1 = engine->engineState.running.pidCorrection; fuelPid.postState(&tsOutputChannels); #endif /* EFI_TUNER_STUDIO */ } diff --git a/firmware/gen_config2.bat b/firmware/gen_config2.bat index b2a0d61822..06a29107fd 100644 --- a/firmware/gen_config2.bat +++ b/firmware/gen_config2.bat @@ -34,6 +34,7 @@ java -DSystemOut.name=gen_config2 ^ %LIVE_DOCS_COMMAND% controllers/sensors/thermistors.cpp %LIVE_DOCS_COMMAND% controllers/sensors/tps.cpp %LIVE_DOCS_COMMAND% controllers/math/speed_density.cpp +%LIVE_DOCS_COMMAND% controllers/algo/fuel_math.cpp %LIVE_DOCS_COMMAND% controllers/actuators/electronic_throttle.cpp java -DSystemOut.name=gen_config2 ^ diff --git a/firmware/integration/engine_state.txt b/firmware/integration/engine_state.txt index 1684cfa589..00703ea34b 100644 --- a/firmware/integration/engine_state.txt +++ b/firmware/integration/engine_state.txt @@ -41,9 +41,10 @@ struct_no_prefix idle_state_s percent_t currentIdlePosition;that's current position with CLT and IAT corrections percent_t baseIdlePosition;current position without adjustments (iacByTpsTaper, afterCrankingIACtaperDuration) int throttleUpState - +! end of idle_state_s structure definition end_struct +! actually define a member of 'idle_state_s' type idle_state_s idle; float targetAFR @@ -59,6 +60,47 @@ float tpsVoltageMCU float tpsVoltageBoard float currentBaroCorrectedVE; +float baroCorrection; + +bit isCranking + +struct cranking_fuel_s + +floatms_t baseFuel;Duration of injection, in ms. During cranking we do not account for injector flow, so if you change injectors you would need to change settings.\nDeprecated. Please use '1'.\nTODO: maybe account for injector flow? +float coolantTemperatureCoefficient; +float tpsCoefficient +float durationCoefficient +floatms_t fuel;Actual injection duration based on all above coefficients. + +! end of cranking_s structure definition +end_struct + +! actually define a member of 'cranking_s' type +cranking_fuel_s cranking + + + +struct running_fuel_s +float postCrankingFuelCorrection + float intakeTemperatureCoefficient + float coolantTemperatureCoefficient + float timeSinceCrankingInSecs + + + floatms_t injectorLag;injectorLag(VBatt)\nthis value depends on a slow-changing VBatt value, so\nwe update it once in a while + + floatms_t pidCorrection;closed-loop fuel correction + + + floatms_t fuel;Actual injection duration with CLT, IAT and TPS acceleration corrections per cycle, as squirt duration.\nWithout injector lag.\n@see baseFuel\n@see actualLastInjection + + + +! end of running_fuel_s structure definition +end_struct + +! actually define a member of 'running_fuel_s' type +running_fuel_s running ! engine_state2_s end_struct diff --git a/java_console/models/src/com/rusefi/config/generated/EngineState.java b/java_console/models/src/com/rusefi/config/generated/EngineState.java index a15767e32e..245f03dfe8 100644 --- a/java_console/models/src/com/rusefi/config/generated/EngineState.java +++ b/java_console/models/src/com/rusefi/config/generated/EngineState.java @@ -1,6 +1,6 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sun Jul 21 18:03:23 EDT 2019 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Mon Aug 26 23:28:23 EDT 2019 // by class com.rusefi.output.JavaFieldsConsumer import com.rusefi.config.*; @@ -30,6 +30,20 @@ public class EngineState { public static final Field TPSVOLTAGEMCU = Field.create("TPSVOLTAGEMCU", 64, FieldType.FLOAT); public static final Field TPSVOLTAGEBOARD = Field.create("TPSVOLTAGEBOARD", 68, FieldType.FLOAT); public static final Field CURRENTBAROCORRECTEDVE = Field.create("CURRENTBAROCORRECTEDVE", 72, FieldType.FLOAT); + public static final Field BAROCORRECTION = Field.create("BAROCORRECTION", 76, FieldType.FLOAT); + public static final Field ISCRANKING = Field.create("ISCRANKING", 80, FieldType.BIT, 0); + public static final Field CRANKING_BASEFUEL = Field.create("CRANKING_BASEFUEL", 84, FieldType.FLOAT); + public static final Field CRANKING_COOLANTTEMPERATURECOEFFICIENT = Field.create("CRANKING_COOLANTTEMPERATURECOEFFICIENT", 88, FieldType.FLOAT); + public static final Field CRANKING_TPSCOEFFICIENT = Field.create("CRANKING_TPSCOEFFICIENT", 92, FieldType.FLOAT); + public static final Field CRANKING_DURATIONCOEFFICIENT = Field.create("CRANKING_DURATIONCOEFFICIENT", 96, FieldType.FLOAT); + public static final Field CRANKING_FUEL = Field.create("CRANKING_FUEL", 100, FieldType.FLOAT); + public static final Field RUNNING_POSTCRANKINGFUELCORRECTION = Field.create("RUNNING_POSTCRANKINGFUELCORRECTION", 104, FieldType.FLOAT); + public static final Field RUNNING_INTAKETEMPERATURECOEFFICIENT = Field.create("RUNNING_INTAKETEMPERATURECOEFFICIENT", 108, FieldType.FLOAT); + public static final Field RUNNING_COOLANTTEMPERATURECOEFFICIENT = Field.create("RUNNING_COOLANTTEMPERATURECOEFFICIENT", 112, FieldType.FLOAT); + public static final Field RUNNING_TIMESINCECRANKINGINSECS = Field.create("RUNNING_TIMESINCECRANKINGINSECS", 116, FieldType.FLOAT); + public static final Field RUNNING_INJECTORLAG = Field.create("RUNNING_INJECTORLAG", 120, FieldType.FLOAT); + public static final Field RUNNING_PIDCORRECTION = Field.create("RUNNING_PIDCORRECTION", 124, FieldType.FLOAT); + public static final Field RUNNING_FUEL = Field.create("RUNNING_FUEL", 128, FieldType.FLOAT); public static final Field[] VALUES = { ITERM, DTERM, @@ -55,5 +69,19 @@ public class EngineState { TPSVOLTAGEMCU, TPSVOLTAGEBOARD, CURRENTBAROCORRECTEDVE, + BAROCORRECTION, + ISCRANKING, + CRANKING_BASEFUEL, + CRANKING_COOLANTTEMPERATURECOEFFICIENT, + CRANKING_TPSCOEFFICIENT, + CRANKING_DURATIONCOEFFICIENT, + CRANKING_FUEL, + RUNNING_POSTCRANKINGFUELCORRECTION, + RUNNING_INTAKETEMPERATURECOEFFICIENT, + RUNNING_COOLANTTEMPERATURECOEFFICIENT, + RUNNING_TIMESINCECRANKINGINSECS, + RUNNING_INJECTORLAG, + RUNNING_PIDCORRECTION, + RUNNING_FUEL, }; } diff --git a/java_console/ui/src/com/rusefi/ldmp/generated/FuelMathMeta.java b/java_console/ui/src/com/rusefi/ldmp/generated/FuelMathMeta.java new file mode 100644 index 0000000000..605279fcdb --- /dev/null +++ b/java_console/ui/src/com/rusefi/ldmp/generated/FuelMathMeta.java @@ -0,0 +1,17 @@ +package com.rusefi.ldmp.generated; + +import com.rusefi.ldmp.*; + +public class FuelMathMeta { + public static final Request[] CONTENT = new Request[]{ + new IfRequest("isCranking", + new Request[]{ + new FieldRequest("cranking_durationCoefficient"), + new FieldRequest("cranking_coolantTemperatureCoefficient"), + new FieldRequest("cranking_tpsCoefficient"), + new FieldRequest("cranking_fuel"), +}, + new Request[]{ +}), + }; +} \ No newline at end of file diff --git a/java_tools/configuration_definition/src/com/rusefi/ldmp/LiveDocsMetaParser.java b/java_tools/configuration_definition/src/com/rusefi/ldmp/LiveDocsMetaParser.java index e16fb8c6f7..a1f57b18bc 100644 --- a/java_tools/configuration_definition/src/com/rusefi/ldmp/LiveDocsMetaParser.java +++ b/java_tools/configuration_definition/src/com/rusefi/ldmp/LiveDocsMetaParser.java @@ -16,12 +16,14 @@ import static com.rusefi.ConfigDefinition.EOL; public class LiveDocsMetaParser { private static final String DISPLAY_TAG = "DISPLAY_TAG"; private static final String DISPLAY_CONFIG = "DISPLAY_CONFIG"; + private static final String DISPLAY_PREFIX = "DISPLAY_PREFIX"; private static final String DISPLAY_FIELD = "DISPLAY_FIELD"; private static final String DISPLAY_TEXT = "DISPLAY_TEXT"; private static final String DISPLAY_SENSOR = "DISPLAY_SENSOR"; private static final String DISPLAY_IF = "DISPLAY_IF"; private static final String DISPLAY_ELSE = "DISPLAY_ELSE"; private static final String DISPLAY_ENDIF = "DISPLAY_ENDIF"; + private static StringBuilder prefix = new StringBuilder(); private static String readLineByLine(String filePath) throws IOException { StringBuilder contentBuilder = new StringBuilder(); @@ -85,11 +87,17 @@ public class LiveDocsMetaParser { SystemOut.println("REQ TAG " + tag); result = meta.start(tag); } + } else if (DISPLAY_PREFIX.equalsIgnoreCase(token)) { + if (s.hasNext()) { + String current = s.next(); + prefix.append(current + "_"); + } } else if (DISPLAY_FIELD.equalsIgnoreCase(token)) { if (s.hasNext()) { - String config = s.next(); + String config = prefix + s.next(); SystemOut.println("REQ FIELD " + config); result.add(new FieldRequest(config)); + prefix.setLength(0); } } else if (DISPLAY_IF.equalsIgnoreCase(token)) { if (s.hasNext()) { diff --git a/unit_tests/tests/test_trigger_decoder.cpp b/unit_tests/tests/test_trigger_decoder.cpp index 38e7ca5a98..1807a3639f 100644 --- a/unit_tests/tests/test_trigger_decoder.cpp +++ b/unit_tests/tests/test_trigger_decoder.cpp @@ -659,9 +659,9 @@ static void setTestBug299(EngineTestHelper *eth) { ASSERT_EQ( 0, eth->executeActions()) << "exec#3"; - ASSERT_EQ( 1, engine->engineState.iatFuelCorrection) << "iatC"; - ASSERT_EQ( 1, engine->engineState.cltFuelCorrection) << "cltC"; - ASSERT_EQ( 0, engine->engineState.injectorLag) << "lag"; + ASSERT_EQ( 1, engine->engineState.running.intakeTemperatureCoefficient) << "iatC"; + ASSERT_EQ( 1, engine->engineState.running.coolantTemperatureCoefficient) << "cltC"; + ASSERT_EQ( 0, engine->engineState.running.injectorLag) << "lag"; testMafValue = 0; ASSERT_EQ( 0, getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE)) << "maf";