From 6ac9aad358e006dffe58d81ab4500e5248b23449 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 30 Sep 2020 17:19:51 -0700 Subject: [PATCH] display base fuel mass in milligrams (#1838) * switch to mg * use the correct thing * gauge scaling Co-authored-by: Matthew Kennedy --- firmware/console/binary/tunerstudio_outputs.h | 4 ++-- firmware/console/status_loop.cpp | 2 +- firmware/controllers/algo/fuel_math.cpp | 2 +- firmware/integration/rusefi_config.txt | 3 ++- firmware/tunerstudio/rusefi.input | 4 ++-- firmware/util/scaled_channel.h | 1 + 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/firmware/console/binary/tunerstudio_outputs.h b/firmware/console/binary/tunerstudio_outputs.h index 3ebafc4c92..961d1084b0 100644 --- a/firmware/console/binary/tunerstudio_outputs.h +++ b/firmware/console/binary/tunerstudio_outputs.h @@ -112,11 +112,11 @@ typedef struct { scaled_angle vvtPosition; // 42 // Fuel math - scaled_channel chargeAirMass; // 44 + scaled_channel chargeAirMass; // 44 cylinder airmass in mg, 0-65 grams scaled_ms crankingFuelMs; // 46 scaled_afr currentTargetAfr; // 48 // This is the raw value we take from the fuel map or base fuel algorithm, before the corrections - scaled_ms fuelBase; // 50 + scaled_fuel_mass_mg fuelBase; // 50 // Total fuel with CLT, IAT and TPS acceleration without injector lag corrections per cycle, as pulse per cycle scaled_ms fuelRunning; // 52 // Actual last injection time - including all compensation and injection mode diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 6ad8be4e8b..b643fd9c62 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -547,7 +547,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->baroPressure = hasBaroSensor() ? getBaroPressure() : 0; #endif /* EFI_ANALOG_SENSORS */ // 48 - tsOutputChannels->fuelBase = engine->engineState.baseFuel; + tsOutputChannels->fuelBase = engine->engineState.baseFuel * 1000; // Convert grams to mg // 64 tsOutputChannels->actualLastInjection = ENGINE(actualLastInjection); diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index c723dda606..1acc1c44d7 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -226,7 +226,7 @@ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { } efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN baseFuel", 0); - engine->engineState.baseFuel = baseFuel; + engine->engineState.baseFuel = baseFuelMass; return tpsAccelEnrich + baseFuel; } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 48262ffc75..b8441461de 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -179,6 +179,7 @@ struct_no_prefix engine_configuration_s #define TPS_1_BYTE_PACKING_MULT 2 #define LOAD_1_BYTE_PACKING_MULT 2 #define PACK_MULT_AFR_CFG 10 +#define PACK_MULT_FUEL_MASS 100 #define FSIO_TABLE_8 8 #define FSIO_CURVE_8 8 @@ -1587,7 +1588,7 @@ end_struct #define GAUGE_NAME_FUEL_CRANKING "fuel: cranking" #define GAUGE_NAME_FUEL_RUNNING "fuel: running" #define GAUGE_NAME_FUEL_LAST_INJECTION "fuel: Last injection" -#define GAUGE_NAME_FUEL_BASE "fuel: base" +#define GAUGE_NAME_FUEL_BASE "fuel: base mass" #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" diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index e00447862e..7b18ce5655 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -227,7 +227,7 @@ enable2ndByteCanID = false chargeAirMass = scalar, U16, 44, "g",0.001, 0 crankingFuelMs = scalar, U16, 46, "ms",{1/@@PACK_MULT_MS@@}, 0.0 currentTargetAfr= scalar, U16, 48, "ratio",,{1/@@PACK_MULT_AFR@@},, 0 - baseFuel = scalar, U16, 50, "ms",{1/@@PACK_MULT_MS@@}, 0 + baseFuel = scalar, U16, 50, "mg",{1/@@PACK_MULT_FUEL_MASS@@}, 0 fuelRunning = scalar, U16, 52, "ms",{1/@@PACK_MULT_MS@@}, 0 actualLastInjection=scalar,U16, 54, "ms",{1/@@PACK_MULT_MS@@}, 0.0 injectorDutyCycle=scalar, U08, 56, "%", 0.5, 0 @@ -978,7 +978,7 @@ gaugeCategory = Fueling injectorLagMsGauge = injectorLagMs, @@GAUGE_NAME_INJECTOR_LAG@@, "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1 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 + baseFuelGauge = baseFuel, @@GAUGE_NAME_FUEL_BASE@@, "mSec", 0, 100, 0, 0, 100, 100, 2, 0 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 diff --git a/firmware/util/scaled_channel.h b/firmware/util/scaled_channel.h index d01f354d52..b3f130afa3 100644 --- a/firmware/util/scaled_channel.h +++ b/firmware/util/scaled_channel.h @@ -54,3 +54,4 @@ using scaled_pressure = scaled_channel; // 0-2000 using scaled_angle = scaled_channel; // +-655 degrees at 0.02 degree resolution using scaled_voltage = scaled_channel; // 0-65v at 1mV resolution using scaled_afr = scaled_channel; // 0-65afr at 0.001 resolution +using scaled_fuel_mass_mg = scaled_channel; // 0 - 655.35 milligrams, 0.01mg resolution