Configurable stoichiometric ratio (#1710)
* configurable stoich ratio * afr table always in gas afr * default * typo * use defined ratio * do it in config too * missed a spot * oops wrong one Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
57e4c071d1
commit
c53979a017
|
@ -250,7 +250,7 @@ void setConstantDwell(floatms_t dwellMs DECLARE_CONFIG_PARAMETER_SUFFIX) {
|
|||
void setAfrMap(afr_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 * AFR_STORAGE_MULT);
|
||||
table[l][rpmIndex] = (int)(value * PACK_MULT_AFR_CFG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -832,6 +832,7 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
setLinearCurve(engineConfiguration->map.samplingWindow, 50, 50, 1);
|
||||
|
||||
setAfrMap(config->afrTable, 14.7);
|
||||
engineConfiguration->stoichRatioPrimary = 14.7f / PACK_MULT_AFR_CFG;
|
||||
|
||||
setDefaultVETable(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
|
|
|
@ -16,12 +16,19 @@ FuelComputer::FuelComputer(const ValueProvider3D& afrTable) : m_afrTable(&afrTab
|
|||
|
||||
float FuelComputer::getStoichiometricRatio() const {
|
||||
// TODO: vary this with ethanol content/configured setting/whatever
|
||||
return 14.7f;
|
||||
float rawConfig = (float)CONFIG(stoichRatioPrimary) / PACK_MULT_AFR_CFG;
|
||||
|
||||
// Config compatibility: this field may be zero on ECUs with old defaults
|
||||
if (rawConfig < 5) {
|
||||
return 14.7f;
|
||||
}
|
||||
|
||||
return rawConfig;
|
||||
}
|
||||
|
||||
float FuelComputer::getTargetLambda(int rpm, float load) const {
|
||||
efiAssert(OBD_PCM_Processor_Fault, m_afrTable != nullptr, "AFR table null", 0);
|
||||
|
||||
// TODO: set the table value in lambda instead of afr
|
||||
return m_afrTable->getValue(rpm, load) / getStoichiometricRatio();
|
||||
return m_afrTable->getValue(rpm, load) / 14.7f;
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@ EXTERN_ENGINE;
|
|||
|
||||
fuel_Map3D_t veMap("VE");
|
||||
fuel_Map3D_t ve2Map("VE2");
|
||||
afr_Map3D_t afrMap("AFR", 1.0 / AFR_STORAGE_MULT);
|
||||
afr_Map3D_t afrMap("AFR", 1.0f / PACK_MULT_AFR_CFG);
|
||||
baroCorr_Map3D_t baroCorrMap("baro");
|
||||
|
||||
#define tpMin 0
|
||||
|
|
|
@ -173,6 +173,7 @@ struct_no_prefix engine_configuration_s
|
|||
#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 FSIO_TABLE_8 8
|
||||
|
||||
#define FSIO_CURVE_8 8
|
||||
|
@ -196,7 +197,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", 0.1, 0, 0, 25.0, 1
|
||||
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 fsio_table_8x8_u8t @@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@ array, U08, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 255.0, 0
|
||||
custom fsio_table_8x8_f32t 4*@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@ array, F32, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 30000.0, 2
|
||||
|
@ -1317,7 +1318,7 @@ tChargeMode_e tChargeMode;
|
|||
int16_t idlerpmpid_iTermMin;iTerm min value;"", 1, 0, -30000, 30000.0, 0
|
||||
|
||||
spi_device_e tle6240spiDevice;
|
||||
uint8_t[1] unusedSpiPadding7;;"units", 1, 0, -20, 100, 0
|
||||
uint8_t stoichRatioPrimary;+Stoichiometric ratio for your primary fuel.;":1", {1/PACK_MULT_AFR_CFG},0, 5, 25.0, 1
|
||||
int16_t idlerpmpid_iTermMax;iTerm max value;"", 1, 0, -30000, 30000.0, 0
|
||||
|
||||
spi_device_e mc33972spiDevice;
|
||||
|
|
|
@ -1604,6 +1604,9 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
|||
dialog = injChars, "Injector Settings", yAxis
|
||||
field = "Injector Flow", injector_flow, {isInjectionEnabled == 1}
|
||||
|
||||
dialog = fuelParams, "Fuel characteristics", yAxis
|
||||
field = "Stoichiometric ratio", stoichRatioPrimary, {isInjectionEnabled == 1}
|
||||
|
||||
dialog = injectorOutputSettings, "Injector Outputs", yAxis
|
||||
field = "Use only first half of pins for batch mode"
|
||||
field = "Injection Pin 1", injectionPins1, {isInjectionEnabled == 1}
|
||||
|
@ -1651,6 +1654,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
|||
topicHelp = "fuelHelp"
|
||||
panel = baseInjection
|
||||
panel = injChars
|
||||
panel = fuelParams
|
||||
panel = injectorsDeadTime
|
||||
|
||||
dialog = ignitionCylExtra, "Ignition Cylinder Extra Timing"
|
||||
|
|
|
@ -143,11 +143,6 @@ void copy2DTable(const vType source[LOAD_BIN_SIZE][RPM_BIN_SIZE], vType destinat
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AFR value is packed into uint8_t with a multiplier of 10
|
||||
*/
|
||||
#define AFR_STORAGE_MULT 10
|
||||
|
||||
typedef Map3D<FUEL_RPM_COUNT, FUEL_LOAD_COUNT, uint8_t, float> afr_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;
|
||||
|
|
Loading…
Reference in New Issue