Skip to content

Commit

Permalink
implement DFCO hysteresis #478
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Sep 13, 2024
1 parent 48488b4 commit 89338bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions firmware/controllers/algo/fuel/dfco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ bool DfcoController::getState() const {
}

// MAP sensor is optional, only inhibit if the sensor is present but broken
if (Sensor::hasSensor(SensorType::Map) && !map) {
bool hasMap = Sensor::hasSensor(SensorType::Map);
if (hasMap && !map) {
return false;
}

Expand All @@ -31,7 +32,7 @@ bool DfcoController::getState() const {
interpolate2d(rpm, config->dfcoMapRpmValuesBins, config->dfcoMapRpmValues) :
engineConfiguration->coastingFuelCutMap;

bool mapActivate = map.value_or(0) < mapThreshold;
bool mapActivate = !hasMap || !m_mapHysteresis.test(map.value_or(0), mapThreshold + 1, mapThreshold - 1);
bool tpsActivate = tps.Value < engineConfiguration->coastingFuelCutTps;
bool cltActivate = clt.Value > engineConfiguration->coastingFuelCutClt;
// True if throttle, MAP, and CLT are all acceptable for DFCO to occur
Expand Down
3 changes: 3 additions & 0 deletions firmware/controllers/algo/fuel/dfco.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once
#include "engine_module.h"
#include "timer.h"
#include "limp_manager.h"

This comment has been minimized.

Copy link
@rusefillc

rusefillc Sep 15, 2024

Contributor

"we have to include limp_manager.h to use Hysteresis" rusefi/rusefi@b31f481


// DFCO = deceleration fuel cut off, ie, save gas when your foot is off the pedal
class DfcoController : public EngineModule {
Expand All @@ -19,6 +20,8 @@ class DfcoController : public EngineModule {
bool getState() const;
bool m_isDfco = false;

mutable Hysteresis m_mapHysteresis;

Timer m_timeSinceCut;
Timer m_timeSinceNoCut;
};
4 changes: 2 additions & 2 deletions unit_tests/tests/ignition_injection/test_fuelCut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ TEST(fuelCut, mapTable) {
EXPECT_NORMAL();

// Drop MAP to just above the interpolated cutoff curve
Sensor::setMockValue(SensorType::Map, 41);
Sensor::setMockValue(SensorType::Map, 43);
eth.engine.periodicFastCallback();
EXPECT_NORMAL();

// Drop MAP to just below the interpolated cutoff curve
Sensor::setMockValue(SensorType::Map, 39);
Sensor::setMockValue(SensorType::Map, 37);
eth.engine.periodicFastCallback();
EXPECT_CUT();

Expand Down

0 comments on commit 89338bd

Please sign in to comment.