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

#include <lambda_monitor.h>

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

Public Member Functions

void update (float rpm, float load)
 
bool isCut () const
 

Protected Member Functions

bool shouldCheckLambda (float rpm, float load) const
 
virtual bool isCurrentlyGood (float rpm, float load) const
 
virtual float getMaxAllowedLambda (float rpm, float load) const =0
 
virtual float getTimeout () const =0
 
virtual bool restoreConditionsMet (float rpm, float load) const
 

Private Attributes

Timer m_timeSinceGoodLambda
 

Additional Inherited Members

- Data Fields inherited from lambda_monitor_s
bool lambdaCurrentlyGood: 1 {}
 
bool lambdaMonitorCut: 1 {}
 
bool unusedBit_2_2: 1 {}
 
bool unusedBit_2_3: 1 {}
 
bool unusedBit_2_4: 1 {}
 
bool unusedBit_2_5: 1 {}
 
bool unusedBit_2_6: 1 {}
 
bool unusedBit_2_7: 1 {}
 
bool unusedBit_2_8: 1 {}
 
bool unusedBit_2_9: 1 {}
 
bool unusedBit_2_10: 1 {}
 
bool unusedBit_2_11: 1 {}
 
bool unusedBit_2_12: 1 {}
 
bool unusedBit_2_13: 1 {}
 
bool unusedBit_2_14: 1 {}
 
bool unusedBit_2_15: 1 {}
 
bool unusedBit_2_16: 1 {}
 
bool unusedBit_2_17: 1 {}
 
bool unusedBit_2_18: 1 {}
 
bool unusedBit_2_19: 1 {}
 
bool unusedBit_2_20: 1 {}
 
bool unusedBit_2_21: 1 {}
 
bool unusedBit_2_22: 1 {}
 
bool unusedBit_2_23: 1 {}
 
bool unusedBit_2_24: 1 {}
 
bool unusedBit_2_25: 1 {}
 
bool unusedBit_2_26: 1 {}
 
bool unusedBit_2_27: 1 {}
 
bool unusedBit_2_28: 1 {}
 
bool unusedBit_2_29: 1 {}
 
bool unusedBit_2_30: 1 {}
 
bool unusedBit_2_31: 1 {}
 
scaled_channel< uint16_t, 100, 1 > lambdaTimeSinceGood = (uint16_t)0
 
uint8_t alignmentFill_at_6 [2] = {}
 

Detailed Description

Definition at line 5 of file lambda_monitor.h.

Member Function Documentation

◆ getMaxAllowedLambda()

virtual float LambdaMonitorBase::getMaxAllowedLambda ( float  rpm,
float  load 
) const
protectedpure virtual

Implemented in LambdaMonitor.

Referenced by isCurrentlyGood().

Here is the caller graph for this function:

◆ getTimeout()

virtual float LambdaMonitorBase::getTimeout ( ) const
protectedpure virtual

Implemented in LambdaMonitor.

Referenced by update().

Here is the caller graph for this function:

◆ isCurrentlyGood()

bool LambdaMonitorBase::isCurrentlyGood ( float  rpm,
float  load 
) const
protectedvirtual

Definition at line 48 of file lambda_monitor.cpp.

48 {
49 // Lambda is always good if disabled
51 return true;
52 }
53
54 // Below min RPM, don't check
55 if (rpm < engineConfiguration->lambdaProtectionMinRpm) {
56 return true;
57 }
58
59 // Below min load, don't check
60 if (load < engineConfiguration->lambdaProtectionMinLoad) {
61 return true;
62 }
63
64 // Below min TPS, don't check
66 return true;
67 }
68
69 // Pause checking if DFCO was active recently
70 auto timeSinceDfco = engine->module<DfcoController>()->getTimeSinceCut();
71 if (timeSinceDfco < engineConfiguration->noFuelTrimAfterDfcoTime) {
72 return true;
73 }
74
75 // Pause checking if some other cut was active recently
76 auto timeSinceFuelCut = engine->module<LimpManager>()->getTimeSinceAnyCut();
77 // TODO: should this duration be configurable?
78 if (timeSinceFuelCut < 2) {
79 return true;
80 }
81
82 // TODO: multiple banks
83 if (auto lambda = Sensor::get(SensorType::Lambda1)) {
84 if (lambda.Value < getMaxAllowedLambda(rpm, load)) {
85 // Lambda is OK, we're good.
86 return true;
87 }
88 } else {
89 // Broken lambda sensor doesn't imply bad lambda
90
91 // TODO: can/should we be smarter here?
92 return true;
93 }
94
95 // All checks failed, lambda is currently bad.
96 return false;
97}
constexpr auto & module()
Definition engine.h:200
virtual SensorResult get() const =0
static float getOrZero(SensorType type)
Definition sensor.h:83
static EngineAccessor engine
Definition engine.h:413
static constexpr engine_configuration_s * engineConfiguration
virtual float getMaxAllowedLambda(float rpm, float load) const =0

Referenced by update().

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

◆ isCut()

bool LambdaMonitorBase::isCut ( ) const

Definition at line 21 of file lambda_monitor.cpp.

21 {
22 return lambdaMonitorCut;
23}

Referenced by populateFrame(), and LimpManager::updateState().

Here is the caller graph for this function:

◆ restoreConditionsMet()

bool LambdaMonitorBase::restoreConditionsMet ( float  rpm,
float  load 
) const
protectedvirtual

Definition at line 99 of file lambda_monitor.cpp.

99 {
101 return false;
102 }
103
105 return false;
106 }
107
109 return false;
110 }
111
112 return true;
113}

Referenced by update().

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

◆ shouldCheckLambda()

bool LambdaMonitorBase::shouldCheckLambda ( float  rpm,
float  load 
) const
protected

◆ update()

void LambdaMonitorBase::update ( float  rpm,
float  load 
)

Definition at line 25 of file lambda_monitor.cpp.

25 {
26 bool isGood = isCurrentlyGood(rpm, load);
27 lambdaCurrentlyGood = isGood;
28 if (isGood) {
30 }
31
32 lambdaTimeSinceGood = m_timeSinceGoodLambda.getElapsedSeconds();
33
34 if (m_timeSinceGoodLambda.hasElapsedSec(getTimeout())) {
35 // Things have been bad long enough, cut!
36 lambdaMonitorCut = true;
37 }
38
39 if (lambdaMonitorCut) {
40 // If things are back to normal, cancel the cut and force a reset
41 if (restoreConditionsMet(rpm, load)) {
42 lambdaMonitorCut = false;
44 }
45 }
46}
virtual bool isCurrentlyGood(float rpm, float load) const
virtual float getTimeout() const =0
virtual bool restoreConditionsMet(float rpm, float load) const
scaled_channel< uint16_t, 100, 1 > lambdaTimeSinceGood

Referenced by EngineState::periodicFastCallback().

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

Field Documentation

◆ m_timeSinceGoodLambda

Timer LambdaMonitorBase::m_timeSinceGoodLambda
private

Definition at line 25 of file lambda_monitor.h.

Referenced by update().


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