From 2b8b43ca5547963e6dbfdd9d70ea1e8923aa0cda Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sun, 5 Jul 2020 13:25:19 -0700 Subject: [PATCH] plumb new load channels (#1573) * wire up new channels * add deprecation comment * add gauges * these tables are indeed used in those modes * simplify Co-authored-by: Matthew Kennedy --- firmware/console/status_loop.cpp | 7 ++++--- firmware/controllers/algo/engine_state.h | 2 ++ firmware/controllers/algo/fuel_math.cpp | 8 ++++++++ firmware/controllers/math/engine_math.cpp | 8 ++++++++ firmware/controllers/math/engine_math.h | 3 +++ firmware/integration/rusefi_config.txt | 9 +++++---- firmware/tunerstudio/rusefi.input | 6 ++++-- 7 files changed, 34 insertions(+), 9 deletions(-) diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 8ffe588860..0b678d1985 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -474,8 +474,6 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ executorStatistics(); #endif /* EFI_PROD_CODE */ - float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE); - // header tsOutputChannels->tsConfigVersion = TS_FILE_VERSION; @@ -524,7 +522,10 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->airFuelRatio = getAfr(PASS_ENGINE_PARAMETER_SIGNATURE); } // offset 24 - tsOutputChannels->engineLoad = engineLoad; + tsOutputChannels->engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE); + + tsOutputChannels->fuelingLoad = getFuelingLoad(PASS_ENGINE_PARAMETER_SIGNATURE); + tsOutputChannels->ignitionLoad = getIgnitionLoad(PASS_ENGINE_PARAMETER_SIGNATURE); // KLUDGE? we always show VBatt because Proteus board has VBatt input sensor hardcoded // offset 28 diff --git a/firmware/controllers/algo/engine_state.h b/firmware/controllers/algo/engine_state.h index 0d3845da56..50361ab441 100644 --- a/firmware/controllers/algo/engine_state.h +++ b/firmware/controllers/algo/engine_state.h @@ -63,6 +63,8 @@ public: int vssEventCounter = 0; + float fuelingLoad = 0; + float ignitionLoad = 0; /** * pre-calculated value from simple fuel lookup diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 442b3e2b0b..db2f22058b 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -239,10 +239,18 @@ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { // Plop some state for others to read ENGINE(engineState.targetAFR) = targetAfr; ENGINE(engineState.sd.airMassInOneCylinder) = airmass.CylinderAirmass; + ENGINE(engineState.fuelingLoad) = airmass.EngineLoadPercent; + // TODO: independently selectable ignition load mode + ENGINE(engineState.ignitionLoad) = airmass.EngineLoadPercent; baseFuel = getInjectionDurationForAirmass(airmass.CylinderAirmass, targetAfr PASS_ENGINE_PARAMETER_SUFFIX) * 1000; efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN baseFuel", 0); } else { + float tps = Sensor::get(SensorType::Tps1).value_or(0); + ENGINE(engineState.fuelingLoad) = tps; + // TODO: independently selectable ignition load mode + ENGINE(engineState.ignitionLoad) = tps; + baseFuel = engine->engineState.baseTableFuel; efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN bt baseFuel", 0); } diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index de2305add5..38bd003840 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -49,6 +49,14 @@ floatms_t getCrankshaftRevolutionTimeMs(int rpm) { return 360 * getOneDegreeTimeMs(rpm); } +float getFuelingLoad(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + return ENGINE(engineState.fuelingLoad); +} + +float getIgnitionLoad(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + return ENGINE(engineState.ignitionLoad); +} + /** * @brief Returns engine load according to selected engine_load_mode * diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index 79334e1929..5ec14659db 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -42,6 +42,9 @@ void setFlatInjectorLag(float value DECLARE_CONFIG_PARAMETER_SUFFIX); floatms_t getCrankshaftRevolutionTimeMs(int rpm); floatms_t getEngineCycleDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX); +float getFuelingLoad(DECLARE_ENGINE_PARAMETER_SIGNATURE); +float getIgnitionLoad(DECLARE_ENGINE_PARAMETER_SIGNATURE); +// getEngineLoadT is deprecated - please use one of the above functions, getFuelingLoad or getIgnitionMode float getEngineLoadT(DECLARE_ENGINE_PARAMETER_SIGNATURE); floatms_t getSparkDwell(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index eb36b57316..bf042489a0 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1491,6 +1491,7 @@ end_struct #define GAUGE_NAME_FUEL_PID_CORR "fuel: Short-term fuel trim" #define GAUGE_NAME_FUEL_WALL_AMOUNT "fuel: wall amount" #define GAUGE_NAME_FUEL_WALL_CORRECTION "fuel: wall corr ms" +#define GAUGE_NAME_FUEL_LOAD "fuel: load" #define GAUGE_NAME_FUEL_INJ_DUTY "fuel: injector duty cycle" #define GAUGE_NAME_TCHARGE "fuel: SD tCharge" @@ -1498,6 +1499,10 @@ end_struct #define GAUGE_NAME_AFR "Air/Fuel Ratio" #define GAUGE_NAME_IAC "Idle Air Valve" +#define GAUGE_NAME_DWELL_DUTY "dwell: coil duty cycle" +#define GAUGE_COIL_DWELL_TIME "dwell: coil charge time" +#define GAUGE_NAME_IGNITION_LOAD "ign: load" + #define GAUGE_NAME_DEBUG_F1 "debug f1" #define GAUGE_NAME_DEBUG_F2 "debug f2: iTerm" #define GAUGE_NAME_DEBUG_F3 "debug f3: prevError" @@ -1642,10 +1647,6 @@ end_struct #define ET_BMW_M73_PROTEUS 63 #define ET_CITROEN_TU3JP 65 -#define GAUGE_NAME_DWELL_DUTY "dwell: coil duty cycle" - -#define GAUGE_COIL_DWELL_TIME "dwell: coil charge time" - ! some board files override this value using prepend file #define ts_show_hip9011 true #define ts_show_main_relay true diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 4d2d5916b3..a78ecc471d 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -984,6 +984,7 @@ gaugeCategory = Ignition ignadvGauge = ignitionAdvance, "Ignition timing", "degrees", -100, 100, -999, -999, 999, 999, 1, 1 dwellGauge = sparkDwellValue, "Dwell", "mSec", 0, 10, 0.5, 1.0, 6.0, 8.0, 1, 1 coilDutyCycleGauge = coilDutyCycle, @@GAUGE_NAME_DWELL_DUTY@@, "perc", -11, 11, 1.0, 1.2, 100, 100, 3, 1 + ignitionLoadGauge = ignitionLoad, @@GAUGE_NAME_IGNITION_LOAD@@, "%", 0, 300, 0, 0, 300, 300, 1, 1 gaugeCategory = Acceleration Enrichment engineLoadDeltaGauge = engineLoadDelta,"AE: load change","value", 0, 120, 10, 10, 100, 100, 1, 1 @@ -1008,6 +1009,7 @@ gaugeCategory = Fueling fuelRunningGauge = fuelRunning, @@GAUGE_NAME_FUEL_RUNNING@@, "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 baseFuelGauge = baseFuel, @@GAUGE_NAME_FUEL_BASE@@, "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 fuelPidCorrectionGauge = fuelPidCorrection, @@GAUGE_NAME_FUEL_PID_CORR@@, "%", -10, 10, -8, -5, 5, 8, 3, 1 + fuelingLoadGauge = fuelingLoad, @@GAUGE_NAME_FUEL_LOAD@@, "%", 0, 300, 0, 0, 300, 300, 1, 1 gaugeCategory = Throttle Body (incl. ETB) pedalPositionGauge = throttlePedalPosition, @@GAUGE_NAME_THROTTLE_PEDAL@@, "%", 0, 120, 0, 0, 100, 100, 1, 1 @@ -1257,14 +1259,14 @@ menuDialog = main subMenu = std_separator # Targets & closed loop - subMenu = afrTableTbl, "Target AFR", 0, {isInjectionEnabled == 1 && (fuelAlgorithm == LM_SPEED_DENSITY || fuelAlgorithm == LM_REAL_MAF)} + subMenu = afrTableTbl, "Target AFR", 0, {isInjectionEnabled == 1} subMenu = fuelClosedLoopDialog, "Closed loop fuel correction", 0, {isInjectionEnabled == 1} subMenu = coastingFuelCutControl, "Deceleration fuel cutoff (DFCO)", 0, {isInjectionEnabled == 1} subMenu = std_separator # Fuel table/VE subMenu = fuelTableDialog, "Fuel table", 0, {isInjectionEnabled == 1 && fuelAlgorithm != LM_SPEED_DENSITY && fuelAlgorithm != LM_REAL_MAF} - subMenu = veTableDialog, "VE", 0, {isInjectionEnabled == 1 && (fuelAlgorithm == LM_SPEED_DENSITY || fuelAlgorithm == LM_REAL_MAF)} + subMenu = veTableDialog, "VE", 0, {isInjectionEnabled == 1} subMenu = injPhaseTableTbl, "Injection phase", 0, {isInjectionEnabled == 1} subMenu = std_separator