/** * @return per cylinder injection time, in Milliseconds */ floatms_t getSpeedDensityFuel(float map DECLARE_GLOBAL_SUFFIX) { /** * most of the values are pre-calculated for performance reasons */ float tChargeK = ENGINE(engineState.tChargeK); if (cisnan(tChargeK)) { warning(CUSTOM_ERR_TCHARGE_NOT_READY2, "tChargeK not ready"); // this would happen before we have CLT reading for example return 0; } efiAssert(CUSTOM_ERR_ASSERT, !cisnan(map), "NaN map", 0); float adjustedMap = map + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_GLOBAL_SIGNATURE); efiAssert(CUSTOM_ERR_ASSERT, !cisnan(adjustedMap), "NaN adjustedMap", 0); float airMass = getCylinderAirMass(ENGINE(engineState.currentBaroCorrectedVE), adjustedMap, tChargeK PASS_GLOBAL_SUFFIX); if (cisnan(airMass)) { warning(CUSTOM_ERR_6685, "NaN airMass"); return 0; } #if EFI_PRINTF_FUEL_DETAILS printf("map=%.2f adjustedMap=%.2f airMass=%.2f\t\n", map, adjustedMap, engine->engineState.airMass); #endif /*EFI_PRINTF_FUEL_DETAILS */ engine->engineState.airMass = airMass; return sdMath(airMass, ENGINE(engineState.targetAFR) PASS_GLOBAL_SUFFIX) * 1000; }
void testSpeedDensity(void) { printf("*************************************************** testSpeedDensity\r\n"); EngineTestHelper eth(FORD_INLINE_6_1995); EXPAND_EngineTestHelper; schedulingQueue.clear(); // todo: there must be a better place for this eth.ec->trigger.customTotalToothCount = 8; eth.applyTriggerShape(); eth.fireTriggerEvents(36); assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F)); // 427 cubic inches, that's a LOT of engine eth.ec->specs.displacement = 6.99728; eth.ec->specs.cylindersCount = 8; eth.ec->injector.flow = gramm_second_to_cc_minute(5.303); float airMass = getAirMass(eth.ec, 0.92, 98, 293.16); assertEquals(0.9371, airMass); // 0.01414 sec or 14.14 ms assertEquals(0.01414, sdMath(eth.ec, airMass, 12.5)); }
static void showFuelInfo2(float rpm, float engineLoad) { float baseFuelMs = getBaseTableFuel(engineConfiguration, (int) rpm, engineLoad); scheduleMsg(&logger, "SD magic fuel %f", sdMath(engineConfiguration, 100, 100, 14.7, convertCelsiusToKelvin(20))); scheduleMsg(&logger, "inj flow %fcc/min displacement %fL", engineConfiguration->injector.flow, engineConfiguration->specs.displacement); scheduleMsg(&logger2, "algo=%s/pump=%s", getEngine_load_mode_e(engineConfiguration->algorithm), boolToString(enginePins.fuelPumpRelay.getLogicValue())); scheduleMsg(&logger2, "injection phase=%f/global fuel correction=%f", getinjectionOffset(rpm), engineConfiguration->globalFuelCorrection); scheduleMsg(&logger2, "baro correction=%f", engine->engineState.baroCorrection); #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) scheduleMsg(&logger, "base cranking fuel %f", engineConfiguration->cranking.baseFuel); scheduleMsg(&logger2, "cranking fuel: %f", getCrankingFuel(PASS_ENGINE_PARAMETER_F)); if (engine->rpmCalculator.isRunning()) { float iatCorrection = engine->engineState.iatFuelCorrection; float cltCorrection = engine->engineState.cltFuelCorrection; float injectorLag = engine->injectorLagMs; scheduleMsg(&logger2, "rpm=%f engineLoad=%f", rpm, engineLoad); scheduleMsg(&logger2, "baseFuel=%f", baseFuelMs); scheduleMsg(&logger2, "iatCorrection=%f cltCorrection=%f injectorLag=%f", iatCorrection, cltCorrection, injectorLag); float value = getRunningFuel(baseFuelMs, (int) rpm PASS_ENGINE_PARAMETER); scheduleMsg(&logger2, "injection pulse width: %f", value); } #endif }
/** * @return per cylinder injection time, in Milliseconds */ float getSpeedDensityFuel(int rpm DECLARE_ENGINE_PARAMETER_S) { //int rpm = engine->rpmCalculator->rpm(); /** * most of the values are pre-calculated for performance reasons */ float tChargeK = ENGINE(engineState.tChargeK); float map = getMap(); float adjMap = map + engine->mapAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F); return sdMath(engineConfiguration, ENGINE(engineState.currentVE), adjMap, ENGINE(engineState.targerAFR), tChargeK) * 1000; }
/** * @return value in Milliseconds */ float getSpeedDensityFuel(Engine *engine, int rpm) { //int rpm = engine->rpmCalculator->rpm(); engine_configuration_s *engineConfiguration = engine->engineConfiguration; float tps = getTPS(engineConfiguration); float coolantC = getCoolantTemperature(engine->engineConfiguration2); float intakeC = getIntakeAirTemperature(engine->engineConfiguration2); float tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC)); float map = getMap(); float VE = veMap.getValue(map, engineConfiguration->veLoadBins, rpm, engineConfiguration->veRpmBins); float AFR = afrMap.getValue(map, engineConfiguration->afrLoadBins, rpm, engineConfiguration->afrRpmBins); return sdMath(engine->engineConfiguration, VE, map, AFR, tChargeK) * 1000; }
void testSpeedDensity(void) { printf("*************************************************** testSpeedDensity\r\n"); EngineTestHelper eth(FORD_INLINE_6_1995); eth.ec->triggerConfig.customTotalToothCount = 8; eth.initTriggerShapeAndRpmCalculator(); eth.fireTriggerEvents(); assertEqualsM("RPM", 1500, eth.rpmState.rpm()); // 427 cubic inches, that's a LOT of engine eth.ec->displacement = 6.99728; eth.ec->cylindersCount = 8; eth.ec->injectorFlow = gramm_second_to_cc_minute(5.303); // 0.01414 sec or 14.14 ms assertEquals(0.01414, sdMath(eth.ec, 0.92, 98, 12.5, 293.16)); }