parent
d988bdca9f
commit
c1699d91d0
|
@ -66,13 +66,13 @@ static bool shouldCorrect(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool shouldUpdateCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
bool shouldUpdateCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
const auto& cfg = CONFIG(stft);
|
const auto& cfg = CONFIG(stft);
|
||||||
|
|
||||||
// Pause (but don't reset) correction if the AFR is off scale.
|
// Pause (but don't reset) correction if the AFR is off scale.
|
||||||
// It's probably a transient and poorly tuned transient correction
|
// It's probably a transient and poorly tuned transient correction
|
||||||
auto afr = Sensor::get(SensorType::Lambda);
|
auto afr = Sensor::get(SensorType::Lambda).value_or(0) * 14.7f;
|
||||||
if (!afr || afr.value_or(0) < (cfg.minAfr * 0.1f) || afr.value_or(0) > (cfg.maxAfr * 0.1f)) {
|
if (!afr || afr < (cfg.minAfr * 0.1f) || afr > (cfg.maxAfr * 0.1f)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,3 +5,4 @@
|
||||||
|
|
||||||
float fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
float fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
size_t computeStftBin(int rpm, float load, stft_s& cfg);
|
size_t computeStftBin(int rpm, float load, stft_s& cfg);
|
||||||
|
bool shouldUpdateCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
#include "engine_test_helper.h"
|
||||||
#include "closed_loop_fuel_cell.h"
|
#include "closed_loop_fuel_cell.h"
|
||||||
#include "closed_loop_fuel.h"
|
#include "closed_loop_fuel.h"
|
||||||
|
|
||||||
|
@ -79,3 +80,19 @@ TEST(ClosedLoopFuel, CellSelection) {
|
||||||
EXPECT_EQ(3, computeStftBin(4000, 50, cfg));
|
EXPECT_EQ(3, computeStftBin(4000, 50, cfg));
|
||||||
EXPECT_EQ(3, computeStftBin(10000, 50, cfg));
|
EXPECT_EQ(3, computeStftBin(10000, 50, cfg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ClosedLoopFuel, afrLimits) {
|
||||||
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
||||||
|
|
||||||
|
engineConfiguration->stft.minAfr = 100; // 10.0 AFR
|
||||||
|
engineConfiguration->stft.maxAfr = 180; // 18.0 AFR
|
||||||
|
|
||||||
|
Sensor::setMockValue(SensorType::Lambda, 0.1f);
|
||||||
|
EXPECT_FALSE(shouldUpdateCorrection(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||||
|
|
||||||
|
Sensor::setMockValue(SensorType::Lambda, 1.0f);
|
||||||
|
EXPECT_TRUE(shouldUpdateCorrection(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||||
|
|
||||||
|
Sensor::setMockValue(SensorType::Lambda, 2.0f);
|
||||||
|
EXPECT_FALSE(shouldUpdateCorrection(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue