rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions
IFuelComputer Struct Referenceabstract

#include <fuel_computer.h>

Inheritance diagram for IFuelComputer:
Inheritance graph
[legend]
Collaboration diagram for IFuelComputer:
Collaboration graph
[legend]

Public Member Functions

virtual mass_t getCycleFuel (mass_t airmass, float rpm, float load)=0
 
temperature_t getTCharge (float rpm, float tps)
 
float getLoadOverride (float defaultLoad, load_override_e overrideMode) const
 

Private Member Functions

float getTChargeCoefficient (float rpm, float tps)
 

Additional Inherited Members

- Data Fields inherited from fuel_computer_s
float totalFuelCorrection = (float)0
 
running_fuel_s running
 
scaled_channel< uint16_t, 100, 1 > afrTableYAxis = (uint16_t)0
 
scaled_channel< uint16_t, 10000, 1 > targetLambda = (uint16_t)0
 
scaled_channel< uint16_t, 1000, 1 > targetAFR = (uint16_t)0
 
scaled_channel< uint16_t, 1000, 1 > stoichiometricRatio = (uint16_t)0
 
float sdTcharge_coff = (float)0
 
float sdAirMassInOneCylinder = (float)0
 
float normalizedCylinderFilling = (float)0
 
uint8_t brokenInjector = (uint8_t)0
 
uint8_t unused88 = (uint8_t)0
 
uint16_t idealEngineTorque = (uint16_t)0
 
bool injectorHwIssue: 1 {}
 
bool unusedBit_13_1: 1 {}
 
bool unusedBit_13_2: 1 {}
 
bool unusedBit_13_3: 1 {}
 
bool unusedBit_13_4: 1 {}
 
bool unusedBit_13_5: 1 {}
 
bool unusedBit_13_6: 1 {}
 
bool unusedBit_13_7: 1 {}
 
bool unusedBit_13_8: 1 {}
 
bool unusedBit_13_9: 1 {}
 
bool unusedBit_13_10: 1 {}
 
bool unusedBit_13_11: 1 {}
 
bool unusedBit_13_12: 1 {}
 
bool unusedBit_13_13: 1 {}
 
bool unusedBit_13_14: 1 {}
 
bool unusedBit_13_15: 1 {}
 
bool unusedBit_13_16: 1 {}
 
bool unusedBit_13_17: 1 {}
 
bool unusedBit_13_18: 1 {}
 
bool unusedBit_13_19: 1 {}
 
bool unusedBit_13_20: 1 {}
 
bool unusedBit_13_21: 1 {}
 
bool unusedBit_13_22: 1 {}
 
bool unusedBit_13_23: 1 {}
 
bool unusedBit_13_24: 1 {}
 
bool unusedBit_13_25: 1 {}
 
bool unusedBit_13_26: 1 {}
 
bool unusedBit_13_27: 1 {}
 
bool unusedBit_13_28: 1 {}
 
bool unusedBit_13_29: 1 {}
 
bool unusedBit_13_30: 1 {}
 
bool unusedBit_13_31: 1 {}
 

Detailed Description

Definition at line 12 of file fuel_computer.h.

Member Function Documentation

◆ getCycleFuel()

virtual mass_t IFuelComputer::getCycleFuel ( mass_t  airmass,
float  rpm,
float  load 
)
pure virtual

Implemented in FuelComputerBase.

◆ getLoadOverride()

float IFuelComputer::getLoadOverride ( float  defaultLoad,
load_override_e  overrideMode 
) const

Definition at line 86 of file fuel_computer.cpp.

86 {
87 switch(overrideMode) {
88 case AFR_None: return defaultLoad;
89 // MAP default to 200kpa - failed MAP goes rich
90 case AFR_MAP: return Sensor::get(SensorType::Map).value_or(200);
91 // TPS/pedal default to 100% - failed TPS goes rich
92 case AFR_Tps: return Sensor::get(SensorType::Tps1).value_or(100);
93 case AFR_AccPedal: return Sensor::get(SensorType::AcceleratorPedal).value_or(100);
94 case AFR_CylFilling: return normalizedCylinderFilling;
95 default: return 0;
96 }
97}
virtual SensorResult get() const =0

Referenced by getBaseFuelMass(), and FuelComputer::getTargetLambdaLoadAxis().

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

◆ getTCharge()

temperature_t IFuelComputer::getTCharge ( float  rpm,
float  tps 
)

Definition at line 65 of file speed_density.cpp.

65 {
66 const auto clt = Sensor::get(SensorType::Clt);
67 const auto iat = Sensor::get(SensorType::Iat);
68
69 float airTemp;
70
71 // Without either valid, return 0C. It's wrong, but it'll pretend to be nice and dense, so at least you won't go lean.
72 if (!iat && !clt) {
73 return 0;
74 } else if (!clt && iat) {
75 // Intake temperature will almost always be colder (richer) than CLT - use that
76 return iat.Value;
77 } else if (!iat && clt) {
78 // Without valid intake temperature, assume intake temp is 0C, and interpolate anyway
79 airTemp = 0;
80 } else {
81 // All is well - use real air temp
82 airTemp = iat.Value;
83 }
84
85 float coolantTemp = clt.Value;
86
88
89 if (std::isnan(sdTcharge_coff)) {
90 warning(ObdCode::CUSTOM_ERR_T2_CHARGE, "t2-getTCharge NaN");
91 return coolantTemp;
92 }
93
94 // Interpolate between CLT and IAT:
95 // 0.0 coefficient -> use CLT (full heat transfer)
96 // 1.0 coefficient -> use IAT (no heat transfer)
97 float Tcharge = interpolateClamped(0.0f, coolantTemp, 1.0f, airTemp, sdTcharge_coff);
98
99 if (std::isnan(Tcharge)) {
100 // we can probably end up here while resetting engine state - interpolation would fail
102 return coolantTemp;
103 }
104
105 return Tcharge;
106}
float interpolateClamped(float x1, float y1, float x2, float y2, float x)
bool warning(ObdCode code, const char *fmt,...)
static CCM_OPTIONAL FunctionalSensor iat(SensorType::Iat, MS2NT(10))
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
@ CUSTOM_ERR_TCHARGE_NOT_READY
@ CUSTOM_ERR_T2_CHARGE
float getTChargeCoefficient(float rpm, float tps)

Referenced by EngineState::updateTChargeK().

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

◆ getTChargeCoefficient()

float IFuelComputer::getTChargeCoefficient ( float  rpm,
float  tps 
)
private

Definition at line 24 of file speed_density.cpp.

24 {
25 // First, do TPS mode since it doesn't need any of the airflow math.
26 if (engineConfiguration->tChargeMode == TCHARGE_MODE_RPM_TPS) {
27 float minRpmKcurrentTPS = interpolateMsg("minRpm", tpMin,
30 float maxRpmKcurrentTPS = interpolateMsg("maxRpm", tpMin,
33
34 return interpolateMsg("Kcurr", rpmMin, minRpmKcurrentTPS, rpmMax, maxRpmKcurrentTPS, rpm);
35 }
36
37 constexpr floatms_t gramsPerMsToKgPerHour = (3600.0f * 1000.0f) / 1000.0f;
38 // We're actually using an 'old' airMass calculated for the previous cycle, but it's ok, we're not having any self-excitaton issues
40 // airMass is in grams per 1 cycle for 1 cyl. Convert it to airFlow in kg/h for the engine.
41 // And if the engine is stopped (0 rpm), then airFlow is also zero (avoiding NaN division)
42 floatms_t airFlow = (rpm == 0) ? 0 : airMassForEngine * gramsPerMsToKgPerHour / getEngineCycleDuration(rpm);
43
44 if (engineConfiguration->tChargeMode == TCHARGE_MODE_AIR_INTERP) {
45 // just interpolate between user-specified min and max coefs, based on the max airFlow value
46 return interpolateClamped(
49 airFlow
50 );
51 } else if (engineConfiguration->tChargeMode == TCHARGE_MODE_AIR_INTERP_TABLE) {
52 return interpolate2d(
53 airFlow,
56 );
57 } else {
58 criticalError("Unexpected tChargeMode: %d", engineConfiguration->tChargeMode);
59 return 0;
60 }
61}
float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x)
Linear interpolation by two points.
static constexpr engine_configuration_s * engineConfiguration
floatms_t getEngineCycleDuration(float rpm)
float floatms_t

Referenced by getTCharge().

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

The documentation for this struct was generated from the following files: