rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes
SpeedDensityAirmass Class Reference

#include <speed_density_airmass.h>

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

Public Member Functions

 SpeedDensityAirmass (const ValueProvider3D &veTable, const ValueProvider3D &mapEstimationTable)
 
AirmassResult getAirmass (float rpm, bool postState) override
 
AirmassResult getAirmass (float rpm, float map, bool postState)
 
float getAirflow (float rpm, float map, bool postState)
 
float getMap (float rpm, bool postState)
 
- Public Member Functions inherited from AirmassVeModelBase
 AirmassVeModelBase (const ValueProvider3D &veTable)
 
float getVe (float rpm, percent_t load, bool postState) const
 

Private Member Functions

float getPredictiveMap (float rpm, bool postState, float mapSensor)
 
float logAndGetFallback (float rpm, bool postState) const
 

Private Attributes

const ValueProvider3D *const m_mapEstimationTable
 
bool m_isMapPredictionActive = false
 
Timer m_predictionTimer
 
float m_initialPredictedMap = 0
 
float m_initialRealMap = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from SpeedDensityBase
static mass_t getAirmassImpl (float ve, float manifoldPressure, float temperature)
 
- Protected Member Functions inherited from SpeedDensityBase
 SpeedDensityBase (const ValueProvider3D &veTable)
 

Detailed Description

Definition at line 6 of file speed_density_airmass.h.

Constructor & Destructor Documentation

◆ SpeedDensityAirmass()

SpeedDensityAirmass::SpeedDensityAirmass ( const ValueProvider3D veTable,
const ValueProvider3D mapEstimationTable 
)
inlineexplicit

Definition at line 8 of file speed_density_airmass.h.

9 : SpeedDensityBase(veTable)
11 {}
const ValueProvider3D *const m_mapEstimationTable
static mapEstimate_Map3D_t mapEstimationTable
Definition fuel_math.cpp:38

Member Function Documentation

◆ getAirflow()

float SpeedDensityAirmass::getAirflow ( float  rpm,
float  map,
bool  postState 
)

Definition at line 41 of file speed_density_airmass.cpp.

41 {
42 auto airmassResult = getAirmass(rpm, map, postState);
43
44 float massPerCycle = airmassResult.CylinderAirmass * engineConfiguration->cylindersCount;
45
47 // 4 stroke engines only do a half cycle per rev
48 massPerCycle = massPerCycle / 2;
49 }
50
51 // g/s
52 return massPerCycle * rpm / 60;
53}
AirmassResult getAirmass(float rpm, bool postState) override
static constexpr engine_configuration_s * engineConfiguration

Referenced by getMaxAirflowAtMap().

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

◆ getAirmass() [1/2]

AirmassResult SpeedDensityAirmass::getAirmass ( float  rpm,
bool  postState 
)
overridevirtual

Implements AirmassModelBase.

Definition at line 6 of file speed_density_airmass.cpp.

6 {
8
9 auto map = getMap(rpm, postState);
10
11 return getAirmass(rpm, map, postState);
12}
float getMap(float rpm, bool postState)
@ GetSpeedDensityFuel

Referenced by getAirflow(), and getAirmass().

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

◆ getAirmass() [2/2]

AirmassResult SpeedDensityAirmass::getAirmass ( float  rpm,
float  map,
bool  postState 
)

most of the values are pre-calculated for performance reasons

Definition at line 14 of file speed_density_airmass.cpp.

14 {
15 /**
16 * most of the values are pre-calculated for performance reasons
17 */
18 float tChargeK = engine->engineState.sd.tChargeK;
19 if (std::isnan(tChargeK)) {
20 warning(ObdCode::CUSTOM_ERR_TCHARGE_NOT_READY2, "tChargeK not ready"); // this would happen before we have CLT reading for example
21 return {};
22 }
23
24 float ve = getVe(rpm, map, postState);
25
26 float airMass = getAirmassImpl(ve, map, tChargeK);
27 if (std::isnan(airMass)) {
28 warning(ObdCode::CUSTOM_ERR_6685, "NaN airMass");
29 return {};
30 }
31#if EFI_PRINTF_FUEL_DETAILS
32 printf("getSpeedDensityAirmass map=%.2f\n", map);
33#endif /*EFI_PRINTF_FUEL_DETAILS */
34
35 return {
36 airMass,
37 map, // AFR/VE table Y axis
38 };
39}
float getVe(float rpm, percent_t load, bool postState) const
Definition airmass.cpp:17
EngineState engineState
Definition engine.h:344
static mass_t getAirmassImpl(float ve, float manifoldPressure, float temperature)
static EngineAccessor engine
Definition engine.h:413
bool warning(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_TCHARGE_NOT_READY2
@ CUSTOM_ERR_6685
printf("\n")
Here is the call graph for this function:

◆ getMap()

float SpeedDensityAirmass::getMap ( float  rpm,
bool  postState 
)

Definition at line 114 of file speed_density_airmass.cpp.

114 {
115 auto mapSensor = Sensor::get(SensorType::Map);
116 if (mapSensor && engineConfiguration->accelEnrichmentMode == AE_MODE_PREDICTIVE_MAP) {
117 return getPredictiveMap(rpm, postState, mapSensor.Value);
118 }
119 return mapSensor.value_or(logAndGetFallback(rpm, postState));
120}
virtual SensorResult get() const =0
float logAndGetFallback(float rpm, bool postState) const
float getPredictiveMap(float rpm, bool postState, float mapSensor)

Referenced by getAirmass().

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

◆ getPredictiveMap()

float SpeedDensityAirmass::getPredictiveMap ( float  rpm,
bool  postState,
float  mapSensor 
)
private

Definition at line 55 of file speed_density_airmass.cpp.

55 {
56 float blendDuration = interpolate2d(rpm, config->predictiveMapBlendDurationBins,
58
59 float elapsedTime = m_predictionTimer.getElapsedSeconds();
60
61 if (m_isMapPredictionActive && elapsedTime >= blendDuration) {
62 // prediction phase is over
64 }
65
66 float effectiveMap = 0;
68 float blendFactor = elapsedTime / blendDuration;
69 // Linearly interpolate between the initial predicted and real values
71
72 if (mapSensor >= effectiveMap) {
74 }
75 } else {
77 float predictedMap = logAndGetFallback(rpm, postState);
78
79 if (predictedMap > mapSensor) {
81 engine->module<TpsAccelEnrichment>()->m_timeSinceAccel.reset();
82 m_predictionTimer.reset();
83 m_initialPredictedMap = predictedMap;
84 m_initialRealMap = mapSensor;
85 effectiveMap = predictedMap;
86 }
87 }
88 }
90
92 effectiveMap = mapSensor;
93 }
94
95#if EFI_TUNER_STUDIO
96 if (postState) {
98 }
99#endif // EFI_TUNER_STUDIO
100
101 return effectiveMap;
102}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
constexpr auto & module()
Definition engine.h:200
static constexpr persistent_config_s * config
effectiveMap("Effective MAP", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 374, 0.1, 0.0, 1000.0, "kPa")
scaled_channel< uint16_t, 10, 1 > effectiveMap
scaled_channel< uint8_t, 50, 1 > predictiveMapBlendDurationValues[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< uint8_t, 1, 50 > predictiveMapBlendDurationBins[TPS_TPS_ACCEL_CLT_CORR_TABLE]

Referenced by getMap().

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

◆ logAndGetFallback()

float SpeedDensityAirmass::logAndGetFallback ( float  rpm,
bool  postState 
) const
private

Definition at line 104 of file speed_density_airmass.cpp.

104 {
106#if EFI_TUNER_STUDIO
107 if (postState) {
109 }
110#endif // EFI_TUNER_STUDIO
111 return fallbackMap;
112}
static float getOrZero(SensorType type)
Definition sensor.h:83
virtual float getValue(float xColumn, float yRow) const =0
fallbackMap("fallbackMap", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 372, 0.1, 0.0, 1000.0, "kPa")
scaled_channel< uint16_t, 10, 1 > fallbackMap

Referenced by getMap(), and getPredictiveMap().

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

Field Documentation

◆ m_initialPredictedMap

float SpeedDensityAirmass::m_initialPredictedMap = 0
private

Definition at line 27 of file speed_density_airmass.h.

Referenced by getPredictiveMap().

◆ m_initialRealMap

float SpeedDensityAirmass::m_initialRealMap = 0
private

Definition at line 28 of file speed_density_airmass.h.

Referenced by getPredictiveMap().

◆ m_isMapPredictionActive

bool SpeedDensityAirmass::m_isMapPredictionActive = false
private

Definition at line 25 of file speed_density_airmass.h.

Referenced by getPredictiveMap().

◆ m_mapEstimationTable

const ValueProvider3D* const SpeedDensityAirmass::m_mapEstimationTable
private

Definition at line 22 of file speed_density_airmass.h.

Referenced by logAndGetFallback().

◆ m_predictionTimer

Timer SpeedDensityAirmass::m_predictionTimer
private

Definition at line 26 of file speed_density_airmass.h.

Referenced by getPredictiveMap().


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