diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index 99195ed230..6d552c6c17 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -151,7 +151,7 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setLinearCurve(config->ignitionLoadBins, 20, 105, 5); setWholeTimingTable_d(10 PASS_CONFIG_PARAMETER_SUFFIX); - setAfrMap(config->afrTable, 13.5); + setLambdaMap(config->lambdaTable, 0.92); setSingleCoilDwell(PASS_CONFIG_PARAMETER_SIGNATURE); engineConfiguration->ignitionMode = IM_ONE_COIL; diff --git a/firmware/config/engines/mazda_miata_custom_hunchback.cpp b/firmware/config/engines/mazda_miata_custom_hunchback.cpp index ac25df334e..86d71cedbd 100644 --- a/firmware/config/engines/mazda_miata_custom_hunchback.cpp +++ b/firmware/config/engines/mazda_miata_custom_hunchback.cpp @@ -72,37 +72,17 @@ static const fuel_table_t mapBased18vvtVeTable_NA_fuel_rail = { }; #endif -static const float mazda_miata_nb2_targetAfrRpmBins[FUEL_RPM_COUNT] = {650.0, 800.0, 1050.0, 1300.0, +static const float mazda_miata_nb2_targetLambdaRpmBins[FUEL_RPM_COUNT] = {650.0, 800.0, 1050.0, 1300.0, 1550.0, 1800.0, 2050.0, 2300.0, 2550.0, 2800.0, 3050.0, 3300.0, 3550.0, 3800.0, 4050.0, 6400.0} ; -static const float mazda_miata_nb2_targetAfrLoadBins[FUEL_LOAD_COUNT] = {10.0, 20.0, 30.0, 40.0, +static const float mazda_miata_nb2_targetLambdaLoadBins[FUEL_LOAD_COUNT] = {10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0, 120.0, 130.0, 140.0, 150.0, 160.0}; -static const fuel_table_t target_AFR_hunchback = { - /* Generated by TS2C on Sun May 07 09:48:38 EDT 2017*/ - {/* 0 10.000 *//* 0 650.0*/14.000, /* 1 800.0*/14.000, /* 2 1050.0*/14.000, /* 3 1300.0*/14.000, /* 4 1550.0*/14.000, /* 5 1800.0*/14.000, /* 6 2050.0*/14.000, /* 7 2300.0*/14.000, /* 8 2550.0*/14.000, /* 9 2800.0*/14.000, /* 10 3050.0*/14.000, /* 11 3300.0*/14.000, /* 12 3550.0*/14.000, /* 13 3800.0*/14.000, /* 14 4050.0*/14.000, /* 15 6400.0*/14.000, }, - {/* 1 20.000 *//* 0 650.0*/14.000, /* 1 800.0*/14.000, /* 2 1050.0*/14.000, /* 3 1300.0*/14.000, /* 4 1550.0*/14.000, /* 5 1800.0*/14.000, /* 6 2050.0*/14.000, /* 7 2300.0*/14.000, /* 8 2550.0*/14.000, /* 9 2800.0*/14.000, /* 10 3050.0*/14.000, /* 11 3300.0*/14.000, /* 12 3550.0*/14.000, /* 13 3800.0*/14.000, /* 14 4050.0*/14.000, /* 15 6400.0*/14.000, }, - {/* 2 30.000 *//* 0 650.0*/14.000, /* 1 800.0*/14.000, /* 2 1050.0*/14.000, /* 3 1300.0*/14.000, /* 4 1550.0*/14.000, /* 5 1800.0*/14.000, /* 6 2050.0*/14.000, /* 7 2300.0*/14.000, /* 8 2550.0*/14.000, /* 9 2800.0*/14.000, /* 10 3050.0*/14.000, /* 11 3300.0*/14.000, /* 12 3550.0*/14.000, /* 13 3800.0*/14.000, /* 14 4050.0*/14.000, /* 15 6400.0*/14.000, }, - {/* 3 40.000 *//* 0 650.0*/14.000, /* 1 800.0*/14.000, /* 2 1050.0*/14.000, /* 3 1300.0*/14.000, /* 4 1550.0*/14.000, /* 5 1800.0*/14.000, /* 6 2050.0*/14.000, /* 7 2300.0*/14.000, /* 8 2550.0*/14.000, /* 9 2800.0*/14.000, /* 10 3050.0*/14.000, /* 11 3300.0*/14.000, /* 12 3550.0*/14.000, /* 13 3800.0*/14.000, /* 14 4050.0*/14.000, /* 15 6400.0*/14.000, }, - {/* 4 50.000 *//* 0 650.0*/14.000, /* 1 800.0*/14.000, /* 2 1050.0*/14.000, /* 3 1300.0*/14.000, /* 4 1550.0*/14.000, /* 5 1800.0*/14.000, /* 6 2050.0*/14.000, /* 7 2300.0*/14.000, /* 8 2550.0*/14.000, /* 9 2800.0*/14.000, /* 10 3050.0*/14.000, /* 11 3300.0*/14.000, /* 12 3550.0*/14.000, /* 13 3800.0*/14.000, /* 14 4050.0*/14.000, /* 15 6400.0*/14.000, }, - {/* 5 60.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 6 70.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 7 80.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 8 90.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 9 100.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 10 110.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 11 120.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 12 130.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 13 140.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 14 150.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, - {/* 15 160.000 *//* 0 650.0*/11.700, /* 1 800.0*/11.700, /* 2 1050.0*/11.700, /* 3 1300.0*/11.700, /* 4 1550.0*/11.700, /* 5 1800.0*/11.700, /* 6 2050.0*/11.700, /* 7 2300.0*/11.700, /* 8 2550.0*/11.700, /* 9 2800.0*/11.700, /* 10 3050.0*/11.700, /* 11 3300.0*/11.700, /* 12 3550.0*/11.700, /* 13 3800.0*/11.700, /* 14 4050.0*/11.000, /* 15 6400.0*/11.000, }, -}; - void setMazdaMiata2003EngineConfigurationNaFuelRail(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setMazdaMiata2003EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE); @@ -118,9 +98,8 @@ void setMazdaMiata2003EngineConfigurationNaFuelRail(DECLARE_CONFIG_PARAMETER_SIG engineConfiguration->vvtOffset = 83; // 2002 green car value - MEMCPY(config->afrRpmBins, mazda_miata_nb2_targetAfrRpmBins); - MEMCPY(config->afrLoadBins, mazda_miata_nb2_targetAfrLoadBins); - MEMCPY(config->afrTable, target_AFR_hunchback); + MEMCPY(config->lambdaRpmBins, mazda_miata_nb2_targetLambdaRpmBins); + MEMCPY(config->lambdaLoadBins, mazda_miata_nb2_targetLambdaLoadBins); engineConfiguration->ignitionPins[2] = GPIOC_7; diff --git a/firmware/config/engines/sachs.cpp b/firmware/config/engines/sachs.cpp index 4d6021c0af..4228379b9d 100644 --- a/firmware/config/engines/sachs.cpp +++ b/firmware/config/engines/sachs.cpp @@ -85,7 +85,7 @@ void setSachs(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // todo: extract a method? figure out something smarter setTimingRpmBin(800, 15000 PASS_CONFIG_PARAMETER_SUFFIX); setLinearCurve(config->veRpmBins, 15000, 7000, 1); - setLinearCurve(config->afrRpmBins, 15000, 7000, 1); + setLinearCurve(config->lambdaRpmBins, 15000, 7000, 1); engineConfiguration->hasFrequencyReportingMapSensor = true; engineConfiguration->frequencyReportingMapInputPin = GPIOC_6; diff --git a/firmware/config/engines/test_engine.cpp b/firmware/config/engines/test_engine.cpp index 3afebd2d80..6f2702cb83 100644 --- a/firmware/config/engines/test_engine.cpp +++ b/firmware/config/engines/test_engine.cpp @@ -37,6 +37,9 @@ void setTestEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setWholeIatCorrTimingTable(0 PASS_CONFIG_PARAMETER_SUFFIX); + // Many tests were written when the default target AFR was 14.0, so use that for tests by default. + engineConfiguration->stoichRatioPrimary = 140; + engineConfiguration->ignitionMode = IM_ONE_COIL; setConstantDwell(3 PASS_CONFIG_PARAMETER_SUFFIX); // 50% duty cycle @ 5000 rpm diff --git a/firmware/console/binary/tunerstudio_outputs.h b/firmware/console/binary/tunerstudio_outputs.h index 29f17a82ad..ad108709c8 100644 --- a/firmware/console/binary/tunerstudio_outputs.h +++ b/firmware/console/binary/tunerstudio_outputs.h @@ -103,7 +103,7 @@ typedef struct { scaled_pressure manifoldAirPressure; // 30 scaled_pressure baroPressure; // 32 - scaled_afr airFuelRatio; // 34 + scaled_lambda lambda; // 34 scaled_channel engineLoad; // 36 // misc sensors diff --git a/firmware/console/binary_log/binary_logging.cpp b/firmware/console/binary_log/binary_logging.cpp index 77c21eee2f..7c2035a14c 100644 --- a/firmware/console/binary_log/binary_logging.cpp +++ b/firmware/console/binary_log/binary_logging.cpp @@ -30,7 +30,7 @@ static const LogField fields[] = { {tsOutputChannels.throttle2Position, GAUGE_NAME_TPS2, "%", 2}, {tsOutputChannels.pedalPosition, GAUGE_NAME_THROTTLE_PEDAL, "%", 2}, {tsOutputChannels.manifoldAirPressure, GAUGE_NAME_MAP, "kPa", 1}, - {tsOutputChannels.airFuelRatio, GAUGE_NAME_AFR, "afr", 2}, + {tsOutputChannels.lambda, GAUGE_NAME_LAMBDA, "", 3}, {tsOutputChannels.vBatt, GAUGE_NAME_VBAT, "v", 2}, {tsOutputChannels.oilPressure, "Oil Press", "kPa", 0}, {tsOutputChannels.vvtPosition, GAUGE_NAME_VVT, "deg", 1}, diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index b00d4e335d..3867aa1468 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -526,7 +526,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE) : 0; // offset 20 - tsOutputChannels->airFuelRatio = Sensor::get(SensorType::Lambda).value_or(0) * 14.7f; + tsOutputChannels->lambda = Sensor::get(SensorType::Lambda).value_or(0); // offset 24 tsOutputChannels->engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index 50a23e2763..901c1009a0 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -27,9 +27,6 @@ #include "status_loop.h" #endif -extern fuel_Map3D_t veMap; -extern afr_Map3D_t afrMap; - EXTERN_ENGINE; // this does not look exactly right diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 817ded403d..3be7b0bb37 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -247,10 +247,10 @@ void setConstantDwell(floatms_t dwellMs DECLARE_CONFIG_PARAMETER_SUFFIX) { setLinearCurve(engineConfiguration->sparkDwellValues, dwellMs, dwellMs, 0.01); } -void setAfrMap(afr_table_t table, float value) { +void setLambdaMap(lambda_table_t table, float value) { for (int l = 0; l < FUEL_LOAD_COUNT; l++) { for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) { - table[l][rpmIndex] = (int)(value * PACK_MULT_AFR_CFG); + table[l][rpmIndex] = (int)(value * PACK_MULT_LAMBDA_CFG); } } } @@ -276,7 +276,7 @@ void setWholeIgnitionIatCorr(float value DECLARE_CONFIG_PARAMETER_SUFFIX) { void setFuelTablesLoadBin(float minValue, float maxValue DECLARE_CONFIG_PARAMETER_SUFFIX) { setLinearCurve(config->injPhaseLoadBins, minValue, maxValue, 1); setLinearCurve(config->veLoadBins, minValue, maxValue, 1); - setLinearCurve(config->afrLoadBins, minValue, maxValue, 1); + setLinearCurve(config->lambdaLoadBins, minValue, maxValue, 1); } void setTimingMap(ignition_table_t map, float value) { @@ -799,8 +799,8 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { setLinearCurve(engineConfiguration->map.samplingWindowBins, 800, 7000, 1); setLinearCurve(engineConfiguration->map.samplingWindow, 50, 50, 1); - setAfrMap(config->afrTable, 14.7); - engineConfiguration->stoichRatioPrimary = 14.7f / PACK_MULT_AFR_CFG; + setLambdaMap(config->lambdaTable, 1.0f); + engineConfiguration->stoichRatioPrimary = 14.7f * PACK_MULT_AFR_CFG; setDefaultVETable(PASS_ENGINE_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index c9bbb5a2ca..72426b4d5f 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -27,7 +27,7 @@ void setOperationMode(engine_configuration_s *engineConfiguration, operation_mod void prepareVoidConfiguration(engine_configuration_s *activeConfiguration); void setTargetRpmCurve(int rpm DECLARE_CONFIG_PARAMETER_SUFFIX); int getTargetRpmForIdleCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE); -void setAfrMap(afr_table_t table, float value); +void setLambdaMap(lambda_table_t table, float value); /** * See also setLinearCurve() */ diff --git a/firmware/controllers/algo/engine_state.h b/firmware/controllers/algo/engine_state.h index 8b8a31118c..9fbaf3e55a 100644 --- a/firmware/controllers/algo/engine_state.h +++ b/firmware/controllers/algo/engine_state.h @@ -79,4 +79,6 @@ public: #endif /* EFI_ENABLE_MOCK_ADC */ multispark_state multispark; + + float targetLambda = 0.0f; }; diff --git a/firmware/controllers/algo/fuel/fuel_computer.cpp b/firmware/controllers/algo/fuel/fuel_computer.cpp index 31d87bda24..4bda358d6f 100644 --- a/firmware/controllers/algo/fuel/fuel_computer.cpp +++ b/firmware/controllers/algo/fuel/fuel_computer.cpp @@ -11,12 +11,13 @@ mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) const float afr = stoich * lambda; ENGINE(engineState.currentAfrLoad) = load; + ENGINE(engineState.targetLambda) = lambda; ENGINE(engineState.targetAFR) = afr; return airmass / afr; } -FuelComputer::FuelComputer(const ValueProvider3D& afrTable) : m_afrTable(&afrTable) {} +FuelComputer::FuelComputer(const ValueProvider3D& lambdaTable) : m_lambdaTable(&lambdaTable) {} float FuelComputer::getStoichiometricRatio() const { // TODO: vary this with ethanol content/configured setting/whatever @@ -31,10 +32,9 @@ float FuelComputer::getStoichiometricRatio() const { } float FuelComputer::getTargetLambda(int rpm, float load) const { - efiAssert(OBD_PCM_Processor_Fault, m_afrTable != nullptr, "AFR table null", 0); + efiAssert(OBD_PCM_Processor_Fault, m_lambdaTable != nullptr, "AFR table null", 0); - // TODO: set the table value in lambda instead of afr - return m_afrTable->getValue(rpm, load) / 14.7f; + return m_lambdaTable->getValue(rpm, load); } float FuelComputer::getTargetLambdaLoadAxis(float defaultLoad) const { diff --git a/firmware/controllers/algo/fuel/fuel_computer.h b/firmware/controllers/algo/fuel/fuel_computer.h index 8027a6eb0f..f3893a3958 100644 --- a/firmware/controllers/algo/fuel/fuel_computer.h +++ b/firmware/controllers/algo/fuel/fuel_computer.h @@ -26,7 +26,7 @@ protected: // This class is a usable implemenation of a fuel model that reads real configuration class FuelComputer final : public FuelComputerBase { public: - FuelComputer(const ValueProvider3D& afrTable); + FuelComputer(const ValueProvider3D& lambdaTable); protected: float getStoichiometricRatio() const override; @@ -34,7 +34,7 @@ protected: float getTargetLambdaLoadAxis(float defaultLoad) const override; private: - const ValueProvider3D* const m_afrTable; + const ValueProvider3D* const m_lambdaTable; }; float getLoadOverride(float defaultLoad, afr_override_e overrideMode DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index a7f0e2c7dd..7e856eb5f9 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -43,7 +43,7 @@ EXTERN_ENGINE; fuel_Map3D_t fuelPhaseMap("fl ph"); extern fuel_Map3D_t veMap; -extern afr_Map3D_t afrMap; +extern lambda_Map3D_t lambdaMap; extern baroCorr_Map3D_t baroCorrMap; #if EFI_ENGINE_CONTROL @@ -331,7 +331,7 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { #endif } -static FuelComputer fuelComputer(afrMap); +static FuelComputer fuelComputer(lambdaMap); static InjectorModel injectorModel; /** diff --git a/firmware/controllers/algo/rusefi_types.h b/firmware/controllers/algo/rusefi_types.h index baa1621737..653206185c 100644 --- a/firmware/controllers/algo/rusefi_types.h +++ b/firmware/controllers/algo/rusefi_types.h @@ -90,7 +90,7 @@ typedef char le_formula_t[LE_COMMAND_LENGTH]; typedef brain_pin_e egt_cs_array_t[EGT_CHANNEL_COUNT]; -typedef uint8_t afr_table_t[FUEL_LOAD_COUNT][FUEL_RPM_COUNT]; +typedef uint8_t lambda_table_t[FUEL_LOAD_COUNT][FUEL_RPM_COUNT]; // todo: merge these two types together? but these tables have different TS parameters like ranges etc typedef float fuel_table_t[FUEL_LOAD_COUNT][FUEL_RPM_COUNT]; typedef float ignition_table_t[IGN_LOAD_COUNT][IGN_RPM_COUNT]; diff --git a/firmware/controllers/math/closed_loop_fuel_cell.cpp b/firmware/controllers/math/closed_loop_fuel_cell.cpp index 6ac9e40710..3892c3145d 100644 --- a/firmware/controllers/math/closed_loop_fuel_cell.cpp +++ b/firmware/controllers/math/closed_loop_fuel_cell.cpp @@ -56,7 +56,7 @@ float ClosedLoopFuelCellImpl::getLambdaError(DECLARE_ENGINE_PARAMETER_SIGNATURE) return 0; } - return lambda.Value - (ENGINE(engineState.targetAFR) / 14.7f); + return lambda.Value - ENGINE(engineState.targetLambda); } #define MAX_ADJ (0.25f) diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index 07227a0eb1..10659770c2 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -28,7 +28,7 @@ EXTERN_ENGINE; fuel_Map3D_t veMap("VE"); fuel_Map3D_t ve2Map("VE2"); -afr_Map3D_t afrMap("AFR"); +lambda_Map3D_t lambdaMap("lambda"); baroCorr_Map3D_t baroCorrMap("baro"); #define tpMin 0 @@ -120,8 +120,8 @@ void setDefaultVETable(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // setLinearCurve(engineConfiguration->ve2LoadBins, 10, 300, 1); // ve2Map.setAll(0.81); - setRpmTableBin(config->afrRpmBins, FUEL_RPM_COUNT); - afrMap.setAll(14.7); + setRpmTableBin(config->lambdaRpmBins, FUEL_RPM_COUNT); + lambdaMap.setAll(1.0); setRpmTableBin(engineConfiguration->baroCorrRpmBins, BARO_CORR_SIZE); setLinearCurve(engineConfiguration->baroCorrPressureBins, 75, 105, 1); @@ -136,6 +136,6 @@ void setDefaultVETable(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void initSpeedDensity(DECLARE_ENGINE_PARAMETER_SIGNATURE) { veMap.init(config->veTable, config->veLoadBins, config->veRpmBins); // ve2Map.init(engineConfiguration->ve2Table, engineConfiguration->ve2LoadBins, engineConfiguration->ve2RpmBins); - afrMap.init(config->afrTable, config->afrLoadBins, config->afrRpmBins); + lambdaMap.init(config->lambdaTable, config->lambdaLoadBins, config->lambdaRpmBins); baroCorrMap.init(engineConfiguration->baroCorrTable, engineConfiguration->baroCorrPressureBins, engineConfiguration->baroCorrRpmBins); } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 7895408284..c6808847ad 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -175,12 +175,14 @@ struct_no_prefix engine_configuration_s #define PACK_ADD_TEMPERATURE 40 #define PACK_MULT_MS 300 #define PACK_MULT_AFR 1000 +#define PACK_MULT_LAMBDA 10000 #define PACK_MULT_ANGLE 50 #define PACK_MULT_VOLTAGE 1000 #define PACK_MULT_MASS_FLOW 10 #define TPS_1_BYTE_PACKING_MULT 2 #define LOAD_1_BYTE_PACKING_MULT 2 #define PACK_MULT_AFR_CFG 10 +#define PACK_MULT_LAMBDA_CFG 147 #define PACK_MULT_FUEL_MASS 100 #define FSIO_TABLE_8 8 @@ -205,7 +207,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 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 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 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 @@ -1487,9 +1489,9 @@ 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 -afr_table_t afrTable; -float[FUEL_LOAD_COUNT] afrLoadBins;;"", 1, 0.0, 0, 500.0, 2 -float[FUEL_RPM_COUNT] afrRpmBins;;"RPM", 1, 0.0, 0, 18000.0, 2 +lambda_table_t lambdaTable; +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 ! ve_table_t ve2Table; ! float[FUEL_LOAD_COUNT] ve2LoadBins;;"kPa", 1, 0.0, 0, 500.0, 2 @@ -1612,7 +1614,7 @@ end_struct #define GAUGE_NAME_FUEL_INJ_DUTY "fuel: injector duty cycle" #define GAUGE_NAME_TCHARGE "fuel: SD tCharge" #define GAUGE_NAME_TARGET_AFR "fuel: target AFR" -#define GAUGE_NAME_AFR "Air/Fuel Ratio" +#define GAUGE_NAME_LAMBDA "Lambda" #define GAUGE_NAME_IAC "Idle Air Valve" #define GAUGE_NAME_DWELL_DUTY "dwell: coil duty cycle" diff --git a/firmware/integration/rusefi_template.xml b/firmware/integration/rusefi_template.xml index 1b6b1ea094..92b84255ba 100644 --- a/firmware/integration/rusefi_template.xml +++ b/firmware/integration/rusefi_template.xml @@ -134,15 +134,15 @@ - -
+
- +
diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index cff9a0af93..6a0c848691 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -90,7 +90,7 @@ enable2ndByteCanID = false pageButtons = "&EGO" gauge1 = RPMGauge - gauge2 = afr1Gauge + gauge2 = lambda1Gauge gauge3 = MAPGauge gauge4 = veValueGauge @@ -135,8 +135,8 @@ enable2ndByteCanID = false [VeAnalyze] ; tableName, lambdaTargetTableName, lambdaChannel, egoCorrectionChannel, activeCondition - veAnalyzeMap = veTableTbl, afrTableTbl, AFRValue, egoCorrection, { 1 } - lambdaTargetTables = afrTableTbl, afrTSCustom + veAnalyzeMap = veTableTbl, lambdaTableTbl, lambdaValue, egoCorrection, { 1 } + lambdaTargetTables = lambdaTableTbl, afrTSCustom ; filter = Name, "DisplayName", outputChannel, operator, defaultVal, userAdjustable filter = minRPMFilter, "Minimum RPM", RPMValue, < , 500, , true @@ -214,7 +214,7 @@ enable2ndByteCanID = false massAirFlowValue= scalar, U16, 28, "Kg/h", {1/@@PACK_MULT_MASS_FLOW@@}, 0 MAPValue = scalar, U16, 30, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0 baroPressure = scalar, U16, 32, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0 - AFRValue = scalar, U16, 34, "AFR",,{1/@@PACK_MULT_AFR@@},, 0.0 + lambdaValue = scalar, U16, 34, "",,{1/@@PACK_MULT_LAMBDA@@},, 0.0 engineLoad = scalar, U16, 36, "%",{1/@@PACK_MULT_PERCENT@@}, 0.0 ; Blend of MAP and TPS, depends on algorithm ; misc sensors @@ -529,7 +529,7 @@ enable2ndByteCanID = false yAxis = 0, 28, 10 xBins = narrowToWideOxygenBins yBins = narrowToWideOxygen - gauge = afr1Gauge + gauge = lambda1Gauge curve = fsioCurve1, "FSIO Curve #1" columnLabel = "X", "Y" @@ -707,7 +707,7 @@ enable2ndByteCanID = false yAxis = 0, 250, 10 xBins = idleVeBins, RPMValue yBins = idleVe - gauge = afr1Gauge + gauge = lambda1Gauge curve = crankingAdvanceCurve, "Cranking Advance Angle" columnLabel = "RPM", "degrees" @@ -836,11 +836,11 @@ enable2ndByteCanID = false upDownLabel = "(Later)", "(Sooner)" - table = afrTableTbl, afrTableMap, "Target AFR Table", 1 + table = lambdaTableTbl, lambdaTableMap, "Target Lambda Table", 1 ; constant, variable - xBins = afrRpmBins, RPMValue - yBins = afrLoadBins, afrTableYAxis - zBins = afrTable + xBins = lambdaRpmBins, RPMValue + yBins = lambdaLoadBins, afrTableYAxis + zBins = lambdaTable ; gridHeight = 2.0 gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees. upDownLabel = "(RICHER)", "(LEANER)" @@ -938,7 +938,7 @@ gaugeCategory = Sensors - Basic RPMGauge = RPMValue, "RPM - engine speed", "RPM", 0, 15000, 200, 500, 6000, 6000, 0, 0 CLTGauge = coolant, "Coolant temp", "deg C", -40, 140, -15, 1, 95, 110, 1, 1 IATGauge = intake, "Intake air temp", "deg C", -40, 140, -15, 1, 95, 110, 1, 1 - afr1Gauge = AFRValue, "Air fuel ratio", "", 10, 19.4, 12, 13, 15, 16, 2, 2 + lambda1Gauge = lambdaValue, "Lambda", "", 0.65, 1.2, 0.7, 0.75, 1.1, 1.15, 3, 2 MAFGauge = MAFValue, "Mass air flow", "v", 0, 5, 0, 1, 3, 4, 1, 1 VBattGauge = VBatt, "Battery voltage", "V", 8, 21, 9, 10, 17, 19, 1, 1 MAPGauge = MAPValue, "MAP", "kPa", 0, 300, 10, 10, 200, 200, 0, 0 @@ -1029,9 +1029,9 @@ gaugeCategory = Knock [WueAnalyze] ; wueCurveName, afrTempCompensationCurve, lambdaTargetTableName, lambdaChannel, coolantTempChannel, egoCorrectionChannel, wueChannel, activeCondition - wueAnalyzeMap = wueAnalyzer_warmup_curve, wueAfrTargetOffsetCurve, afrTableTbl, AFRValue, coolant, cltCorrection, egoCorrection + wueAnalyzeMap = wueAnalyzer_warmup_curve, wueAfrTargetOffsetCurve, lambdaTableTbl, lambdaValue, coolant, cltCorrection, egoCorrection - lambdaTargetTables = afrTableTbl, afrTSCustom + lambdaTargetTables = lambdaTableTbl, afrTSCustom wuePercentOffset = 0 ; for working with 0 based enrichment set to 100 option = disableLiveUpdates @@ -1062,7 +1062,7 @@ gaugeCategory = Knock gauge2 = CLTGauge gauge3 = TPSGauge gauge4 = MAPGauge - gauge5 = afr1Gauge + gauge5 = lambda1Gauge gauge6 = VBattGauge gauge7 = dwellGauge gauge8 = ignadvGauge @@ -1129,7 +1129,7 @@ gaugeCategory = Knock entry = TPS2Value, @@GAUGE_NAME_TPS2@@, float, "%.2f" entry = MAFValue, @@GAUGE_NAME_MAF@@, float, "%.2f" entry = MAPValue, @@GAUGE_NAME_MAP@@, float, "%.1f" - entry = AFRValue, @@GAUGE_NAME_AFR@@, float, "%.2f" + entry = lambdaValue, @@GAUGE_NAME_LAMBDA@@, float, "%.2f" entry = VBatt, @@GAUGE_NAME_VBAT@@, float, "%.2f" entry = engineLoad, @@GAUGE_NAME_ENGINE_LOAD@@, float, "%.1f" entry = fuelingLoad, @@GAUGE_NAME_FUEL_LOAD@@, float, "%.1f" @@ -1287,7 +1287,7 @@ menuDialog = main subMenu = std_separator # Fuel model - subMenu = afrTableTbl, "Target AFR", 0, {isInjectionEnabled == 1} + subMenu = lambdaTableTbl, "Target lambda", 0, {isInjectionEnabled == 1} subMenu = cltFuelCorrCurve, "CLT multiplier", 0, {isInjectionEnabled == 1} subMenu = iatFuelCorrCurve, "IAT multiplier", 0, {isInjectionEnabled == 1} subMenu = fuelClosedLoopDialog, "Closed loop fuel correction", 0, {isInjectionEnabled == 1} @@ -3354,4 +3354,3 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" [Tools] ;addTool = toolName, PanelName addTool = veTableGenerator, "VE Table Generator", veTableTbl - addTool = afrTableGenerator, "AFR Table Generator", afrTableTbl diff --git a/firmware/util/containers/table_helper.h b/firmware/util/containers/table_helper.h index 4e9ecd0888..be20e57173 100644 --- a/firmware/util/containers/table_helper.h +++ b/firmware/util/containers/table_helper.h @@ -85,7 +85,7 @@ void copy2DTable(const vType source[LOAD_BIN_SIZE][RPM_BIN_SIZE], vType destinat } } -typedef Map3D> afr_Map3D_t; +typedef Map3D> lambda_Map3D_t; typedef Map3D ign_Map3D_t; typedef Map3D fuel_Map3D_t; typedef Map3D baroCorr_Map3D_t; diff --git a/firmware/util/scaled_channel.h b/firmware/util/scaled_channel.h index 652ab05505..469282ee36 100644 --- a/firmware/util/scaled_channel.h +++ b/firmware/util/scaled_channel.h @@ -55,4 +55,5 @@ using scaled_high_pressure = scaled_channel; 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_lambda = scaled_channel; // 0-6.5 lambda at 0.0001 resolution using scaled_fuel_mass_mg = scaled_channel; // 0 - 655.35 milligrams, 0.01mg resolution diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/Fields.java b/java_console/models/src/main/java/com/rusefi/config/generated/Fields.java index 9f14036138..b74061b529 100644 --- a/java_console/models/src/main/java/com/rusefi/config/generated/Fields.java +++ b/java_console/models/src/main/java/com/rusefi/config/generated/Fields.java @@ -34,10 +34,7 @@ public class Fields { public static final int afr_v2_offset = 572; public static final int afr_value1_offset = 568; public static final int afr_value2_offset = 576; - public static final int afrLoadBins_offset = 18848; public static final int afrOverrideMode_offset = 2111; - public static final int afrRpmBins_offset = 18912; - public static final int afrTable_offset = 18592; public static final int afterCrankingIACtaperDuration_offset = 2036; public static final int AFTERSTART_DECAY_CURVE_SIZE = 8; public static final int AFTERSTART_ENRICH_CURVE_SIZE = 8; @@ -592,7 +589,6 @@ public class Fields { public static final String GAUGE_NAME_ACCEL_X = "Acceleration: X"; public static final String GAUGE_NAME_ACCEL_Y = "Acceleration: Y"; public static final String GAUGE_NAME_ACCEL_Z = "Acceleration: Z"; - public static final String GAUGE_NAME_AFR = "Air/Fuel Ratio"; public static final String GAUGE_NAME_AIR_FLOW = "MAF air flow"; public static final String GAUGE_NAME_AIR_MASS = "air mass"; public static final String GAUGE_NAME_BARO_PRESSURE = "Barometric pressure"; @@ -641,6 +637,7 @@ public class Fields { public static final String GAUGE_NAME_INJECTOR_LAG = "fuel: injector lag"; public static final String GAUGE_NAME_KNOCK_COUNTER = "knock: counter"; public static final String GAUGE_NAME_KNOCK_LEVEL = "knock: current level"; + public static final String GAUGE_NAME_LAMBDA = "Lambda"; public static final String GAUGE_NAME_MAF = "MAF"; public static final String GAUGE_NAME_MAP = "MAP"; public static final String GAUGE_NAME_RPM = "RPM"; @@ -943,6 +940,9 @@ public class Fields { public static final int knockNoise_offset = 1820; public static final int knockNoiseRpmBins_offset = 1852; public static final int knockVThreshold_offset = 1512; + public static final int lambdaLoadBins_offset = 18848; + public static final int lambdaRpmBins_offset = 18912; + public static final int lambdaTable_offset = 18592; public static final int launchActivateDelay_offset = 1060; public static final int launchActivatePin_offset = 991; public static final int launchActivationMode_offset = 1020; @@ -1089,6 +1089,8 @@ public class Fields { public static final int PACK_MULT_ANGLE = 50; public static final int PACK_MULT_FUEL_MASS = 100; public static final int PACK_MULT_HIGH_PRESSURE = 10; + public static final int PACK_MULT_LAMBDA = 10000; + public static final int PACK_MULT_LAMBDA_CFG = 147; public static final int PACK_MULT_MASS_FLOW = 10; public static final int PACK_MULT_MS = 300; public static final int PACK_MULT_PERCENT = 100; @@ -2643,7 +2645,7 @@ public class Fields { public static final Field TCUSOLENOIDTABLE = Field.create("TCUSOLENOIDTABLE", 15136, FieldType.INT); public static final Field IGNITIONTABLE = Field.create("IGNITIONTABLE", 16288, FieldType.INT); public static final Field VETABLE = Field.create("VETABLE", 17440, FieldType.INT); - public static final Field AFRTABLE = Field.create("AFRTABLE", 18592, FieldType.INT); + public static final Field LAMBDATABLE = Field.create("LAMBDATABLE", 18592, FieldType.INT); public static final Field TPSTPSACCELTABLE = Field.create("TPSTPSACCELTABLE", 18976, FieldType.INT); public static final Field FSIOTABLE1 = Field.create("FSIOTABLE1", 19296, FieldType.INT); public static final Field FSIOTABLE2 = Field.create("FSIOTABLE2", 19616, FieldType.INT); @@ -3698,7 +3700,7 @@ public class Fields { TCUSOLENOIDTABLE, IGNITIONTABLE, VETABLE, - AFRTABLE, + LAMBDATABLE, TPSTPSACCELTABLE, FSIOTABLE1, FSIOTABLE2, diff --git a/java_console/models/src/main/java/com/rusefi/core/Sensor.java b/java_console/models/src/main/java/com/rusefi/core/Sensor.java index e9005b902c..27be0608f1 100644 --- a/java_console/models/src/main/java/com/rusefi/core/Sensor.java +++ b/java_console/models/src/main/java/com/rusefi/core/Sensor.java @@ -44,7 +44,7 @@ public enum Sensor { MAF(GAUGE_NAME_MAF, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 26, 1.0 / PACK_MULT_VOLTAGE, 0, 5, "Volts"), MAP(GAUGE_NAME_MAP, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 30, 1.0 / PACK_MULT_PRESSURE, 20, 300, "kPa"), - AFR(GAUGE_NAME_AFR, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 34, 1.0 / PACK_MULT_AFR, 10, 20, "afr"), + Lambda(GAUGE_NAME_LAMBDA, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 34, 1.0 / PACK_MULT_LAMBDA, 0.65, 1.2, "lambda"), VBATT(GAUGE_NAME_VBAT, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 38, 1.0 / PACK_MULT_VOLTAGE, 4, 18, "Volts"), oilPressure("Oil Pressure", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 40, 1.0 / PACK_MULT_PRESSURE, 0, 5, "X"), diff --git a/java_console/ui/src/main/java/com/rusefi/sensor_logs/BinarySensorLogSandbox.java b/java_console/ui/src/main/java/com/rusefi/sensor_logs/BinarySensorLogSandbox.java index d472bcca40..572abd69d8 100644 --- a/java_console/ui/src/main/java/com/rusefi/sensor_logs/BinarySensorLogSandbox.java +++ b/java_console/ui/src/main/java/com/rusefi/sensor_logs/BinarySensorLogSandbox.java @@ -28,7 +28,7 @@ public class BinarySensorLogSandbox { Sensor.etbTarget, Sensor.etb1DutyCycle, Sensor.totalTriggerErrorCounter, - Sensor.AFR, + Sensor.Lambda, Sensor.TARGET_AFR, Sensor.FIRMWARE_VERSION, Sensor.CLT); diff --git a/java_console/ui/src/main/java/com/rusefi/sensor_logs/SensorLogger.java b/java_console/ui/src/main/java/com/rusefi/sensor_logs/SensorLogger.java index e5a4d5d6b1..fbce55dae3 100644 --- a/java_console/ui/src/main/java/com/rusefi/sensor_logs/SensorLogger.java +++ b/java_console/ui/src/main/java/com/rusefi/sensor_logs/SensorLogger.java @@ -25,7 +25,7 @@ public class SensorLogger { Sensor.IAT, Sensor.MAF, Sensor.MAP, - Sensor.AFR, + Sensor.Lambda, Sensor.PPS, Sensor.ETB_CONTROL_QUALITY, diff --git a/java_console/ui/src/main/java/com/rusefi/ui/FuelTunePane.java b/java_console/ui/src/main/java/com/rusefi/ui/FuelTunePane.java index 0d2bea806f..95de37f12a 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/FuelTunePane.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/FuelTunePane.java @@ -125,7 +125,7 @@ public class FuelTunePane { rightPanel.add(grid.panel); grid.panel.add(GaugesGridElement.read(uiContext, config.getChild("1"), Sensor.RPM)); - grid.panel.add(GaugesGridElement.read(uiContext, config.getChild("2"), Sensor.AFR)); + grid.panel.add(GaugesGridElement.read(uiContext, config.getChild("2"), Sensor.Lambda)); JPanel middlePanel = new JPanel(new GridLayout(1, 2)); middlePanel.add(veTable); @@ -292,7 +292,7 @@ public class FuelTunePane { return; int rpm = (int) value; double engineLoad = sc.getValue(Sensor.MAP); - double afr = sc.getValue(Sensor.AFR); + double afr = sc.getValue(Sensor.Lambda); // todo: add UI for pre-conditions double deltaTps = sc.getValue(Sensor.deltaTps); double clt = sc.getValue(Sensor.CLT); diff --git a/java_console/ui/src/main/java/com/rusefi/ui/GaugesPanel.java b/java_console/ui/src/main/java/com/rusefi/ui/GaugesPanel.java index c0f7e557c0..20e0f797a2 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/GaugesPanel.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/GaugesPanel.java @@ -44,7 +44,7 @@ public class GaugesPanel { Sensor.injectorLagMs, Sensor.lastErrorCode, - Sensor.AFR, + Sensor.Lambda, Sensor.VBATT, Sensor.VSS, diff --git a/java_console/ui/src/main/java/com/rusefi/ui/widgets/DetachedSensor.java b/java_console/ui/src/main/java/com/rusefi/ui/widgets/DetachedSensor.java index 4a719bf80e..e0a5ba4ac4 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/widgets/DetachedSensor.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/widgets/DetachedSensor.java @@ -34,7 +34,7 @@ public class DetachedSensor { */ private static final Collection MOCKABLE = Arrays.asList( Sensor.CLT, - Sensor.AFR, + Sensor.Lambda, Sensor.IAT, Sensor.MAF, Sensor.MAP, diff --git a/unit_tests/tests/ignition_injection/test_fuel_computer.cpp b/unit_tests/tests/ignition_injection/test_fuel_computer.cpp index 44f0f1b3ea..3ed1da8855 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_computer.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_computer.cpp @@ -34,11 +34,11 @@ TEST(FuelComputer, getCycleFuel) { } TEST(FuelComputer, LambdaLookup) { - MockVp3d afrTable; - FuelComputer dut(afrTable); + MockVp3d lambdaTable; + FuelComputer dut(lambdaTable); - EXPECT_CALL(afrTable, getValue(1500, FloatEq(0.7f))) - .WillOnce(Return(14.7f)); + EXPECT_CALL(lambdaTable, getValue(1500, FloatEq(0.7f))) + .WillOnce(Return(0.85f)); - EXPECT_FLOAT_EQ(dut.getTargetLambda(1500, 0.7f), 1.0f); + EXPECT_FLOAT_EQ(dut.getTargetLambda(1500, 0.7f), 0.85f); } diff --git a/unit_tests/tests/test_fuel_math.cpp b/unit_tests/tests/test_fuel_math.cpp index d888bcb2da..df462da722 100644 --- a/unit_tests/tests/test_fuel_math.cpp +++ b/unit_tests/tests/test_fuel_math.cpp @@ -84,7 +84,6 @@ TEST(AirmassModes, MafNormal) { WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); engineConfiguration->fuelAlgorithm = LM_REAL_MAF; engineConfiguration->injector.flow = 200; - setAfrMap(config->afrTable, 13); MockVp3d veTable; // Ensure that the correct cell is read from the VE table diff --git a/unit_tests/tests/trigger/test_trigger_decoder.cpp b/unit_tests/tests/trigger/test_trigger_decoder.cpp index 4bc84b1177..3076ab023e 100644 --- a/unit_tests/tests/trigger/test_trigger_decoder.cpp +++ b/unit_tests/tests/trigger/test_trigger_decoder.cpp @@ -300,6 +300,10 @@ extern bool_t debugSignalExecutor; TEST(misc, testRpmCalculator) { WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); + + // These tests were written when the default target AFR was 14.0, so replicate that + engineConfiguration->stoichRatioPrimary = 140; + EXPECT_CALL(eth.mockAirmass, getAirmass(_)) .WillRepeatedly(Return(AirmassResult{0.1008f, 50.0f}));