rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions
MafAirmass Class Referencefinal

#include <maf_airmass.h>

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

Public Member Functions

 MafAirmass (const ValueProvider3D &veTable)
 
AirmassResult getAirmass (float rpm, bool postState) override
 
AirmassResult getAirmassImpl (float massAirFlow, float rpm, bool postState) const
 
- Public Member Functions inherited from AirmassVeModelBase
 AirmassVeModelBase (const ValueProvider3D &veTable)
 
float getVe (float rpm, percent_t load, bool postState) const
 

Private Member Functions

float getMaf () const
 

Detailed Description

Definition at line 5 of file maf_airmass.h.

Constructor & Destructor Documentation

◆ MafAirmass()

MafAirmass::MafAirmass ( const ValueProvider3D veTable)
inlineexplicit

Definition at line 7 of file maf_airmass.h.

Member Function Documentation

◆ getAirmass()

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

Implements AirmassModelBase.

Definition at line 31 of file maf_airmass.cpp.

31 {
32 float maf = getMaf();
33
34 return getAirmassImpl(maf, rpm, postState);
35}
float getMaf() const
AirmassResult getAirmassImpl(float massAirFlow, float rpm, bool postState) const
static FunctionalSensor maf(SensorType::Maf, MS2NT(50))
Here is the call graph for this function:

◆ getAirmassImpl()

AirmassResult MafAirmass::getAirmassImpl ( float  massAirFlow,
float  rpm,
bool  postState 
) const

Function block now works to create a standardised load from the cylinder filling as well as tune fuel via VE table.

Returns
total duration of fuel injection per engine cycle, in milliseconds

Definition at line 41 of file maf_airmass.cpp.

41 {
42 // If the engine is stopped, MAF is meaningless
43 if (rpm == 0) {
44 return {};
45 }
46
47 // kg/hr -> g/s
48 float gramPerSecond = massAirFlow * 1000 / 3600;
49
50 // 1/min -> 1/s
51 float revsPerSecond = rpm / 60.0f;
52 mass_t airPerRevolution = gramPerSecond / revsPerSecond;
53
54 // Now we have to divide among cylinders - on a 4 stroke, half of the cylinders happen every revolution
55 // This math is floating point to work properly on engines with odd cylinder count
56 float halfCylCount = engineConfiguration->cylindersCount / 2.0f;
57
58 mass_t cylinderAirmass = airPerRevolution / halfCylCount;
59
60 //Create % load for fuel table using relative naturally aspirated cylinder filling
61 float airChargeLoad = 100 * cylinderAirmass / getStandardAirCharge();
62
63 //Correct air mass by VE table
64 mass_t correctedAirmass = cylinderAirmass * getVe(rpm, airChargeLoad, postState);
65
66 return {
67 correctedAirmass,
68 airChargeLoad, // AFR/VE/ignition table Y axis
69 };
70}
float getVe(float rpm, percent_t load, bool postState) const
Definition airmass.cpp:17
static constexpr engine_configuration_s * engineConfiguration
float getStandardAirCharge()
float mass_t

Referenced by getAirmass().

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

◆ getMaf()

float MafAirmass::getMaf ( ) const
private

Definition at line 7 of file maf_airmass.cpp.

7 {
9
12
13 if (maf && maf2) {
14 // Both MAFs work, return the sum
15 return maf.Value + maf2.Value;
16 } else if (maf) {
17 // MAF 1 works, but not MAF 2, so double the value from #1
18 return 2 * maf.Value;
19 } else if (maf2) {
20 // MAF 2 works, but not MAF 1, so double the value from #2
21 return 2 * maf2.Value;
22 } else {
23 // Both MAFs are broken, give up.
24 return 0;
25 }
26 } else {
27 return maf.value_or(0);
28 }
29}
virtual bool hasSensor() const
Definition sensor.h:141
virtual SensorResult get() const =0
static FunctionalSensor maf2(SensorType::Maf2, MS2NT(50))

Referenced by getAirmass().

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

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