From 57390322549b9de646b08cca545250d7ee100f23 Mon Sep 17 00:00:00 2001 From: OrchardPerformance <49926376+OrchardPerformance@users.noreply.github.com> Date: Tue, 14 Apr 2020 06:21:48 +0100 Subject: [PATCH] Update to Matt's MAF code for VE table tuning. (#1295) * Update rusefi_lib * Update fuel_math.cpp Updated Matt's MAF code to include fuel table * fixed missing include * Replace get_specs_displacement * ve2Map corrected * ve2Map fix 2 * Fix for missing TS table * Corrected standard air charge * Math fix, PW now good Still have minimal response from the VE table * rusefi.input correction * Added extra comment * Ease of reading update --- firmware/controllers/algo/fuel_math.cpp | 14 +++++++++++--- firmware/tunerstudio/rusefi.input | 6 +++--- hardware/rusefi_lib | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 256c906752..a8bffc1d73 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -36,7 +36,7 @@ EXTERN_ENGINE; fuel_Map3D_t fuelMap("fuel"); static fuel_Map3D_t fuelPhaseMap("fl ph"); -extern fuel_Map3D_t ve2Map; +extern fuel_Map3D_t veMap; extern afr_Map3D_t afrMap; extern baroCorr_Map3D_t baroCorrMap; @@ -142,6 +142,7 @@ floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) { /* DISPLAY_ENDIF */ /** + * Function block now works to create a standardised load from the cylinder filling as well as tune fuel via VE table. * @return total duration of fuel injection per engine cycle, in milliseconds */ float getRealMafFuel(float airSpeed, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { @@ -155,7 +156,6 @@ float getRealMafFuel(float airSpeed, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { // 1/min -> 1/s float revsPerSecond = rpm / 60.0f; - float airPerRevolution = gramPerSecond / revsPerSecond; // Now we have to divide among cylinders - on a 4 stroke, half of the cylinders happen every rev @@ -163,7 +163,15 @@ float getRealMafFuel(float airSpeed, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { float halfCylCount = CONFIG(specs.cylindersCount) / 2.0f; float cylinderAirmass = airPerRevolution / halfCylCount; - float fuelMassGram = cylinderAirmass / afrMap.getValue(rpm, airSpeed); + + //Calculation of 100% VE air mass in g/rev - 1 cylinder filling at 1.2929g/L + float StandardAirCharge = CONFIG(specs.displacement) / CONFIG(specs.cylindersCount) * 1.2929; + //Create % load for fuel table using relative naturally aspiratedcylinder filling + float airChargeLoad = 100 * cylinderAirmass/StandardAirCharge; + + //Correct air mass by VE table + float corrCylAirmass = cylinderAirmass * veMap.getValue(rpm, airChargeLoad) / 100; + float fuelMassGram = corrCylAirmass / afrMap.getValue(rpm, airSpeed); float pulseWidthSeconds = fuelMassGram / cc_minute_to_gramm_second(engineConfiguration->injector.flow); // Convert to ms diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 9dae030fb6..15bc0642ef 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1208,14 +1208,14 @@ menuDialog = main subMenu = std_separator # Targets & closed loop - subMenu = afrTableTbl, "Target AFR", 0, {isInjectionEnabled == 1 && fuelAlgorithm == LM_SPEED_DENSITY} + subMenu = afrTableTbl, "Target AFR", 0, {isInjectionEnabled == 1 && (fuelAlgorithm == LM_SPEED_DENSITY || fuelAlgorithm == LM_REAL_MAF)} subMenu = fuelClosedLoopDialog, "Closed loop 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} - subMenu = veTableDialog, "VE", 0, {isInjectionEnabled == 1 && fuelAlgorithm == LM_SPEED_DENSITY} + 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 = injPhaseTableTbl, "Injection phase", 0, {isInjectionEnabled == 1} subMenu = std_separator diff --git a/hardware/rusefi_lib b/hardware/rusefi_lib index 37b2bec061..08677673d2 160000 --- a/hardware/rusefi_lib +++ b/hardware/rusefi_lib @@ -1 +1 @@ -Subproject commit 37b2bec0612122614058137efb6fbe5b6b2502df +Subproject commit 08677673d2e6c05e8650555fd87ec30876acf831