Improve ETB idle control (#1319)
* compress idle pos * fix tests for new behavior
This commit is contained in:
parent
1a5e0a42f8
commit
99489cff67
|
@ -168,7 +168,8 @@ expected<percent_t> EtbController::getSetpoint() const {
|
||||||
float sanitizedPedal = clampF(0, pedalPosition.Value, 100);
|
float sanitizedPedal = clampF(0, pedalPosition.Value, 100);
|
||||||
|
|
||||||
float rpm = GET_RPM();
|
float rpm = GET_RPM();
|
||||||
engine->engineState.targetFromTable = m_pedalMap->getValue(rpm / RPM_1_BYTE_PACKING_MULT, sanitizedPedal);
|
float targetFromTable = m_pedalMap->getValue(rpm / RPM_1_BYTE_PACKING_MULT, sanitizedPedal);
|
||||||
|
engine->engineState.targetFromTable = targetFromTable;
|
||||||
|
|
||||||
percent_t etbIdlePosition = clampF(
|
percent_t etbIdlePosition = clampF(
|
||||||
0,
|
0,
|
||||||
|
@ -177,15 +178,19 @@ expected<percent_t> EtbController::getSetpoint() const {
|
||||||
);
|
);
|
||||||
percent_t etbIdleAddition = 0.01f * CONFIG(etbIdleThrottleRange) * etbIdlePosition;
|
percent_t etbIdleAddition = 0.01f * CONFIG(etbIdleThrottleRange) * etbIdlePosition;
|
||||||
|
|
||||||
float target = engine->engineState.targetFromTable + etbIdleAddition;
|
// Interpolate so that the idle adder just "compresses" the throttle's range upward.
|
||||||
|
// [0, 100] -> [idle, 100]
|
||||||
|
// 0% target from table -> idle position as target
|
||||||
|
// 100% target from table -> 100% target position
|
||||||
|
percent_t targetPosition = interpolateClamped(0, etbIdleAddition, 100, 100, targetFromTable);
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
if (m_myIndex == 0) {
|
if (m_myIndex == 0) {
|
||||||
tsOutputChannels.etbTarget = target;
|
tsOutputChannels.etbTarget = targetPosition;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return target;
|
return targetPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
expected<percent_t> EtbController::getOpenLoop(percent_t target) const {
|
expected<percent_t> EtbController::getOpenLoop(percent_t target) const {
|
||||||
|
|
|
@ -176,26 +176,30 @@ TEST(etb, setpointIdle) {
|
||||||
// Idle should now have 10% range
|
// Idle should now have 10% range
|
||||||
engineConfiguration->etbIdleThrottleRange = 10;
|
engineConfiguration->etbIdleThrottleRange = 10;
|
||||||
|
|
||||||
// 50% idle position should increase setpoint by 5%
|
// 50% idle position should increase setpoint by 5% when closed, and 0% when open
|
||||||
etb.setIdlePosition(50);
|
etb.setIdlePosition(50);
|
||||||
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f);
|
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f);
|
||||||
EXPECT_FLOAT_EQ(5, etb.getSetpoint().value_or(-1));
|
EXPECT_FLOAT_EQ(5, etb.getSetpoint().value_or(-1));
|
||||||
Sensor::setMockValue(SensorType::AcceleratorPedal, 50.0f);
|
Sensor::setMockValue(SensorType::AcceleratorPedal, 50.0f);
|
||||||
EXPECT_FLOAT_EQ(55, etb.getSetpoint().value_or(-1));
|
EXPECT_FLOAT_EQ(52.5, etb.getSetpoint().value_or(-1));
|
||||||
|
Sensor::setMockValue(SensorType::AcceleratorPedal, 100.0f);
|
||||||
|
EXPECT_FLOAT_EQ(100, etb.getSetpoint().value_or(-1));
|
||||||
|
|
||||||
// 100% setpoint should increase by 10%
|
// 100% setpoint should increase by 10% closed, scaled 0% at wot
|
||||||
etb.setIdlePosition(100);
|
etb.setIdlePosition(100);
|
||||||
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f);
|
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f);
|
||||||
EXPECT_FLOAT_EQ(10, etb.getSetpoint().value_or(-1));
|
EXPECT_FLOAT_EQ(10, etb.getSetpoint().value_or(-1));
|
||||||
Sensor::setMockValue(SensorType::AcceleratorPedal, 50.0f);
|
Sensor::setMockValue(SensorType::AcceleratorPedal, 50.0f);
|
||||||
EXPECT_FLOAT_EQ(60, etb.getSetpoint().value_or(-1));
|
EXPECT_FLOAT_EQ(55, etb.getSetpoint().value_or(-1));
|
||||||
|
Sensor::setMockValue(SensorType::AcceleratorPedal, 100.0f);
|
||||||
|
EXPECT_FLOAT_EQ(100, etb.getSetpoint().value_or(-1));
|
||||||
|
|
||||||
// 125% setpoint should clamp to 10% increase
|
// 125% setpoint should clamp to 10% increase
|
||||||
etb.setIdlePosition(125);
|
etb.setIdlePosition(125);
|
||||||
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f);
|
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f);
|
||||||
EXPECT_FLOAT_EQ(10, etb.getSetpoint().value_or(-1));
|
EXPECT_FLOAT_EQ(10, etb.getSetpoint().value_or(-1));
|
||||||
Sensor::setMockValue(SensorType::AcceleratorPedal, 50.0f);
|
Sensor::setMockValue(SensorType::AcceleratorPedal, 50.0f);
|
||||||
EXPECT_FLOAT_EQ(60, etb.getSetpoint().value_or(-1));
|
EXPECT_FLOAT_EQ(55, etb.getSetpoint().value_or(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(etb, etbTpsSensor) {
|
TEST(etb, etbTpsSensor) {
|
||||||
|
|
Loading…
Reference in New Issue