Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable closed loop idle when coasting in gear #496

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion firmware/controllers/actuators/idle_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ IIdleController::Phase IdleController::determinePhase(float rpm, float targetRpm
float maximumIdleRpm = targetRpm + engineConfiguration->idlePidRpmUpperLimit;
looksLikeCoasting = rpm > maximumIdleRpm;
looksLikeCrankToIdle = crankingTaperFraction < 1;
if (looksLikeCoasting && !looksLikeCrankToIdle) {

// if car is gear, disable closed loop idle
// this applies to cars like NA/NB miatas where the clutch up switch only returns true if also in gear
bool transmissionInGear = engineConfiguration->disableIdleClutchUp
&& isBrainPinValid(engineConfiguration->clutchUpPin)
&& engine->engineState.clutchUpState;

if ( (looksLikeCoasting || transmissionInGear) && !looksLikeCrankToIdle) {
return Phase::Coasting;
}

Expand Down
3 changes: 1 addition & 2 deletions firmware/controllers/actuators/idle_thread_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ percent_t getIdlePosition() {

void startPedalPins() {
#if EFI_PROD_CODE
// this is neutral/no gear switch input. on Miata it's wired both to clutch pedal and neutral in gearbox
// this switch is not used yet
startInputPinIfValid("clutch down switch", engineConfiguration->clutchDownPin, engineConfiguration->clutchDownPinMode);

// this is neutral/no gear switch input. on Miata it's wired both to clutch pedal and neutral in gearbox
startInputPinIfValid("clutch up switch", engineConfiguration->clutchUpPin, engineConfiguration->clutchUpPinMode);

startInputPinIfValid("throttle pedal up switch", engineConfiguration->throttlePedalUpPin, engineConfiguration->throttlePedalUpPinMode);
Expand Down
1 change: 1 addition & 0 deletions firmware/integration/rusefi_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ bit useSeparateAdvanceForCranking,"Table","Fixed (auto taper)";In Constant mode,
bit useAdvanceCorrectionsForCranking;This enables the various ignition corrections during cranking (IAT, CLT, FSIO and PID idle).\nYou probably don't need this.
bit flexCranking;Enable a second cranking table to use for E100 flex fuel, interpolating between the two based on flex fuel sensor.
bit useIacPidMultTable;This flag allows to use a special 'PID Multiplier' table (0.0-1.0) to compensate for nonlinear nature of IAC-RPM controller
bit disableIdleClutchUp;Disable closed loop idle if ClutchUp is true. Only works for vehicles where the signal is only present when in gear, like NA/NB miatas. This helps prevent integral saturation while coasting at low RPM
bit isBoostControlEnabled
bit launchSmoothRetard;Interpolates the Ignition Retard from 0 to 100% within the RPM Range
bit isPhaseSyncRequiredForIgnition;Some engines are OK running semi-random sequential while other engine require phase synchronization
Expand Down
1 change: 1 addition & 0 deletions firmware/tunerstudio/tunerstudio.template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
field = "RPM upper limit", idlePidRpmUpperLimit
field = "RPM deadzone", idlePidRpmDeadZone
field = "Max vehicle speed", maxIdleVss
field = "Disable Idle in Gear", disableIdleClutchUp, {clutchUpPin != @@ADC_CHANNEL_NONE@@}

dialog = idleExtra, "Extra Idle Features"
field = "Use idle ignition table", useSeparateAdvanceForIdle
Expand Down
22 changes: 21 additions & 1 deletion unit_tests/tests/test_idle_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ TEST(idle_v2, testDeterminePhase) {
// Below TPS but above RPM should be outside the zone
EXPECT_EQ(ICP::Coasting, dut.determinePhase(1101, 1000, 0, 0, 10));
EXPECT_EQ(ICP::Coasting, dut.determinePhase(5000, 1000, 0, 0, 10));

// enable feature to prevent idle state when coasting in gear
engineConfiguration->disableIdleClutchUp = true;
setMockState(engineConfiguration->clutchUpPin, false);
engineConfiguration->clutchUpPin = Gpio::G2;
engineConfiguration->clutchUpPinMode = PI_PULLDOWN;
engine->updateSwitchInputs();

// should be same behaviour as before when clutch is pressed/car in neutral
EXPECT_EQ(ICP::Idling, dut.determinePhase(1099, 1000, 0, 0, 10));
EXPECT_EQ(ICP::Coasting, dut.determinePhase(1101, 1000, 0, 0, 10));
EXPECT_EQ(ICP::CrankToIdleTaper, dut.determinePhase(1000, 1000, 0, 0, 0.5f));
EXPECT_EQ(ICP::Running, dut.determinePhase(1000, 1000, 10, 0, 10));

// clutchUp indicates car in gear with clutch not pressed, should recognize as coasting instead of idle now
setMockState(engineConfiguration->clutchUpPin, true);
engine->updateSwitchInputs();
EXPECT_EQ(ICP::Coasting, dut.determinePhase(1099, 1000, 0, 0, 10));
EXPECT_EQ(ICP::Coasting, dut.determinePhase(1101, 1000, 0, 0, 10));

}

TEST(idle_v2, crankingOpenLoop) {
Expand Down Expand Up @@ -528,4 +548,4 @@ TEST(idle_v2, IntegrationClamping) {

// Result would be 75 + 75 = 150, but it should clamp to 100
EXPECT_EQ(100, dut.getIdlePosition(950));
}
}
Loading