From c1315a4ecc99478eb629ba1c72d4c119066f34f6 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Tue, 3 Oct 2023 18:29:17 -0700 Subject: [PATCH] Fix autotune in AFR mode: add "gas scale AFR" output channels & gauges --- firmware/console/binary/output_channels.txt | 5 ++++- firmware/console/status_loop.cpp | 2 ++ firmware/integration/rusefi_config_shared.txt | 2 ++ firmware/tunerstudio/rusefi.input | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/firmware/console/binary/output_channels.txt b/firmware/console/binary/output_channels.txt index 9ce5af293c..3361338ee6 100644 --- a/firmware/console/binary/output_channels.txt +++ b/firmware/console/binary/output_channels.txt @@ -374,5 +374,8 @@ float mapFast uint16_t engineRunTime;;"sec",1,0,0,0,1 uint16_t autoscale distanceTraveled;;"km",0.1,0,0,0,1 - uint8_t[124 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 + uint16_t autoscale afrGasolineScale;@@GAUGE_NAME_AFR_GAS_SCALE@@;"AFR",{1/@@PACK_MULT_AFR@@}, 0, 0, 0, 2 + uint16_t autoscale afr2GasolineScale;@@GAUGE_NAME_AFR2_GAS_SCALE@@;"AFR",{1/@@PACK_MULT_AFR@@}, 0, 0, 0, 2 + + uint8_t[120 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 end_struct diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 795c74c522..28f7ed7341 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -433,10 +433,12 @@ static void updateLambda() { float lambdaValue = Sensor::getOrZero(SensorType::Lambda1); engine->outputChannels.lambdaValue = lambdaValue; engine->outputChannels.AFRValue = lambdaValue * engine->fuelComputer.stoichiometricRatio; + engine->outputChannels.afrGasolineScale = lambdaValue * STOICH_RATIO; float lambda2Value = Sensor::getOrZero(SensorType::Lambda2); engine->outputChannels.lambdaValue2 = lambda2Value; engine->outputChannels.AFRValue2 = lambda2Value * engine->fuelComputer.stoichiometricRatio; + engine->outputChannels.afr2GasolineScale = lambda2Value * STOICH_RATIO; } static void updateFuelSensors() { diff --git a/firmware/integration/rusefi_config_shared.txt b/firmware/integration/rusefi_config_shared.txt index 9efbcdfe23..18ce64e9d2 100644 --- a/firmware/integration/rusefi_config_shared.txt +++ b/firmware/integration/rusefi_config_shared.txt @@ -170,6 +170,8 @@ #define GAUGE_NAME_FUEL_INJECTION_TIMING "Fuel: Injection timing SOI" #define GAUGE_NAME_AFR "Air/Fuel Ratio" #define GAUGE_NAME_AFR2 "Air/Fuel Ratio 2" +#define GAUGE_NAME_AFR_GAS_SCALE "Air/Fuel Ratio (Gas Scale)" +#define GAUGE_NAME_AFR2_GAS_SCALE "Air/Fuel Ratio 2 (Gas Scale)" #define GAUGE_NAME_LAMBDA "Lambda" #define GAUGE_NAME_LAMBDA2 "Lambda 2" #define GAUGE_NAME_IAC "Idle: Position" diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 22ef0eab48..bcb23720e6 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -158,7 +158,7 @@ enable2ndByteCanID = false veAnalyzeMap = veTableTbl, lambdaTableTbl, lambdaValue, egoCorrectionForVeAnalyze, { 1 } lambdaTargetTables = lambdaTableTbl, afrTSCustom #else - veAnalyzeMap = veTableTbl, afrTableTbl, AFRValue, egoCorrectionForVeAnalyze, { 1 } + veAnalyzeMap = veTableTbl, afrTableTbl, afrGasolineScale, egoCorrectionForVeAnalyze, { 1 } lambdaTargetTables = afrTableTbl, afrTSCustom #endif @@ -1414,6 +1414,8 @@ gaugeCategory = Sensors - Basic IATGauge = intake, "Intake air temp", "C", -40, 140, -15, 1, 95, 110, 1, 1 afr1Gauge = AFRValue, @@GAUGE_NAME_AFR@@, "", 10, 19.4, 12, 13, 15, 16, 2, 2 afr2Gauge = AFRValue2, @@GAUGE_NAME_AFR2@@, "", 10, 19.4, 12, 13, 15, 16, 2, 2 + afrGasScale1Gauge = AFRValue, @@GAUGE_NAME_AFR_GAS_SCALE@@, "", 10, 19.4, 12, 13, 15, 16, 2, 2 + afrGasScale2Gauge = AFRValue2, @@GAUGE_NAME_AFR2_GAS_SCALE@@, "", 10, 19.4, 12, 13, 15, 16, 2, 2 lambda1Gauge = lambdaValue, @@GAUGE_NAME_LAMBDA@@, "", 0.65, 1.2, 0.7, 0.75, 1.1, 1.15, 3, 2 lambda2Gauge = lambdaValue2, @@GAUGE_NAME_LAMBDA2@@, "", 0.65, 1.2, 0.7, 0.75, 1.1, 1.15, 3, 2 VBattGauge = VBatt, "Battery", "V", 8, 21, 9, 10, 17, 19, 1, 1