44 float baseCrankingFuel;
46 baseCrankingFuel = baseFuel;
66 bool alreadyWarned =
false;
75 if (e85Mult <= 0.1f) {
125 float correction =
baroCorrection * iatCorrection * cltCorrection * postCrankingFuelCorrection;
127#if EFI_ANTILAG_SYSTEM
131#if EFI_LAUNCH_CONTROL
138 float runningFuel = baseFuel * correction;
156 case LM_SPEED_DENSITY:
return &
sdAirmass;
175#if EFI_ENGINE_CONTROL
185 auto airmass = model->getAirmass(rpm,
true);
204 if (std::isnan(baseFuelMass)) {
213 if (std::isnan(rpm)) {
217 if (std::isnan(load)) {
227 if (std::isnan(value)) {
245 case IM_SIMULTANEOUS:
246 case IM_SINGLE_POINT:
262 case IM_SIMULTANEOUS: {
270 return 1.0f / cylCount;
273 case IM_SINGLE_POINT:
286 return 100 * totalInjectiorAmountPerCycle / engineCycleDuration;
292 return 100 * totalInjectiorAmountPerCycle / engineCycleDuration;
323 float injectionFuelMass = cycleFuelMass * durationMultiplier;
336 float tpsAccelPerInjection = durationMultiplier * tpsAccelEnrich;
339 return injectionFuelMass * (1 + tpsAccelPerInjection);
343 return injectionFuelMass + tpsFuelMass;
383 float correction = interpolate3d(
389 if (std::isnan(correction) || correction < 0.01) {
401#if EFI_ANTILAG_SYSTEM
404 auto AlsFuelAdd = interpolate3d(
417#if EFI_ENGINE_CONTROL
436 return idealGasLaw(cylDisplacement, STD_ATMOSPHERE, C_K_OFFSET + STD_IAT);
439PUBLIC_API_WEAK_SOMETHING_WEIRD
441 auto trimPercent = interpolate3d(
450 return (100 + trimPercent) / 100;
460 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 interpolateClamped(float x1, float y1, float x2, float y2, float x)
LimpManager * getLimpManager()
injection_mode_e getCurrentInjectionMode()
static Engine *const 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 getRunningFuel(float baseFuel)
int getNumberOfInjections(injection_mode_e mode)
static float getCycleFuelMass(bool isCranking, float baseFuelMass)
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)
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
normalizedCylinderFilling("Air: Normalized cyl filling", SensorCategory.SENSOR_INPUTS, FieldType.INT, 916, 1.0, 0.0, 100.0, "%")
baroCorrection("Fuel: Barometric pressure mult", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1288, 1.0, -1.0, -1.0, "")
revolutionCounterSinceStart("revolutionCounterSinceStart", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 56, 1.0, 0.0, 0.0, "")
crankingFuel("crankingFuel", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1272, 1.0, -1.0, -1.0, "")
mass_t idealGasLaw(float volume, float pressure, float temperature)
float getLoadOverride(float defaultLoad, load_override_e overrideMode) const
float coolantTemperatureCoefficient
float durationCoefficient
scaled_channel< uint16_t, 100, 1 > fuel
engine_load_mode_e fuelAlgorithm
bool enableStagedInjection
bool useRunningMathForCranking
cranking_parameters_s cranking
scaled_channel< uint16_t, 1000, 1 > displacement
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]
float crankingCycleFuelCoef[CRANKING_CYCLE_CLT_SIZE][CRANKING_CURVE_SIZE]
uint8_t injectorStagingTable[INJ_STAGING_COUNT][INJ_STAGING_COUNT]
fuel_cyl_trim_s fuelTrims[12]
float baroCorrTable[BARO_CORR_SIZE][BARO_CORR_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]
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]
float crankingTpsCoef[CRANKING_CURVE_SIZE]
scaled_channel< uint16_t, 100, 1 > mapEstimateTpsBins[MAP_EST_LOAD_COUNT]
float baroCorrRpmBins[BARO_CORR_SIZE]
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)