rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
fuel_math.cpp File Reference

Detailed Description

Fuel amount calculation logic.

Date
May 27, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file fuel_math.cpp.

Functions

float getCrankingFuel3 (float baseFuel, uint32_t revolutionCounterSinceStart)
 
float getRunningFuel (float baseFuel)
 
AirmassModelBasegetAirmassModel (engine_load_mode_e mode)
 
float getMaxAirflowAtMap (float map)
 
static float getBaseFuelMass (float rpm)
 
angle_t getInjectionOffset (float rpm, float load)
 
int getNumberOfInjections (injection_mode_e mode)
 
float getInjectionModeDurationMultiplier ()
 
percent_t getInjectorDutyCycle (float rpm)
 
percent_t getInjectorDutyCycleStage2 (float rpm)
 
float getCycleFuelMass (bool isCranking, float baseFuelMass)
 
float getInjectionMass (float rpm)
 
void initFuelMap ()
 Initialize fuel map data structure.
 
float getCltFuelCorrection ()
 Engine warm-up fuel correction.
 
float getIatFuelCorrection ()
 
float getPostCrankingFuelCorrection ()
 
float getBaroCorrection ()
 
percent_t getFuelALSCorrection (float rpm)
 
float getCrankingFuel (float baseFuel)
 
float getStandardAirCharge ()
 
PUBLIC_API_WEAK_SOMETHING_WEIRD float getCylinderFuelTrim (size_t cylinderNumber, float rpm, float fuelLoad)
 
float getStage2InjectionFraction (float rpm, float load)
 

Variables

ve_Map3D_t veMap
 
static mapEstimate_Map3D_t mapEstimationTable {"mape"}
 
static SpeedDensityAirmass sdAirmass (veMap, mapEstimationTable)
 
static MafAirmass mafAirmass (veMap)
 
static AlphaNAirmass alphaNAirmass (veMap)
 
static Hysteresis stage2Hysteresis
 

Function Documentation

◆ getAirmassModel()

AirmassModelBase * getAirmassModel ( engine_load_mode_e  mode)

Definition at line 152 of file fuel_math.cpp.

152 {
153 switch (mode) {
154 case LM_SPEED_DENSITY: return &sdAirmass;
155 case LM_REAL_MAF: return &mafAirmass;
156 case LM_ALPHA_N: return &alphaNAirmass;
157#if EFI_LUA
158 case LM_LUA: return &(getLuaAirmassModel());
159#endif
160#if EFI_UNIT_TEST
161 case LM_MOCK: return engine->mockAirmassModel;
162#endif
163 default:
165 return nullptr;
166 }
167}
AirmassModelBase * mockAirmassModel
Definition engine.h:367
static Engine *const engine
Definition engine.h:388
static constexpr engine_configuration_s * engineConfiguration
void firmwareError(ObdCode code, const char *fmt,...)
static SpeedDensityAirmass sdAirmass(veMap, mapEstimationTable)
static MafAirmass mafAirmass(veMap)
static AlphaNAirmass alphaNAirmass(veMap)
AirmassModelBase & getLuaAirmassModel()
@ CUSTOM_ERR_ASSERT

Referenced by getBaseFuelMass(), and lua_getAirmass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBaroCorrection()

float getBaroCorrection ( )

Definition at line 401 of file fuel_math.cpp.

401 {
403 // Default to 1atm if failed
404 float pressure = Sensor::get(SensorType::BarometricPressure).value_or(STD_ATMOSPHERE);
405
406 float correction = interpolate3d(
408 config->baroCorrPressureBins, pressure,
410 );
411
412 if (std::isnan(correction) || correction < 0.01) {
413 warning(ObdCode::OBD_Barometric_Press_Circ_Range_Perf, "Invalid baro correction %f", correction);
414 return 1;
415 }
416
417 return correction;
418 } else {
419 return 1;
420 }
421}
virtual bool hasSensor() const
Definition sensor.h:141
virtual SensorResult get() const =0
static float getOrZero(SensorType type)
Definition sensor.h:83
static constexpr persistent_config_s * config
bool warning(ObdCode code, const char *fmt,...)
@ OBD_Barometric_Press_Circ_Range_Perf
@ BarometricPressure

Referenced by EngineState::periodicFastCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBaseFuelMass()

static float getBaseFuelMass ( float  rpm)
static

Definition at line 176 of file fuel_math.cpp.

176 {
178
179 // airmass modes - get airmass first, then convert to fuel
181 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, model != nullptr, "Invalid airmass mode", 0.0f);
182
183 auto airmass = model->getAirmass(rpm, true);
184
185 // Plop some state for others to read
186 float normalizedCylinderFilling = 100 * airmass.CylinderAirmass / getStandardAirCharge();
187 engine->fuelComputer.sdAirMassInOneCylinder = airmass.CylinderAirmass;
189 engine->engineState.fuelingLoad = airmass.EngineLoadPercent;
191
192 auto gramPerCycle = airmass.CylinderAirmass * engineConfiguration->cylindersCount;
193 auto gramPerMs = rpm == 0 ? 0 : gramPerCycle / getEngineCycleDuration(rpm);
194
195 // convert g/s -> kg/h
196 engine->engineState.airflowEstimate = gramPerMs * 3600000 /* milliseconds per hour */ / 1000 /* grams per kg */;
197
198 float baseFuelMass = engine->fuelComputer.getCycleFuel(airmass.CylinderAirmass, rpm, airmass.EngineLoadPercent);
199
200 engine->engineState.baseFuel = baseFuelMass;
201
202 if (std::isnan(baseFuelMass)) {
203 // todo: we should not have this here but https://github.com/rusefi/rusefi/issues/1690
204 return 0;
205 }
206
207 return baseFuelMass;
208}
FuelComputer fuelComputer
Definition engine.h:131
EngineState engineState
Definition engine.h:329
floatms_t baseFuel
float airflowEstimate
mass_t getCycleFuel(mass_t airmass, float rpm, float load) override
floatms_t getEngineCycleDuration(float rpm)
AirmassModelBase * getAirmassModel(engine_load_mode_e mode)
float getStandardAirCharge()
@ GetBaseFuel
normalizedCylinderFilling("Air: Normalized cyl filling", SensorCategory.SENSOR_INPUTS, FieldType.INT, 904, 1.0, 0.0, 100.0, "%")
float getLoadOverride(float defaultLoad, load_override_e overrideMode) const

Referenced by getInjectionMass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCltFuelCorrection()

float getCltFuelCorrection ( )

Engine warm-up fuel correction.

Definition at line 358 of file fuel_math.cpp.

358 {
359 const auto clt = Sensor::get(SensorType::Clt);
360
361 if (!clt)
362 return 1; // this error should be already reported somewhere else, let's just handle it
363
364 return interpolate2d(clt.Value, config->cltFuelCorrBins, config->cltFuelCorr);
365}
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))

Referenced by EngineState::periodicFastCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCrankingFuel()

float getCrankingFuel ( float  baseFuel)
Returns
Duration of fuel injection while craning

Definition at line 444 of file fuel_math.cpp.

444 {
446}
RpmCalculator rpmCalculator
Definition engine.h:291
uint32_t getRevolutionCounterSinceStart(void) const
float getCrankingFuel3(float baseFuel, uint32_t revolutionCounterSinceStart)
Definition fuel_math.cpp:42

Referenced by getCycleFuelMass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCrankingFuel3()

float getCrankingFuel3 ( float  baseFuel,
uint32_t  revolutionCounterSinceStart 
)

Cranking fuel is different depending on engine coolant temperature If the sensor is failed, use 20 deg C

Definition at line 42 of file fuel_math.cpp.

42 {
43
44 float baseCrankingFuel;
46 baseCrankingFuel = baseFuel;
47 } else {
48 // Cranking fuel changes over time
49 baseCrankingFuel = interpolate3d(
53 ) * 0.001f; // parameter is in milligrams, convert to grams
54 }
55
56 engine->engineState.crankingFuel.baseFuel = baseCrankingFuel * 1000; // convert to mg
57
58 /**
59 * Cranking fuel is different depending on engine coolant temperature
60 * If the sensor is failed, use 20 deg C
61 */
62 auto clt = Sensor::get(SensorType::Clt).value_or(20);
63 auto e0Mult = interpolate2d(clt, config->crankingFuelBins, config->crankingFuelCoef);
64
65 bool alreadyWarned = false;
66 if (e0Mult <= 0.1f) {
67 warning(ObdCode::CUSTOM_ERR_ZERO_E0_MULT, "zero e0 multiplier");
68 alreadyWarned = true;
69 }
70
72 auto e85Mult = interpolate2d(clt, config->crankingFuelBins, config->crankingFuelCoefE100);
73
74 if (e85Mult <= 0.1f) {
75 warning(ObdCode::CUSTOM_ERR_ZERO_E85_MULT, "zero e85 multiplier");
76 alreadyWarned = true;
77 }
78
79 // If failed flex sensor, default to 50% E
80 auto flex = Sensor::get(SensorType::FuelEthanolPercent).value_or(50);
81
84 0, e0Mult,
85 85, e85Mult,
86 flex
87 );
88 } else {
90 }
91
94 tps.Valid
95 ? interpolate2d(tps.Value, config->crankingTpsBins, config->crankingTpsCoef)
96 : 1; // in case of failed TPS, don't correct.
97
98 floatms_t crankingFuel = baseCrankingFuel
101
103
104 // don't re-warn for zero fuel when we already warned for a more specific problem
105 if (!alreadyWarned && crankingFuel <= 0) {
107 }
108 return crankingFuel;
109}
float interpolateClamped(float x1, float y1, float x2, float y2, float x)
@ CUSTOM_ERR_ZERO_E85_MULT
@ CUSTOM_ERR_ZERO_CRANKING_FUEL
@ CUSTOM_ERR_ZERO_E0_MULT
float floatms_t
@ FuelEthanolPercent
@ DriverThrottleIntent
revolutionCounterSinceStart("revolutionCounterSinceStart", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 56, 1.0, 0.0, 0.0, "")
crankingFuel("crankingFuel", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1316, 1.0, -1.0, -1.0, "")
scaled_channel< uint16_t, 100, 1 > baseFuel
scaled_channel< uint16_t, 100, 1 > fuel
cranking_fuel_s crankingFuel
float crankingCycleBaseFuel[CRANKING_CYCLE_CLT_SIZE][CRANKING_CURVE_SIZE]
scaled_channel< uint16_t, 100, 1 > crankingFuelCoefE100[CRANKING_CURVE_SIZE]

Referenced by getCrankingFuel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCycleFuelMass()

float getCycleFuelMass ( bool  isCranking,
float  baseFuelMass 
)

Definition at line 293 of file fuel_math.cpp.

293 {
294 if (isCranking) {
295 return getCrankingFuel(baseFuelMass);
296 } else {
297 return getRunningFuel(baseFuelMass);
298 }
299}
float getRunningFuel(float baseFuel)
float getCrankingFuel(float baseFuel)

Referenced by getInjectionMass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCylinderFuelTrim()

PUBLIC_API_WEAK_SOMETHING_WEIRD float getCylinderFuelTrim ( size_t  cylinderNumber,
float  rpm,
float  fuelLoad 
)

Definition at line 463 of file fuel_math.cpp.

463 {
464 auto trimPercent = interpolate3d(
465 config->fuelTrims[cylinderNumber].table,
466 config->fuelTrimLoadBins, fuelLoad,
468 );
469
470 // Convert from percent +- to multiplier
471 // 5% -> 1.05
472 // possible optimization: remove division by moving this scaling to TS level
473 return (100 + trimPercent) / 100;
474}
scaled_channel< int8_t, 5, 1 > table[FUEL_TRIM_SIZE][FUEL_TRIM_SIZE]

Referenced by EngineState::periodicFastCallback().

Here is the caller graph for this function:

◆ getFuelALSCorrection()

percent_t getFuelALSCorrection ( float  rpm)

Definition at line 423 of file fuel_math.cpp.

423 {
424#if EFI_ANTILAG_SYSTEM
427 auto AlsFuelAdd = interpolate3d(
429 config->alsFuelAdjustmentLoadBins, throttleIntent,
431 );
432 return AlsFuelAdd;
433 } else
434#endif /* EFI_ANTILAG_SYSTEM */
435 {
436 return 0;
437 }
438}
AntilagSystemBase antilagController
Definition engine.h:213
scaled_channel< int16_t, 10, 1 > ALSFuelAdjustment[ALS_SIZE][ALS_SIZE]

Referenced by AntilagSystemBase::update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIatFuelCorrection()

float getIatFuelCorrection ( )

Definition at line 367 of file fuel_math.cpp.

367 {
368 const auto iat = Sensor::get(SensorType::Iat);
369
370 if (!iat)
371 return 1; // this error should be already reported somewhere else, let's just handle it
372
373 return interpolate2d(iat.Value, config->iatFuelCorrBins, config->iatFuelCorr);
374}
static CCM_OPTIONAL FunctionalSensor iat(SensorType::Iat, MS2NT(10))

Referenced by EngineState::periodicFastCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInjectionMass()

float getInjectionMass ( float  rpm)
Returns
Mass of each individual fuel injection, in grams in case of single point injection mode the amount of fuel into all cylinders, otherwise the amount for one cylinder

Definition at line 305 of file fuel_math.cpp.

305 {
307
308 // Always update base fuel - some cranking modes use it
309 float baseFuelMass = getBaseFuelMass(rpm);
310
311 bool isCranking = engine->rpmCalculator.isCranking();
312 float cycleFuelMass = getCycleFuelMass(isCranking, baseFuelMass);
313 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(cycleFuelMass), "NaN cycleFuelMass", 0);
314
315 if (engine->module<DfcoController>()->cutFuel()) {
316 // If decel fuel cut, zero out fuel
317 cycleFuelMass = 0;
318 }
319
320 float durationMultiplier = getInjectionModeDurationMultiplier();
321 float injectionFuelMass = cycleFuelMass * durationMultiplier;
322
323 // Prepare injector flow rate & deadtime
324 engine->module<InjectorModelPrimary>()->prepare();
325
327 engine->module<InjectorModelSecondary>()->prepare();
328 }
329
330 float tpsAccelEnrich = engine->module<TpsAccelEnrichment>()->getTpsEnrichment();
331 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(tpsAccelEnrich), "NaN tpsAccelEnrich", 0);
332 engine->engineState.tpsAccelEnrich = tpsAccelEnrich;
333
334 float tpsAccelPerInjection = durationMultiplier * tpsAccelEnrich;
335
337 return injectionFuelMass * (1 + tpsAccelPerInjection);
338 } else {
339 // For legacy reasons, the TPS accel table is in units of milliseconds, so we have to convert BACK to mass
340 float tpsFuelMass = engine->module<InjectorModelPrimary>()->getFuelMassForDuration(tpsAccelPerInjection);
341 return injectionFuelMass + tpsFuelMass;
342 }
343}
bool cutFuel() const
Definition dfco.cpp:75
constexpr auto & module()
Definition engine.h:190
floatms_t tpsAccelEnrich
bool isCranking() const override
static float getBaseFuelMass(float rpm)
float getCycleFuelMass(bool isCranking, float baseFuelMass)
float getInjectionModeDurationMultiplier()
@ GetInjectionDuration

Referenced by EngineState::periodicFastCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInjectionModeDurationMultiplier()

float getInjectionModeDurationMultiplier ( )

Definition at line 256 of file fuel_math.cpp.

256 {
258
259 switch (mode) {
260 case IM_SIMULTANEOUS: {
261 auto cylCount = engineConfiguration->cylindersCount;
262
263 if (cylCount == 0) {
264 // we can end up here during configuration reset
265 return 0;
266 }
267
268 return 1.0f / cylCount;
269 }
270 case IM_SEQUENTIAL:
271 case IM_SINGLE_POINT:
272 return 1;
273 case IM_BATCH:
274 return 0.5f;
275 default:
276 firmwareError(ObdCode::CUSTOM_ERR_INVALID_INJECTION_MODE, "Unexpected injection_mode_e %d", mode);
277 return 0;
278 }
279}
injection_mode_e getCurrentInjectionMode()
Definition engine.cpp:538
@ CUSTOM_ERR_INVALID_INJECTION_MODE
injection_mode_e

Referenced by getInjectionMass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInjectionOffset()

angle_t getInjectionOffset ( float  rpm,
float  load 
)

Definition at line 210 of file fuel_math.cpp.

210 {
211 if (std::isnan(rpm)) {
212 return 0; // error already reported
213 }
214
215 if (std::isnan(load)) {
216 return 0; // error already reported
217 }
218
219 angle_t value = interpolate3d(
223 );
224
225 if (std::isnan(value)) {
226 // we could be here while resetting configuration for example
227 // huh? what? when do we have RPM while resetting configuration? is that CI edge case? shall we fix CI?
228 warning(ObdCode::CUSTOM_ERR_6569, "phase map not ready");
229 return 0;
230 }
231
232 angle_t result = value;
233 wrapAngle(result, "inj offset#2", ObdCode::CUSTOM_ERR_6553);
234 return result;
235}
@ CUSTOM_ERR_6553
@ CUSTOM_ERR_6569
float angle_t
int16_t injectionPhase[INJ_PHASE_LOAD_COUNT][INJ_PHASE_RPM_COUNT]
void wrapAngle(angle_t &angle, const char *msg, ObdCode code)

Referenced by EngineState::periodicFastCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInjectorDutyCycle()

percent_t getInjectorDutyCycle ( float  rpm)

Definition at line 281 of file fuel_math.cpp.

281 {
283 floatms_t engineCycleDuration = getEngineCycleDuration(rpm);
284 return 100 * totalInjectiorAmountPerCycle / engineCycleDuration;
285}
floatms_t injectionDuration
int getNumberOfInjections(injection_mode_e mode)

Referenced by canDashboardHaltech(), EngineState::periodicFastCallback(), populateFrame(), LimpManager::updateState(), and updateTunerStudioState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInjectorDutyCycleStage2()

percent_t getInjectorDutyCycleStage2 ( float  rpm)

Definition at line 287 of file fuel_math.cpp.

287 {
289 floatms_t engineCycleDuration = getEngineCycleDuration(rpm);
290 return 100 * totalInjectiorAmountPerCycle / engineCycleDuration;
291}
floatms_t injectionDurationStage2

Referenced by updateTunerStudioState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMaxAirflowAtMap()

float getMaxAirflowAtMap ( float  map)

Definition at line 169 of file fuel_math.cpp.

169 {
171}
float getAirflow(float rpm, float map, bool postState)

Referenced by ThrottleModel::maxEngineFlow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNumberOfInjections()

int getNumberOfInjections ( injection_mode_e  mode)

Number of injections using each injector per engine cycle

See also
getNumberOfSparks

Definition at line 241 of file fuel_math.cpp.

241 {
242 switch (mode) {
243 case IM_SIMULTANEOUS:
244 case IM_SINGLE_POINT:
246 case IM_BATCH:
247 return 2;
248 case IM_SEQUENTIAL:
249 return 1;
250 default:
251 firmwareError(ObdCode::CUSTOM_ERR_INVALID_INJECTION_MODE, "Unexpected injection_mode_e %d", mode);
252 return 1;
253 }
254}

Referenced by getInjectorDutyCycle(), getInjectorDutyCycleStage2(), and InjectionEvent::onTriggerTooth().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPostCrankingFuelCorrection()

float getPostCrankingFuelCorrection ( )

Definition at line 376 of file fuel_math.cpp.

376 {
377 const auto revolutionCounter = engine->rpmCalculator.getRevolutionCounterSinceStart();
378 // if the engine run time is past the last bin, disable ASE in case the table is filled with values more than 1.0, helps with compatibility
379 if (revolutionCounter > config->postCrankingDurationBins[efi::size(config->postCrankingDurationBins) - 1])
380 return 1;
381
382 // TODO:
383 //const auto clt = Sensor::get(SensorType::Clt);
384 //if (!clt)
385 // return 1; // this error should be already reported somewhere else, let's just handle it
386
387 // post-cranking fuel enrichment.
388 float postCrankingFactor = interpolate3d(
391 config->postCrankingDurationBins, revolutionCounter
392 );
393
394 // for compatibility reasons, apply only if the factor is greater than unity (only allow adding fuel)
395 if (postCrankingFactor < 1.0f)
396 postCrankingFactor = 1.0f;
397
398 return postCrankingFactor;
399}
float postCrankingFactor[CRANKING_ENRICH_CLT_COUNT][CRANKING_ENRICH_COUNT]

Referenced by EngineState::periodicFastCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRunningFuel()

float getRunningFuel ( float  baseFuel)
Returns
baseFuel with CLT and IAT corrections

Definition at line 111 of file fuel_math.cpp.

111 {
113
116 float postCrankingFuelCorrection = engine->fuelComputer.running.postCrankingFuelCorrection;
118
119 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(iatCorrection), "NaN iatCorrection", 0);
120 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(cltCorrection), "NaN cltCorrection", 0);
121 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(postCrankingFuelCorrection), "NaN postCrankingFuelCorrection", 0);
122
123 float correction = baroCorrection * iatCorrection * cltCorrection * postCrankingFuelCorrection;
124
125#if EFI_ANTILAG_SYSTEM
126 correction *= (1 + engine->antilagController.fuelALSCorrection / 100);
127#endif /* EFI_ANTILAG_SYSTEM */
128
129#if EFI_LAUNCH_CONTROL
131 correction *= engine->module<NitrousController>().unmock().getFuelCoefficient();
132#endif
133
134 correction *= getLimpManager()->getLimitingFuelCorrection();
135
136 float runningFuel = baseFuel * correction;
137
138 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(runningFuel), "NaN runningFuel", 0);
139
140 // Publish output state
141 engine->fuelComputer.running.baseFuel = baseFuel * 1000;
143 engine->fuelComputer.running.fuel = runningFuel * 1000;
144
145 return runningFuel;
146}
LaunchControlBase launchController
Definition engine.h:205
float getFuelCoefficient() const
float getLimitingFuelCorrection() const
float getFuelCoefficient() const
LimpManager * getLimpManager()
Definition engine.cpp:582
@ GetRunningFuel
baroCorrection("Fuel: Barometric pressure mult", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1328, 1.0, -1.0, -1.0, "")
scaled_channel< uint16_t, 100, 1 > baseFuel
scaled_channel< uint16_t, 100, 1 > fuel

Referenced by getCycleFuelMass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStage2InjectionFraction()

float getStage2InjectionFraction ( float  rpm,
float  load 
)

Definition at line 478 of file fuel_math.cpp.

478 {
480 return 0;
481 }
482
483 float frac = 0.01f * interpolate3d(
487 );
488
489 // don't allow very small fraction, with some hysteresis
490 if (!stage2Hysteresis.test(frac, 0.1, 0.03)) {
491 return 0;
492 }
493
494 // Clamp to 90%
495 if (frac > 0.9) {
496 frac = 0.9;
497 }
498
499 return frac;
500}
bool test(float value, float rising, float falling)
Definition hysteresis.h:31
static Hysteresis stage2Hysteresis
uint8_t injectorStagingTable[INJ_STAGING_COUNT][INJ_STAGING_COUNT]

Referenced by EngineState::periodicFastCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStandardAirCharge()

float getStandardAirCharge ( )

Standard cylinder air charge - 100% VE at standard temperature, grams per cylinder

Should we bother caching 'getStandardAirCharge' result or can we afford to run the math every time we calculate fuel?

Definition at line 453 of file fuel_math.cpp.

453 {
454 float totalDisplacement = engineConfiguration->displacement;
455 float cylDisplacement = totalDisplacement / engineConfiguration->cylindersCount;
456
457 // Calculation of 100% VE air mass in g/cyl - 1 cylinder filling at 1.204/L
458 // 101.325kpa, 20C
459 return idealGasLaw(cylDisplacement, STD_ATMOSPHERE, C_K_OFFSET + STD_IAT);
460}
mass_t idealGasLaw(float volume, float pressure, float temperature)

Referenced by MafAirmass::getAirmassImpl(), and getBaseFuelMass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initFuelMap()

void initFuelMap ( )

Initialize fuel map data structure.

Note
this method has nothing to do with fuel map VALUES - it's job is to prepare the fuel map data structure for 3d interpolation

Definition at line 351 of file fuel_math.cpp.

351 {
353}
void initTable(TValueInit(&table)[TRowNum][TColNum], const TXColumnInit(&columnBins)[TColNum], const TRowInit(&rowBins)[TRowNum])
static mapEstimate_Map3D_t mapEstimationTable
Definition fuel_math.cpp:38
scaled_channel< uint16_t, 100, 1 > mapEstimateTpsBins[MAP_EST_LOAD_COUNT]
scaled_channel< uint16_t, 100, 1 > mapEstimateTable[MAP_EST_LOAD_COUNT][MAP_EST_RPM_COUNT]

Referenced by initDataStructures().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ alphaNAirmass

AlphaNAirmass alphaNAirmass(veMap) ( veMap  )
static

Referenced by getAirmassModel().

◆ mafAirmass

MafAirmass mafAirmass(veMap) ( veMap  )
static

Referenced by getAirmassModel().

◆ mapEstimationTable

mapEstimate_Map3D_t mapEstimationTable {"mape"}
static

Definition at line 38 of file fuel_math.cpp.

38{"mape"};

Referenced by initFuelMap().

◆ sdAirmass

◆ stage2Hysteresis

Hysteresis stage2Hysteresis
static

Definition at line 476 of file fuel_math.cpp.

Referenced by getStage2InjectionFraction().

◆ veMap

ve_Map3D_t veMap
extern

Definition at line 19 of file speed_density.cpp.

19{"ve"};

Referenced by initSpeedDensity().

Go to the source code of this file.