Everything in lambda! (#1893)

* lambda

* default configs, fix build

* config, gauge, UI

* more digits

* change menu text

* fix that while I'm here

* doesn't need extra word

* todo note

* tests

* last test

* missed a config

* update java

* store target lambda

* more java

* format

* hopefully enough java for CI to pass
This commit is contained in:
Matthew Kennedy 2020-10-26 15:15:17 -07:00 committed by GitHub
parent 5e06db6b75
commit 09b41bb1bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 87 additions and 99 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -103,7 +103,7 @@ typedef struct {
scaled_pressure manifoldAirPressure; // 30
scaled_pressure baroPressure; // 32
scaled_afr airFuelRatio; // 34
scaled_lambda lambda; // 34
scaled_channel<uint16_t, 100> engineLoad; // 36
// misc sensors

View File

@ -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},

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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()
*/

View File

@ -79,4 +79,6 @@ public:
#endif /* EFI_ENABLE_MOCK_ADC */
multispark_state multispark;
float targetLambda = 0.0f;
};

View File

@ -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 {

View File

@ -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);

View File

@ -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;
/**

View File

@ -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];

View File

@ -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)

View File

@ -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);
}

View File

@ -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"

View File

@ -134,15 +134,15 @@
<table type="3D" name="Target AFR"
category="Fuel"
storageaddress="@@afrTable_offset_hex@@" sizex="@@FUEL_LOAD_COUNT@@"
storageaddress="@@lambdaTable_offset_hex@@" sizex="@@FUEL_LOAD_COUNT@@"
sizey="@@FUEL_RPM_COUNT@@" storagetype="uint8" endian="big">
<scaling units="Engine Load" expression="x/10" to_byte="x*10" format="0.00" fineincrement=".1"
<scaling units="Engine Load" expression="x/147" to_byte="x*147" format="0.00" fineincrement=".01"
coarseincrement="1"/>
<table type="X Axis" storageaddress="@@afrRpmBins_offset_hex@@" storagetype="float" endian="big">
<table type="X Axis" storageaddress="@@lambdaRpmBins_offset_hex@@" storagetype="float" endian="big">
<scaling units="RPM" expression="x" to_byte="x" format="0.00" fineincrement=".1"
coarseincrement="1"/>
</table>
<table type="Y Axis" storageaddress="@@afrLoadBins_offset_hex@@" storagetype="float" endian="big">
<table type="Y Axis" storageaddress="@@lambdaLoadBins_offset_hex@@" storagetype="float" endian="big">
<scaling units="engine_load" expression="x" to_byte="x" format="0.00" fineincrement=".1" coarseincrement="1"/>
</table>
</table>

View File

@ -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

View File

@ -85,7 +85,7 @@ void copy2DTable(const vType source[LOAD_BIN_SIZE][RPM_BIN_SIZE], vType destinat
}
}
typedef Map3D<FUEL_RPM_COUNT, FUEL_LOAD_COUNT, uint8_t, float, efi::ratio<1, PACK_MULT_AFR_CFG>> afr_Map3D_t;
typedef Map3D<FUEL_RPM_COUNT, FUEL_LOAD_COUNT, uint8_t, float, efi::ratio<1, PACK_MULT_LAMBDA_CFG>> lambda_Map3D_t;
typedef Map3D<IGN_RPM_COUNT, IGN_LOAD_COUNT, float, float> ign_Map3D_t;
typedef Map3D<FUEL_RPM_COUNT, FUEL_LOAD_COUNT, float, float> fuel_Map3D_t;
typedef Map3D<BARO_CORR_SIZE, BARO_CORR_SIZE, float, float> baroCorr_Map3D_t;

View File

@ -55,4 +55,5 @@ using scaled_high_pressure = scaled_channel<uint16_t, PACK_MULT_HIGH_PRESSURE>;
using scaled_angle = scaled_channel<int16_t, PACK_MULT_ANGLE>; // +-655 degrees at 0.02 degree resolution
using scaled_voltage = scaled_channel<uint16_t, PACK_MULT_VOLTAGE>; // 0-65v at 1mV resolution
using scaled_afr = scaled_channel<uint16_t, PACK_MULT_AFR>; // 0-65afr at 0.001 resolution
using scaled_lambda = scaled_channel<uint16_t, PACK_MULT_LAMBDA>; // 0-6.5 lambda at 0.0001 resolution
using scaled_fuel_mass_mg = scaled_channel<uint16_t, PACK_MULT_FUEL_MASS>; // 0 - 655.35 milligrams, 0.01mg resolution

View File

@ -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,

View File

@ -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"),

View File

@ -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);

View File

@ -25,7 +25,7 @@ public class SensorLogger {
Sensor.IAT,
Sensor.MAF,
Sensor.MAP,
Sensor.AFR,
Sensor.Lambda,
Sensor.PPS,
Sensor.ETB_CONTROL_QUALITY,

View File

@ -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);

View File

@ -44,7 +44,7 @@ public class GaugesPanel {
Sensor.injectorLagMs,
Sensor.lastErrorCode,
Sensor.AFR,
Sensor.Lambda,
Sensor.VBATT,
Sensor.VSS,

View File

@ -34,7 +34,7 @@ public class DetachedSensor {
*/
private static final Collection<Sensor> MOCKABLE = Arrays.asList(
Sensor.CLT,
Sensor.AFR,
Sensor.Lambda,
Sensor.IAT,
Sensor.MAF,
Sensor.MAP,

View File

@ -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);
}

View File

@ -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

View File

@ -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}));