44 float baseCrankingFuel;
46 baseCrankingFuel = baseFuel;
49 baseCrankingFuel = interpolate3d(
65 bool alreadyWarned =
false;
74 if (e85Mult <= 0.1f) {
123 float correction =
baroCorrection * iatCorrection * cltCorrection * postCrankingFuelCorrection;
125#if EFI_ANTILAG_SYSTEM
129#if EFI_LAUNCH_CONTROL
134#ifdef MODULE_VVL_CONTROLLER
140 float runningFuel = baseFuel * correction;
158 if (mode == engine_load_mode_e::UNSUPPORTED_ENUM_VALUE) {
164 case engine_load_mode_e::LM_SPEED_DENSITY:
return &
sdAirmass;
165 case engine_load_mode_e::LM_REAL_MAF:
return &
mafAirmass;
180#if EFI_ENGINE_CONTROL
190 auto airmass = model->getAirmass(rpm,
true);
209 if (std::isnan(baseFuelMass)) {
218 if (std::isnan(rpm)) {
222 if (std::isnan(load)) {
232 if (std::isnan(value)) {
250 case IM_SIMULTANEOUS:
251 case IM_SINGLE_POINT:
267 case IM_SIMULTANEOUS: {
275 return 1.0f / cylCount;
278 case IM_SINGLE_POINT:
291 return 100 * totalInjectiorAmountPerCycle / engineCycleDuration;
297 return 100 * totalInjectiorAmountPerCycle / engineCycleDuration;
328 float injectionFuelMass = cycleFuelMass * durationMultiplier;
338 float tpsFuelMass = 0;
345 float tpsAccelPerInjection = durationMultiplier * tpsAccelEnrich;
349 case AE_MODE_PERCENT_ADDER:
351 tpsFuelMass = injectionFuelMass * tpsAccelPerInjection;
354 case AE_MODE_MS_ADDER:
360 case AE_MODE_PREDICTIVE_MAP:
370 return injectionFuelMass + tpsFuelMass;
416 float postCrankingFactor = interpolate3d(
423 if (postCrankingFactor < 1.0f)
424 postCrankingFactor = 1.0f;
426 return postCrankingFactor;
434 float correction = interpolate3d(
440 if (std::isnan(correction) || correction < 0.01) {
452#if EFI_ANTILAG_SYSTEM
455 auto AlsFuelAdd = interpolate3d(
468#if EFI_ENGINE_CONTROL
487 return idealGasLaw(cylDisplacement, STD_ATMOSPHERE, C_K_OFFSET + STD_IAT);
490PUBLIC_API_WEAK_SOMETHING_WEIRD
492 auto trimPercent = interpolate3d(
501 return (100 + trimPercent) / 100;
511 float frac = 0.01f * interpolate3d(
FuelComputer fuelComputer
LaunchControlBase launchController
RpmCalculator rpmCalculator
AntilagSystemBase antilagController
AirmassModelBase * mockAirmassModel
constexpr auto & module()
floatms_t injectionDuration
floatms_t injectionDurationStage2
mass_t getCycleFuel(mass_t airmass, float rpm, float load) override
bool test(float value, float rising, float falling)
float getFuelCoefficient() const
float getLimitingFuelCorrection() const
void initTable(TValueInit(&table)[TRowNum][TColNum], const TXColumnInit(&columnBins)[TColNum], const TRowInit(&rowBins)[TRowNum])
float getFuelCoefficient() const
bool isCranking() const override
uint32_t getRevolutionCounterSinceStart(void) const
virtual bool hasSensor() const
virtual SensorResult get() const =0
static float getOrZero(SensorType type)
float getAirflow(float rpm, float map, bool postState)
float getFuelCoefficient() const
float interpolateClamped(float x1, float y1, float x2, float y2, float x)
LimpManager * getLimpManager()
injection_mode_e getCurrentInjectionMode()
static EngineAccessor engine
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
floatms_t getEngineCycleDuration(float rpm)
bool warning(ObdCode code, const char *fmt,...)
void firmwareError(ObdCode code, const char *fmt,...)
percent_t getInjectorDutyCycleStage2(float rpm)
static mapEstimate_Map3D_t mapEstimationTable
static float getBaseFuelMass(float rpm)
void initFuelMap()
Initialize fuel map data structure.
float getStage2InjectionFraction(float rpm, float load)
float getPostCrankingFuelCorrection()
float getRunningFuel(float baseFuel)
int getNumberOfInjections(injection_mode_e mode)
static SpeedDensityAirmass sdAirmass(veMap, mapEstimationTable)
AirmassModelBase * getAirmassModel(engine_load_mode_e mode)
angle_t getInjectionOffset(float rpm, float load)
static MafAirmass mafAirmass(veMap)
float getIatFuelCorrection()
float getCrankingFuel(float baseFuel)
float getBaroCorrection()
float getCrankingFuel3(float baseFuel, uint32_t revolutionCounterSinceStart)
static AlphaNAirmass alphaNAirmass(veMap)
float getMaxAirflowAtMap(float map)
float getCycleFuelMass(bool isCranking, float baseFuelMass)
percent_t getFuelALSCorrection(float rpm)
float getCltFuelCorrection()
Engine warm-up fuel correction.
PUBLIC_API_WEAK_SOMETHING_WEIRD float getCylinderFuelTrim(size_t cylinderNumber, float rpm, float fuelLoad)
static Hysteresis stage2Hysteresis
float getStandardAirCharge()
float getInjectionModeDurationMultiplier()
float getInjectionMass(float rpm)
percent_t getInjectorDutyCycle(float rpm)
static CCM_OPTIONAL FunctionalSensor iat(SensorType::Iat, MS2NT(10))
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
AirmassModelBase & getLuaAirmassModel()
@ CUSTOM_ERR_INVALID_INJECTION_MODE
@ OBD_Barometric_Press_Circ_Range_Perf
@ CUSTOM_ERR_ZERO_E85_MULT
@ CUSTOM_ERR_ZERO_CRANKING_FUEL
@ CUSTOM_ERR_ZERO_E0_MULT
revolutionCounterSinceStart("revolutionCounterSinceStart", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 64, 1.0, 0.0, 0.0, "")
baroCorrection("Fuel: Barometric pressure mult", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1364, 1.0, -1.0, -1.0, "")
normalizedCylinderFilling("Air: Normalized cyl filling", SensorCategory.SENSOR_INPUTS, FieldType.INT, 928, 1.0, 0.0, 100.0, "%")
crankingFuel("crankingFuel", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1352, 1.0, -1.0, -1.0, "")
mass_t idealGasLaw(float volume, float pressure, float temperature)
float getLoadOverride(float defaultLoad, load_override_e overrideMode) const
scaled_channel< uint16_t, 100, 1 > baseFuel
float coolantTemperatureCoefficient
scaled_channel< uint16_t, 100, 1 > fuel
engine_load_mode_e fuelAlgorithm
bool enableStagedInjection
bool useRunningMathForCranking
accel_enrichment_mode_e accelEnrichmentMode
load_override_e ignOverrideMode
injection_mode_e injectionMode
cranking_fuel_s crankingFuel
float normalizedCylinderFilling
float sdAirMassInOneCylinder
float totalFuelCorrection
scaled_channel< int8_t, 5, 1 > table[FUEL_TRIM_SIZE][FUEL_TRIM_SIZE]
scaled_channel< int16_t, 10, 1 > ALSFuelAdjustment[ALS_SIZE][ALS_SIZE]
uint16_t injectorStagingRpmBins[INJ_STAGING_COUNT]
float crankingFuelCoef[CRANKING_CURVE_SIZE]
uint8_t injectorStagingTable[INJ_STAGING_COUNT][INJ_STAGING_COUNT]
float baroCorrTable[BARO_CORR_SIZE][BARO_CORR_SIZE]
float crankingCycleBaseFuel[CRANKING_CYCLE_CLT_SIZE][CRANKING_CURVE_SIZE]
uint16_t injectorStagingLoadBins[INJ_STAGING_COUNT]
uint16_t alsFuelAdjustmentLoadBins[ALS_SIZE]
float baroCorrPressureBins[BARO_CORR_SIZE]
int16_t injectionPhase[INJ_PHASE_LOAD_COUNT][INJ_PHASE_RPM_COUNT]
int16_t postCrankingCLTBins[CRANKING_ENRICH_CLT_COUNT]
float crankingFuelBins[CRANKING_CURVE_SIZE]
uint16_t injPhaseRpmBins[INJ_PHASE_RPM_COUNT]
uint16_t injPhaseLoadBins[INJ_PHASE_LOAD_COUNT]
uint16_t fuelTrimRpmBins[FUEL_TRIM_SIZE]
float cltFuelCorr[CLT_FUEL_CURVE_SIZE]
uint16_t postCrankingDurationBins[CRANKING_ENRICH_COUNT]
float crankingTpsCoef[CRANKING_CURVE_SIZE]
scaled_channel< uint16_t, 100, 1 > mapEstimateTpsBins[MAP_EST_LOAD_COUNT]
float baroCorrRpmBins[BARO_CORR_SIZE]
float postCrankingFactor[CRANKING_ENRICH_CLT_COUNT][CRANKING_ENRICH_COUNT]
fuel_cyl_trim_s fuelTrims[MAX_CYLINDER_COUNT]
uint16_t fuelTrimLoadBins[FUEL_TRIM_SIZE]
float cltFuelCorrBins[CLT_FUEL_CURVE_SIZE]
scaled_channel< uint16_t, 100, 1 > crankingFuelCoefE100[CRANKING_CURVE_SIZE]
float iatFuelCorr[IAT_CURVE_SIZE]
int16_t crankingCycleFuelCltBins[CRANKING_CYCLE_CLT_SIZE]
float iatFuelCorrBins[IAT_CURVE_SIZE]
float crankingCycleBins[CRANKING_CURVE_SIZE]
scaled_channel< uint16_t, 100, 1 > mapEstimateTable[MAP_EST_LOAD_COUNT][MAP_EST_RPM_COUNT]
uint16_t mapEstimateRpmBins[MAP_EST_RPM_COUNT]
float crankingTpsBins[CRANKING_CURVE_SIZE]
uint16_t alsFuelAdjustmentrpmBins[ALS_SIZE]
scaled_channel< uint16_t, 100, 1 > baseFuel
float postCrankingFuelCorrection
scaled_channel< uint16_t, 100, 1 > fuel
float intakeTemperatureCoefficient
float coolantTemperatureCoefficient
void wrapAngle(angle_t &angle, const char *msg, ObdCode code)