From eb2882857f64dd5cc9e8bb9d1ba69c6e12aee7a5 Mon Sep 17 00:00:00 2001 From: andreika-git Date: Thu, 5 Nov 2020 22:35:11 +0200 Subject: [PATCH] Make AFR great again! (#1929) Co-authored-by: Andrei --- firmware/integration/rusefi_config.txt | 6 ++++ firmware/tunerstudio/rusefi.input | 40 +++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index b64575d2a1..f3de0c8d3a 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -208,6 +208,7 @@ struct_no_prefix engine_configuration_s custom fuel_table_t 4*@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, F32, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"ms", 1, 0, 0.0, 500.0, 2 custom ve_table_t 4*@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, F32, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"%", 1, 0, 0, 999.0, 2 custom lambda_table_t @@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, U08, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"deg", {1/@@PACK_MULT_LAMBDA_CFG@@}, 0, 0.6, 1.5, 2 +custom afr_table_t @@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, U08, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"deg", {1/@@PACK_MULT_AFR_CFG@@}, 0, 0, 25.0, 1 custom tcubinary_table_t @@TCU_GEAR_COUNT@@x@@TCU_SOLENOID_COUNT@@ array, U08, @OFFSET@, [@@TCU_GEAR_COUNT@@x@@TCU_SOLENOID_COUNT@@],"onoff", 1, 0, 0, 1, 0 @@ -1490,7 +1491,12 @@ ve_table_t veTable; float[FUEL_LOAD_COUNT] veLoadBins;;"kPa", 1, 0.0, 0, 400.0, 2 float[FUEL_RPM_COUNT] veRpmBins;;"RPM", 1, 0.0, 0, 18000.0, 2 +#if LAMBDA lambda_table_t lambdaTable; +#else +afr_table_t lambdaTable; +#endif + float[FUEL_LOAD_COUNT] lambdaLoadBins;;"", 1, 0.0, 0, 500.0, 2 float[FUEL_RPM_COUNT] lambdaRpmBins;;"RPM", 1, 0.0, 0, 18000.0, 2 diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 8ffdd1a8c9..defe7b438a 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -90,7 +90,11 @@ enable2ndByteCanID = false pageButtons = "&EGO" gauge1 = RPMGauge +#if LAMBDA gauge2 = lambda1Gauge +#else + gauge2 = afr1Gauge +#endif gauge3 = MAPGauge gauge4 = veValueGauge @@ -135,8 +139,13 @@ enable2ndByteCanID = false [VeAnalyze] ; tableName, lambdaTargetTableName, lambdaChannel, egoCorrectionChannel, activeCondition +#if LAMBDA veAnalyzeMap = veTableTbl, lambdaTableTbl, lambdaValue, egoCorrection, { 1 } lambdaTargetTables = lambdaTableTbl, afrTSCustom +#else + veAnalyzeMap = veTableTbl, afrTableTbl, AFRValue, egoCorrection, { 1 } + lambdaTargetTables = afrTableTbl, afrTSCustom +#endif ; filter = Name, "DisplayName", outputChannel, operator, defaultVal, userAdjustable filter = minRPMFilter, "Minimum RPM", RPMValue, < , 500, , true @@ -531,7 +540,11 @@ enable2ndByteCanID = false yAxis = 0, 28, 10 xBins = narrowToWideOxygenBins yBins = narrowToWideOxygen +#if LAMBDA gauge = lambda1Gauge +#else + gauge = afr1Gauge +#endif curve = fsioCurve1, "FSIO Curve #1" columnLabel = "X", "Y" @@ -709,7 +722,11 @@ enable2ndByteCanID = false yAxis = 0, 250, 10 xBins = idleVeBins, RPMValue yBins = idleVe +#if LAMBDA gauge = lambda1Gauge +#else + gauge = afr1Gauge +#endif curve = crankingAdvanceCurve, "Cranking Advance Angle" columnLabel = "RPM", "degrees" @@ -838,7 +855,11 @@ enable2ndByteCanID = false upDownLabel = "(Later)", "(Sooner)" +#if LAMBDA table = lambdaTableTbl, lambdaTableMap, "Target Lambda Table", 1 +#else + table = afrTableTbl, afrTableMap, "Target AFR Table", 1 +#endif ; constant, variable xBins = lambdaRpmBins, RPMValue yBins = lambdaLoadBins, afrTableYAxis @@ -1032,9 +1053,13 @@ gaugeCategory = Knock [WueAnalyze] ; wueCurveName, afrTempCompensationCurve, lambdaTargetTableName, lambdaChannel, coolantTempChannel, egoCorrectionChannel, wueChannel, activeCondition +#if LAMBDA wueAnalyzeMap = wueAnalyzer_warmup_curve, wueAfrTargetOffsetCurve, lambdaTableTbl, lambdaValue, coolant, cltCorrection, egoCorrection - lambdaTargetTables = lambdaTableTbl, afrTSCustom +#else + wueAnalyzeMap = wueAnalyzer_warmup_curve, wueAfrTargetOffsetCurve, afrTableTbl, AFRValue, coolant, cltCorrection, egoCorrection + lambdaTargetTables = afrTableTbl, afrTSCustom +#endif wuePercentOffset = 0 ; for working with 0 based enrichment set to 100 option = disableLiveUpdates @@ -1065,7 +1090,11 @@ gaugeCategory = Knock gauge2 = CLTGauge gauge3 = TPSGauge gauge4 = MAPGauge +#if LAMBDA gauge5 = lambda1Gauge +#else + gauge5 = afr1Gauge +#endif gauge6 = VBattGauge gauge7 = dwellGauge gauge8 = ignadvGauge @@ -1292,7 +1321,11 @@ menuDialog = main subMenu = std_separator # Fuel model +#if LAMBDA subMenu = lambdaTableTbl, "Target lambda", 0, {isInjectionEnabled == 1} +#else + subMenu = afrTableTbl, "Target AFR", 0, {isInjectionEnabled == 1} +#endif subMenu = cltFuelCorrCurve, "CLT multiplier", 0, {isInjectionEnabled == 1} subMenu = iatFuelCorrCurve, "IAT multiplier", 0, {isInjectionEnabled == 1} subMenu = fuelClosedLoopDialog, "Closed loop fuel correction", 0, {isInjectionEnabled == 1} @@ -3361,3 +3394,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" [Tools] ;addTool = toolName, PanelName addTool = veTableGenerator, "VE Table Generator", veTableTbl +#if LAMBDA +#else + addTool = afrTableGenerator, "AFR Table Generator", afrTableTbl +#endif +