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

#include <limp_manager.h>

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

Public Member Functions

void updateState (float rpm, efitick_t nowNt)
 
void onFastCallback () override
 
void onIgnitionStateChanged (bool ignitionOn) override
 
bool allowElectronicThrottle () const
 
LimpState allowInjection () const
 
LimpState allowIgnition () const
 
float getTimeSinceAnyCut () const
 
bool allowTriggerInput () const
 
void updateRevLimit (float rpm)
 
angle_t getLimitingTimingRetard () const
 
float getLimitingFuelCorrection () const
 
void reportEtbProblem ()
 
void fatalError ()
 
- Public Member Functions inherited from EngineModule
virtual void onConfigurationChange (engine_configuration_s const *)
 
virtual void onSlowCallback ()
 
virtual bool needsDelayedShutoff ()
 

Data Fields

ShutdownController shutdownController
 
Timer externalGdiCanBusComms
 

Private Member Functions

void setFaultRevLimit (int limit, ClearReason rpmLimitReason)
 

Private Attributes

Hysteresis m_revLimitHysteresis
 
MaxLimitWithHysteresis m_boostCutHysteresis
 
Hysteresis m_injectorDutyCutHysteresis
 
int32_t m_faultRevLimit = INT32_MAX
 
Clearable m_allowEtb
 
Clearable m_allowInjection
 
Clearable m_allowIgnition
 
Clearable m_allowTriggerInput
 
Clearable m_transientAllowInjection = true
 
Clearable m_transientAllowIgnition = true
 
bool m_hadOilPressureAfterStart = false
 
bool m_ignitionOn = false
 
angle_t m_timingRetard = 0
 
float m_fuelCorrection = 1.0f
 
float m_revLimit
 
ClearReason m_rpmLimitReason = ClearReason::None
 
float resumeRpm
 
Timer m_lastCutTime
 
Timer m_injectorDutySustainedTimer
 
Timer m_lowOilPressureTimer
 

Detailed Description

Definition at line 88 of file limp_manager.h.

Member Function Documentation

◆ allowElectronicThrottle()

bool LimpManager::allowElectronicThrottle ( ) const

Definition at line 274 of file limp_manager.cpp.

274 {
276}
bool etbIgnoreJamProtection
Definition engine.h:277
Clearable m_allowEtb
static Engine *const engine
Definition engine.h:389

Referenced by EtbController::setOutput().

Here is the caller graph for this function:

◆ allowIgnition()

LimpState LimpManager::allowIgnition ( ) const

Definition at line 293 of file limp_manager.cpp.

293 {
294 if (!m_allowIgnition) {
295 return {false, m_allowIgnition.clearReason};
296 }
299 }
300 return {true, ClearReason::None};
301}
ClearReason clearReason
Clearable m_allowIgnition
Clearable m_transientAllowIgnition

Referenced by onTriggerEventSparkLogic().

Here is the caller graph for this function:

◆ allowInjection()

LimpState LimpManager::allowInjection ( ) const

Definition at line 283 of file limp_manager.cpp.

283 {
284 if (!m_allowInjection) {
285 return {false, m_allowInjection.clearReason};
286 }
289 }
290 return {true, ClearReason::None};
291}
Clearable m_transientAllowInjection
Clearable m_allowInjection

Referenced by handleFuel().

Here is the caller graph for this function:

◆ allowTriggerInput()

bool LimpManager::allowTriggerInput ( ) const

Definition at line 279 of file limp_manager.cpp.

279 {
280 return m_allowTriggerInput;
281}
Clearable m_allowTriggerInput

Referenced by handleShaftSignal().

Here is the caller graph for this function:

◆ fatalError()

void LimpManager::fatalError ( )

Definition at line 255 of file limp_manager.cpp.

255 {
260
262}
void clear(ClearReason p_clearReason)
void setFaultRevLimit(int limit, ClearReason rpmLimitReason)

Referenced by firmwareError().

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

◆ getLimitingFuelCorrection()

float LimpManager::getLimitingFuelCorrection ( ) const

Definition at line 309 of file limp_manager.cpp.

309 {
311 return 1.0f; // no correction
312 return m_fuelCorrection;
313}
float m_fuelCorrection
static constexpr engine_configuration_s * engineConfiguration

Referenced by getRunningFuel().

Here is the caller graph for this function:

◆ getLimitingTimingRetard()

angle_t LimpManager::getLimitingTimingRetard ( ) const

Definition at line 303 of file limp_manager.cpp.

Referenced by EngineState::periodicFastCallback().

Here is the caller graph for this function:

◆ getTimeSinceAnyCut()

float LimpManager::getTimeSinceAnyCut ( ) const

Definition at line 315 of file limp_manager.cpp.

315 {
316 return m_lastCutTime.getElapsedSeconds();
317}
Timer m_lastCutTime

◆ onFastCallback()

void LimpManager::onFastCallback ( )
overridevirtual

Reimplemented from EngineModule.

Definition at line 35 of file limp_manager.cpp.

35 {
37}
void updateState(float rpm, efitick_t nowNt)
static float getOrZero(SensorType type)
Definition sensor.h:83
efitick_t getTimeNowNt()
Definition efitime.cpp:19

Referenced by TriggerCentral::decodeMapCam().

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

◆ onIgnitionStateChanged()

void LimpManager::onIgnitionStateChanged ( bool  ignitionOn)
overridevirtual

Reimplemented from EngineModule.

Definition at line 246 of file limp_manager.cpp.

246 {
247 m_ignitionOn = ignitionOn;
248}

◆ reportEtbProblem()

void LimpManager::reportEtbProblem ( )

Definition at line 250 of file limp_manager.cpp.

Referenced by EtbController::checkJam().

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

◆ setFaultRevLimit()

void LimpManager::setFaultRevLimit ( int  limit,
ClearReason  rpmLimitReason 
)
private

Definition at line 264 of file limp_manager.cpp.

264 {
265 // Only allow decreasing the limit
266 // aka uses the limit of the worst fault to yet occur
267 if (limit < m_faultRevLimit) {
268 m_faultRevLimit = limit;
269 m_rpmLimitReason = rpmLimitReason;
270 }
271}
int32_t m_faultRevLimit
ClearReason m_rpmLimitReason

Referenced by fatalError(), and reportEtbProblem().

Here is the caller graph for this function:

◆ updateRevLimit()

void LimpManager::updateRevLimit ( float  rpm)

Definition at line 39 of file limp_manager.cpp.

39 {
40 // User-configured hard RPM limit, either constant or CLT-lookup
43 : (float)engineConfiguration->rpmHardLimit;
44
45 // Require configurable rpm drop before resuming
47
49
51 m_fuelCorrection = 1.0f + fuelAdded / 100;
52}
float interpolateClamped(float x1, float y1, float x2, float y2, float x)
static constexpr persistent_config_s * config
float percent_t

Referenced by EngineState::periodicFastCallback(), and updateState().

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

◆ updateState()

void LimpManager::updateState ( float  rpm,
efitick_t  nowNt 
)

todo: we need explicit clarification on why do we cut fuel but do not cut spark here!

Definition at line 54 of file limp_manager.cpp.

54 {
57
58#if EFI_SHAFT_POSITION_INPUT && !EFI_UNIT_TEST
59 if (!m_ignitionOn
60 && !engine->triggerCentral.directSelfStimulation // useful to try things on real ECU even without ignition voltage
61 ) {
64 }
65#endif
66
68 if (externalGdiCanBusComms.getElapsedSeconds() > 1) {
70 }
71 }
72
74 allowSpark.clear(ClearReason::Lua);
75 }
76
78 allowFuel.clear(ClearReason::Lua);
79 }
80
81#if EFI_HD_ACR
82 // Don't inject fuel during Harley compression release - it sprays fuel everywhere
84 allowFuel.clear(ClearReason::ACR);
85 }
86#endif // EFI_HD_ACR
87
88 updateRevLimit(rpm);
92 }
93
95 allowSpark.clear(ClearReason::HardLimit);
96 }
97 }
98
99#if EFI_SHAFT_POSITION_INPUT
100 if (engine->lambdaMonitor.isCut()) {
102 }
103
106 // Any engine that requires cam-assistance for a full crank sync (symmetrical crank) can't schedule until we have cam sync
107 // examples:
108 // NB2, Nissan VQ/MR: symmetrical crank wheel and we need to make sure no spark happens out of sync
109 // VTwin Harley: uneven firing order, so we need "cam" MAP sync to make sure no spark happens out of sync
112 }
113
114 // Force fuel limiting on the fault rev limit
115 if (rpm > m_faultRevLimit) {
116 allowFuel.clear(m_rpmLimitReason);
117 }
118
119 // Limit fuel only on boost pressure (limiting spark bends valves)
121 if (mapCut != 0) {
122 // require drop of 'boostCutPressureHyst' kPa to resume fuel
124 allowFuel.clear(ClearReason::BoostCut);
125 }
126 }
127
129 bool hasOilpSensor = Sensor::hasSensor(SensorType::OilPressure);
131 uint16_t minOilPressure = engineConfiguration->minOilPressureAfterStart;
132
133 // Only check if the setting is enabled and you have an oil pressure sensor
134 if (minOilPressure > 0 && hasOilpSensor) {
135 // Has it been long enough we should have pressure?
136 bool isTimedOut = engine->rpmCalculator.getSecondsSinceEngineStart(nowNt) > 5.0f;
137
138 // Only check before timed out
139 if (!isTimedOut) {
140 if (oilp) {
141 // We had oil pressure! Set the flag.
142 if (oilp.Value > minOilPressure) {
144 }
145 }
146 }
147
148 // If time is up, the sensor works, and no pressure, kill the engine.
149 if (isTimedOut && !m_hadOilPressureAfterStart) {
151 }
152 }
153
155 float minPressure = interpolate2d(rpm, config->minimumOilPressureBins, config->minimumOilPressureValues);
156 bool isPressureSufficient = oilp.Value > minPressure;
157
158 if (isPressureSufficient) {
159 m_lowOilPressureTimer.reset(nowNt);
160 }
161
164 }
165 }
166 } else {
167 // reset state in case of stalled engine
169 m_lowOilPressureTimer.reset(nowNt);
170 }
171
172 // If we're in engine stop mode, inhibit fuel
173 if (shutdownController.isEngineStop(nowNt)) {
174 /**
175 * todo: we need explicit clarification on why do we cut fuel but do not cut spark here!
176 */
178 }
179
180 {
181 // If duty cycle is high, impose a fuel cut rev limiter.
182 // This is safer than attempting to limp along with injectors or a pump that are out of flow.
183 // Two conditions will trigger a cut:
184 // - An instantaneous excursion above maxInjectorDutyInstant
185 // - A sustained excursion above maxInjectorDutySustained for a duration of >= maxInjectorDutySustainedTimeout
186 // Only reset once below 20% duty to force the driver to lift off the pedal
187
188 auto injDutyCycle = getInjectorDutyCycle(rpm);
189 bool isOverInstantDutyCycle = injDutyCycle > engineConfiguration->maxInjectorDutyInstant;
190 bool isOverSustainedDutyCycle = injDutyCycle > engineConfiguration->maxInjectorDutySustained;
191 bool isUnderLowDuty = injDutyCycle < 20;
192
193 if (!isOverSustainedDutyCycle) {
194 // Duty cycle is OK, reset timer.
195 m_injectorDutySustainedTimer.reset(nowNt);
196 }
197
198 // True if isOverSustainedDutyCycle has been true for longer than the timeout
199 bool sustainedLimitTimedOut = m_injectorDutySustainedTimer.hasElapsedSec(engineConfiguration->maxInjectorDutySustainedTimeout);
200
201 bool someLimitTripped = isOverInstantDutyCycle || sustainedLimitTimedOut;
202
203 if (m_injectorDutyCutHysteresis.test(someLimitTripped, isUnderLowDuty)) {
205 warning(ObdCode::CUSTOM_TOO_LONG_FUEL_INJECTION, "Injector duty cycle cut %.1f", injDutyCycle);
206 }
207 }
208
209 // If the pedal is pushed while not running, cut fuel to clear a flood condition.
214 }
215#endif // EFI_SHAFT_POSITION_INPUT
216
217 if (!engine->isMainRelayEnabled()) {
218/*
219todo AndreiKA this change breaks 22 unit tests?
220 allowFuel.clear();
221 allowSpark.clear();
222*/
223 }
224
225#if EFI_LAUNCH_CONTROL
226 // Fuel cut if launch control engaged
228 allowFuel.clear(ClearReason::LaunchCut);
229 }
230
231 // Spark cut if launch control engaged
233 allowSpark.clear(ClearReason::LaunchCut);
234 }
235#endif // EFI_LAUNCH_CONTROL
236
237 m_transientAllowInjection = allowFuel;
238 m_transientAllowIgnition = allowSpark;
239
241 // Tracks the last time any cut happened
242 m_lastCutTime.reset(nowNt);
243 }
244}
TriggerCentral triggerCentral
Definition engine.h:299
bool isMainRelayEnabled() const
Definition engine.cpp:530
LaunchControlBase launchController
Definition engine.h:202
EngineState engineState
Definition engine.h:325
RpmCalculator rpmCalculator
Definition engine.h:287
LambdaMonitor lambdaMonitor
Definition engine.h:218
constexpr auto & module()
Definition engine.h:187
bool isActive() const
bool test(float value, float rising, float falling)
Definition hysteresis.h:31
bool isLaunchFuelRpmRetardCondition() const
bool isLaunchSparkRpmRetardCondition() const
Hysteresis m_revLimitHysteresis
Timer m_lowOilPressureTimer
bool m_hadOilPressureAfterStart
MaxLimitWithHysteresis m_boostCutHysteresis
Timer m_injectorDutySustainedTimer
void updateRevLimit(float rpm)
Hysteresis m_injectorDutyCutHysteresis
ShutdownController shutdownController
Timer externalGdiCanBusComms
bool checkIfLimitIsExceeded(const float value, const float maxLimit, const float hysteresis)
bool hasSynchronizedPhase() const
float getSecondsSinceEngineStart(efitick_t nowNt) const
bool isRunning() const
virtual bool hasSensor() const
Definition sensor.h:141
virtual SensorResult get() const =0
bool isEngineStop(efitick_t nowNt) const
PrimaryTriggerDecoder triggerState
bool warning(ObdCode code, const char *fmt,...)
percent_t getInjectorDutyCycle(float rpm)
bool isGdiEngine()
static bool noFiringUntilVvtSync(vvt_mode_e vvtMode)
@ CUSTOM_TOO_LONG_FUEL_INJECTION
@ DriverThrottleIntent
scaled_channel< uint8_t, 1, 10 > minimumOilPressureValues[8]
scaled_channel< uint8_t, 1, 100 > minimumOilPressureBins[8]

Referenced by onFastCallback().

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

Field Documentation

◆ externalGdiCanBusComms

Timer LimpManager::externalGdiCanBusComms

Definition at line 115 of file limp_manager.h.

Referenced by processCanRxMessage(), and updateState().

◆ m_allowEtb

Clearable LimpManager::m_allowEtb
private

Definition at line 127 of file limp_manager.h.

Referenced by allowElectronicThrottle(), fatalError(), and reportEtbProblem().

◆ m_allowIgnition

Clearable LimpManager::m_allowIgnition
private

Definition at line 129 of file limp_manager.h.

Referenced by allowIgnition(), and fatalError().

◆ m_allowInjection

Clearable LimpManager::m_allowInjection
private

Definition at line 128 of file limp_manager.h.

Referenced by allowInjection(), and fatalError().

◆ m_allowTriggerInput

Clearable LimpManager::m_allowTriggerInput
private

Definition at line 130 of file limp_manager.h.

Referenced by allowTriggerInput(), and fatalError().

◆ m_boostCutHysteresis

MaxLimitWithHysteresis LimpManager::m_boostCutHysteresis
private

Definition at line 121 of file limp_manager.h.

Referenced by updateState().

◆ m_faultRevLimit

int32_t LimpManager::m_faultRevLimit = INT32_MAX
private

Definition at line 125 of file limp_manager.h.

Referenced by setFaultRevLimit(), and updateState().

◆ m_fuelCorrection

float LimpManager::m_fuelCorrection = 1.0f
private

Definition at line 141 of file limp_manager.h.

Referenced by getLimitingFuelCorrection(), and updateRevLimit().

◆ m_hadOilPressureAfterStart

bool LimpManager::m_hadOilPressureAfterStart = false
private

Definition at line 135 of file limp_manager.h.

Referenced by updateState().

◆ m_ignitionOn

bool LimpManager::m_ignitionOn = false
private

Definition at line 138 of file limp_manager.h.

Referenced by onIgnitionStateChanged(), and updateState().

◆ m_injectorDutyCutHysteresis

Hysteresis LimpManager::m_injectorDutyCutHysteresis
private

Definition at line 122 of file limp_manager.h.

Referenced by updateState().

◆ m_injectorDutySustainedTimer

Timer LimpManager::m_injectorDutySustainedTimer
private

Definition at line 152 of file limp_manager.h.

Referenced by updateState().

◆ m_lastCutTime

Timer LimpManager::m_lastCutTime
private

Definition at line 149 of file limp_manager.h.

Referenced by getTimeSinceAnyCut(), and updateState().

◆ m_lowOilPressureTimer

Timer LimpManager::m_lowOilPressureTimer
private

Definition at line 155 of file limp_manager.h.

Referenced by updateState().

◆ m_revLimit

float LimpManager::m_revLimit
private

Definition at line 144 of file limp_manager.h.

Referenced by updateRevLimit(), and updateState().

◆ m_revLimitHysteresis

Hysteresis LimpManager::m_revLimitHysteresis
private

Definition at line 120 of file limp_manager.h.

Referenced by updateState().

◆ m_rpmLimitReason

ClearReason LimpManager::m_rpmLimitReason = ClearReason::None
private

Definition at line 145 of file limp_manager.h.

Referenced by setFaultRevLimit(), and updateState().

◆ m_timingRetard

angle_t LimpManager::m_timingRetard = 0
private

Definition at line 140 of file limp_manager.h.

Referenced by getLimitingTimingRetard(), and updateRevLimit().

◆ m_transientAllowIgnition

Clearable LimpManager::m_transientAllowIgnition = true
private

Definition at line 133 of file limp_manager.h.

Referenced by allowIgnition(), and updateState().

◆ m_transientAllowInjection

Clearable LimpManager::m_transientAllowInjection = true
private

Definition at line 132 of file limp_manager.h.

Referenced by allowInjection(), and updateState().

◆ resumeRpm

float LimpManager::resumeRpm
private

Definition at line 146 of file limp_manager.h.

Referenced by updateRevLimit(), and updateState().

◆ shutdownController

ShutdownController LimpManager::shutdownController

Definition at line 90 of file limp_manager.h.

Referenced by configureRusefiLuaHooks(), doScheduleStopEngine(), and updateState().


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