better idle VE table transition

This commit is contained in:
Matthew Kennedy 2023-03-27 00:42:56 -07:00
parent a29b28493a
commit bdeeb82f93
2 changed files with 22 additions and 8 deletions

View File

@ -26,14 +26,19 @@ float AirmassVeModelBase::getVe(int rpm, float load) const {
auto tps = Sensor::get(SensorType::Tps1);
// get VE from the separate table for Idle if idling
if (engine->module<IdleController>()->isIdlingOrTaper() &&
tps && engineConfiguration->useSeparateVeForIdle) {
tps && engineConfiguration->useSeparateVeForIdle) {
percent_t idleVe = interpolate3d(
config->idleVeTable,
config->idleVeLoadBins, load,
config->idleVeRpmBins, rpm
);
// interpolate between idle table and normal (running) table using TPS threshold
ve = interpolateClamped(0.0f, idleVe, engineConfiguration->idlePidDeactivationTpsThreshold, ve, tps.Value);
// 0 TPS -> idle table
// 1/2 threshold -> idle table
// idle threshold -> normal table
float idleThreshold = engineConfiguration->idlePidDeactivationTpsThreshold;
ve = interpolateClamped(idleThreshold / 2, idleVe, idleThreshold, ve, tps.Value);
}
#endif // EFI_IDLE_CONTROL

View File

@ -271,11 +271,20 @@ TEST(FuelMath, IdleVeTable) {
idler.isIdling = true;
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.4f);
// Below half threshold, fully use idle VE table
Sensor::setMockValue(SensorType::Tps1, 0);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.4f);
Sensor::setMockValue(SensorType::Tps1, 2);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.4f);
Sensor::setMockValue(SensorType::Tps1, 5);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.4f);
// As TPS approaches idle threshold, phase-out the idle VE table
Sensor::setMockValue(SensorType::Tps1, 2.5f);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.425f);
Sensor::setMockValue(SensorType::Tps1, 5.0f);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.45f);
Sensor::setMockValue(SensorType::Tps1, 7.5f);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.475f);
Sensor::setMockValue(SensorType::Tps1, 6);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.42f);
Sensor::setMockValue(SensorType::Tps1, 8);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.46f);
Sensor::setMockValue(SensorType::Tps1, 10);
EXPECT_FLOAT_EQ(dut.getVe(1000, 50), 0.5f);
}