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

#include <dfco.h>

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

Public Member Functions

void update ()
 
bool cutFuel () const
 
float getTimingRetard () const
 
float getTimeSinceCut () const
 
- Public Member Functions inherited from EngineModule
virtual void initNoConfiguration ()
 
virtual void setDefaultConfiguration ()
 
virtual void onConfigurationChange (engine_configuration_s const *)
 
virtual void onSlowCallback ()
 
virtual void onFastCallback ()
 
virtual void onEngineStop ()
 
virtual void onIgnitionStateChanged (bool)
 
virtual bool needsDelayedShutoff ()
 
virtual void onEnginePhase (float, efitick_t, angle_t, angle_t)
 

Private Member Functions

bool getState () const
 

Private Attributes

bool m_isDfco = false
 
Hysteresis m_mapHysteresis
 
Timer m_timeSinceCut
 
Timer m_timeSinceNoCut
 

Detailed Description

Definition at line 11 of file dfco.h.

Member Function Documentation

◆ cutFuel()

bool DfcoController::cutFuel ( ) const

Definition at line 81 of file dfco.cpp.

81 {
82 float cutDelay = engineConfiguration->dfcoDelay;
83
84 // 0 delay means cut immediately, aka timer has always expired
85 bool hasBeenDelay = (cutDelay == 0) || m_timeSinceNoCut.hasElapsedSec(cutDelay);
86
87 return m_isDfco && hasBeenDelay;
88}
bool m_isDfco
Definition dfco.h:24
Timer m_timeSinceNoCut
Definition dfco.h:29
static constexpr engine_configuration_s * engineConfiguration

Referenced by getInjectionMass().

Here is the caller graph for this function:

◆ getState()

bool DfcoController::getState ( ) const
private

Definition at line 8 of file dfco.cpp.

8 {
10 return false;
11 }
12
13 if (checkIfTuningVeNow()) {
14 return false;
15 }
16
18 const auto clt = Sensor::get(SensorType::Clt);
19 const auto map = Sensor::get(SensorType::Map);
20
21 // If some sensor is broken, inhibit DFCO
22 if (!tps || !clt) {
23 return false;
24 }
25
26 // MAP sensor is optional, only inhibit if the sensor is present but broken
28 if (hasMap && !map) {
29 return false;
30 }
32 // Lua might have reasons to disable
33 return false;
34 }
35
38
39 bool mapActivate = !hasMap || !m_mapHysteresis.test(map.value_or(0), engineConfiguration->coastingFuelCutMap + 1, engineConfiguration->coastingFuelCutMap - 1);
40 bool tpsActivate = tps.Value < engineConfiguration->coastingFuelCutTps;
41 bool cltActivate = clt.Value > engineConfiguration->coastingFuelCutClt;
42 // True if throttle, MAP, and CLT are all acceptable for DFCO to occur
43 bool dfcoAllowed = mapActivate && tpsActivate && cltActivate;
44
45 bool rpmActivate = (rpm > engineConfiguration->coastingFuelCutRpmHigh);
46 bool rpmDeactivate = (rpm < engineConfiguration->coastingFuelCutRpmLow);
47
48 // greater than or equal so that it works if both config params are set to 0
49 bool vssActivate = (vss >= engineConfiguration->coastingFuelCutVssHigh);
50 bool vssDeactivate = (vss < engineConfiguration->coastingFuelCutVssLow);
51
52 // RPM is high enough, VSS high enough, and DFCO allowed
53 if (dfcoAllowed && rpmActivate && vssActivate) {
54 return true;
55 }
56
57 // RPM too low, VSS too low, or DFCO not allowed
58 if (!dfcoAllowed || rpmDeactivate || vssDeactivate) {
59 return false;
60 }
61
62 // No conditions hit, no change to state (provides hysteresis)
63 return m_isDfco;
64}
Hysteresis m_mapHysteresis
Definition dfco.h:26
EngineState engineState
Definition engine.h:344
bool test(float value, float rising, float falling)
Definition hysteresis.h:31
virtual bool hasSensor() const
Definition sensor.h:141
virtual SensorResult get() const =0
static float getOrZero(SensorType type)
Definition sensor.h:83
bool checkIfTuningVeNow()
static EngineAccessor engine
Definition engine.h:413
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
@ DriverThrottleIntent

Referenced by update().

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

◆ getTimeSinceCut()

float DfcoController::getTimeSinceCut ( ) const

Definition at line 90 of file dfco.cpp.

90 {
91 return m_timeSinceCut.getElapsedSeconds();
92}
Timer m_timeSinceCut
Definition dfco.h:28

◆ getTimingRetard()

float DfcoController::getTimingRetard ( ) const

Definition at line 94 of file dfco.cpp.

94 {
95 float cutTiming = clampF(0, engineConfiguration->dfcoRetardDeg, 30);
96
97 if (m_isDfco) {
98 // While cut, always retard timing
99 return cutTiming;
100 } else {
101 float timeSinceCut = m_timeSinceCut.getElapsedSeconds();
102 float rampInTime = engineConfiguration->dfcoRetardRampInTime;
103
104 if (timeSinceCut > rampInTime) {
105 // Normal operation, no retard
106 return 0;
107 } else {
108 return interpolateClamped(0, cutTiming, 0.5, 0, timeSinceCut);
109 }
110 }
111}
float interpolateClamped(float x1, float y1, float x2, float y2, float x)
Here is the call graph for this function:

◆ update()

void DfcoController::update ( )

Definition at line 66 of file dfco.cpp.

66 {
67 // Run state machine
68 bool newState = getState();
69
70 // If fuel is cut, reset the timer
71 if (newState) {
72 m_timeSinceCut.reset();
73 } else {
74 // If fuel is not cut, reset the not-cut timer
75 m_timeSinceNoCut.reset();
76 }
77
78 m_isDfco = newState;
79}
bool getState() const
Definition dfco.cpp:8
Here is the call graph for this function:

Field Documentation

◆ m_isDfco

bool DfcoController::m_isDfco = false
private

Definition at line 24 of file dfco.h.

Referenced by cutFuel(), getState(), getTimingRetard(), and update().

◆ m_mapHysteresis

Hysteresis DfcoController::m_mapHysteresis
mutableprivate

Definition at line 26 of file dfco.h.

Referenced by getState().

◆ m_timeSinceCut

Timer DfcoController::m_timeSinceCut
private

Definition at line 28 of file dfco.h.

Referenced by getTimeSinceCut(), getTimingRetard(), and update().

◆ m_timeSinceNoCut

Timer DfcoController::m_timeSinceNoCut
private

Definition at line 29 of file dfco.h.

Referenced by cutFuel(), and update().


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