This commit is contained in:
Matthew Kennedy 2020-07-30 21:20:10 -07:00
parent 08be750098
commit 132ee12974
6 changed files with 20 additions and 72 deletions

View File

@ -286,7 +286,7 @@ void updateDevConsoleState(void) {
static void showFuelInfo2(float rpm, float engineLoad) {
float baseFuelMs = getBaseTableFuel((int) rpm, engineLoad);
float baseFuelMs = 0; // TODO
float magicAir = SpeedDensityBase::getAirmassImpl(1, 100, convertCelsiusToKelvin(20) PASS_ENGINE_PARAMETER_SUFFIX);

View File

@ -197,39 +197,24 @@ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(tpsAccelEnrich), "NaN tpsAccelEnrich", 0);
ENGINE(engineState.tpsAccelEnrich) = tpsAccelEnrich;
floatms_t baseFuel;
// airmass modes - get airmass first, then convert to fuel
auto model = getAirmassModel(PASS_ENGINE_PARAMETER_SIGNATURE);
efiAssert(CUSTOM_ERR_ASSERT, model != nullptr, "Invalid airmass mode", 0.0f);
if ((CONFIG(fuelAlgorithm) == LM_SPEED_DENSITY) ||
(engineConfiguration->fuelAlgorithm == LM_REAL_MAF) ||
(engineConfiguration->fuelAlgorithm == LM_ALPHA_N_2) ||
(engineConfiguration->fuelAlgorithm == LM_MOCK)) {
// airmass modes - get airmass first, then convert to fuel
auto model = getAirmassModel(PASS_ENGINE_PARAMETER_SIGNATURE);
efiAssert(CUSTOM_ERR_ASSERT, model != nullptr, "Invalid airmass mode", 0.0f);
auto airmass = model->getAirmass(rpm);
auto airmass = model->getAirmass(rpm);
// The airmass mode will tell us how to look up AFR - use the provided Y axis value
float targetAfr = afrMap.getValue(rpm, airmass.EngineLoadPercent);
// The airmass mode will tell us how to look up AFR - use the provided Y axis value
float targetAfr = afrMap.getValue(rpm, airmass.EngineLoadPercent);
// Plop some state for others to read
ENGINE(engineState.targetAFR) = targetAfr;
ENGINE(engineState.sd.airMassInOneCylinder) = airmass.CylinderAirmass;
ENGINE(engineState.fuelingLoad) = airmass.EngineLoadPercent;
// TODO: independently selectable ignition load mode
ENGINE(engineState.ignitionLoad) = airmass.EngineLoadPercent;
// Plop some state for others to read
ENGINE(engineState.targetAFR) = targetAfr;
ENGINE(engineState.sd.airMassInOneCylinder) = airmass.CylinderAirmass;
ENGINE(engineState.fuelingLoad) = airmass.EngineLoadPercent;
// TODO: independently selectable ignition load mode
ENGINE(engineState.ignitionLoad) = airmass.EngineLoadPercent;
baseFuel = getInjectionDurationForAirmass(airmass.CylinderAirmass, targetAfr PASS_ENGINE_PARAMETER_SUFFIX) * 1000;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN baseFuel", 0);
} else {
float tps = Sensor::get(SensorType::Tps1).value_or(0);
ENGINE(engineState.fuelingLoad) = tps;
// TODO: independently selectable ignition load mode
ENGINE(engineState.ignitionLoad) = tps;
baseFuel = getBaseTableFuel(rpm, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN bt baseFuel", 0);
}
float baseFuel = getInjectionDurationForAirmass(airmass.CylinderAirmass, targetAfr PASS_ENGINE_PARAMETER_SUFFIX) * 1000;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN baseFuel", 0);
engine->engineState.baseFuel = baseFuel;
@ -446,27 +431,6 @@ float getFuelCutOffCorrection(efitick_t nowNt, int rpm DECLARE_ENGINE_PARAMETER_
return fuelCorr;
}
/**
* @return Fuel injection duration injection as specified in the fuel map, in milliseconds
*/
floatms_t getBaseTableFuel(int rpm, float engineLoad) {
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
if (cisnan(engineLoad)) {
warning(CUSTOM_NAN_ENGINE_LOAD_2, "NaN engine load");
return 0;
}
floatms_t result = fuelMap.getValue(rpm, engineLoad);
if (cisnan(result)) {
// result could be NaN in case of invalid table, like during initialization
result = 0;
warning(CUSTOM_ERR_FUEL_TABLE_NOT_READY, "baseFuel table not ready");
}
return result;
#else
return 0;
#endif
}
float getBaroCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (hasBaroSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
float correction = baroCorrMap.getValue(GET_RPM(), getBaroPressure(PASS_ENGINE_PARAMETER_SIGNATURE));

View File

@ -22,7 +22,6 @@ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX);
*/
floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX);
floatms_t getBaseTableFuel(int rpm, float engineLoad);
float getBaroCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE);
int getNumberOfInjections(injection_mode_e mode DECLARE_ENGINE_PARAMETER_SUFFIX);
angle_t getInjectionOffset(float rpm, float load DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -75,8 +75,6 @@ static void testRusefiMethods(const int count) {
start = currentTimeMillis();
for (int i = 0; i < count; i++)
tempi += getBaseTableFuel(testEngine.engineConfiguration, 4020, 2.21111);
time = currentTimeMillis() - start;
if (tempi != 0)
scheduleMsg(logger, "Finished %d iterations of getBaseFuel in %dms", count, time);

View File

@ -21,23 +21,8 @@ using ::testing::FloatNear;
TEST(misc, testFuelMap) {
printf("Setting up FORD_ASPIRE_1996\r\n");
WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996);
engineConfiguration->fuelAlgorithm = LM_PLAIN_MAF;
printf("Filling fuel map\r\n");
for (int k = 0; k < FUEL_LOAD_COUNT; k++) {
for (int r = 0; r < FUEL_RPM_COUNT; r++) {
eth.engine.config->fuelTable[k][r] = k * 200 + r;
}
}
for (int i = 0; i < FUEL_LOAD_COUNT; i++)
eth.engine.config->fuelLoadBins[i] = i;
for (int i = 0; i < FUEL_RPM_COUNT; i++)
eth.engine.config->fuelRpmBins[i] = i;
ASSERT_EQ( 1005, getBaseTableFuel(5, 5)) << "base fuel table";
printf("*** getInjectorLag\r\n");
// engine->engineState.vb
assertEqualsM("lag", 1.04, getInjectorLag(12 PASS_ENGINE_PARAMETER_SUFFIX));
for (int i = 0; i < VBAT_INJECTOR_CURVE_SIZE; i++) {
@ -53,7 +38,8 @@ TEST(misc, testFuelMap) {
// because all the correction tables are zero
printf("*************************************************** getRunningFuel 1\r\n");
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
float baseFuel = getBaseTableFuel(5, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
//float baseFuel = getBaseTableFuel(5, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
float baseFuel = 1234;
ASSERT_NEAR(5.3679, getRunningFuel(baseFuel PASS_ENGINE_PARAMETER_SUFFIX), EPS4D) << "base fuel";
printf("*************************************************** setting IAT table\r\n");
@ -88,7 +74,8 @@ TEST(misc, testFuelMap) {
// 1005 * 2 for IAT correction
printf("*************************************************** getRunningFuel 2\r\n");
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
baseFuel = getBaseTableFuel(5, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
//baseFuel = getBaseTableFuel(5, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
baseFuel = 1234;
EXPECT_EQ(baseFuel, 1005);
// Check that runningFuel corrects appropriately

View File

@ -592,7 +592,7 @@ static void assertInjectionEventBatch(const char *msg, InjectionEvent *ev, int i
static void setTestBug299(EngineTestHelper *eth) {
// TODO: switch to mock airmass
eth->persistentConfig.engineConfiguration.fuelAlgorithm = LM_PLAIN_MAF;
//eth->persistentConfig.engineConfiguration.fuelAlgorithm = LM_PLAIN_MAF;
setupSimpleTestEngineWithMafAndTT_ONE_trigger(eth);
Engine *engine = &eth->engine;
EXPAND_Engine