From a4973a6f3d7e4c713ef77d07a0ad357a0979a8f2 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Tue, 15 Jun 2021 14:30:35 -0700 Subject: [PATCH] fan/AC idle improvements (#2818) * fan 2 open loop bump * we had an AC target bump all this time?! * format * enable test * I can't type --- firmware/controllers/actuators/idle_thread.cpp | 14 ++++++++------ firmware/integration/rusefi_config.txt | 3 +-- firmware/tunerstudio/rusefi.input | 3 ++- unit_tests/tests/test_idle_controller.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index b42c03f42d..7967f2d85c 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -196,11 +196,15 @@ void IdleController::init(pid_s* idlePidConfig) { } int IdleController::getTargetRpm(float clt) const { - // TODO: bump target rpm based on AC and/or fan(s)? + auto target = interpolate2d(clt, CONFIG(cltIdleRpmBins), CONFIG(cltIdleRpm)); - float fsioBump = engine->fsioState.fsioIdleTargetRPMAdjustment; + // Bump for AC + target += engine->acSwitchState ? CONFIG(acIdleRpmBump) : 0; - return fsioBump + interpolate2d(clt, CONFIG(cltIdleRpmBins), CONFIG(cltIdleRpm)); + // Bump by FSIO + target += engine->fsioState.fsioIdleTargetRPMAdjustment; + + return target; } IIdleController::Phase IdleController::determinePhase(int rpm, int targetRpm, SensorResult tps) const { @@ -247,9 +251,7 @@ float IdleController::getRunningOpenLoop(float clt, SensorResult tps) const { // Now we bump it by the AC/fan amount if necessary running += engine->acSwitchState ? CONFIG(acIdleExtraOffset) : 0; running += enginePins.fanRelay.getLogicValue() ? CONFIG(fan1ExtraIdle) : 0; - - // TODO: once we have dual fans, enable - //running += enginePins.fanRelay2.getLogicValue() ? CONFIG(fan2ExtraIdle) : 0; + running += enginePins.fanRelay2.getLogicValue() ? CONFIG(fan2ExtraIdle) : 0; // Now bump it by the specified amount when the throttle is opened (if configured) // nb: invalid tps will make no change, no explicit check required diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 05e9fea240..71213bc3f7 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1148,8 +1148,7 @@ bit unused_1484_bit_31 ! todo: start using these parameters! int16_t acCutoffLowRpm;;"RPM", 1, 0, 1, 15000, 0 int16_t acCutoffHighRpm;;"RPM", 1, 0, 1, 15000, 0 - int16_t acIdleRpmBump;;"RPM", 1, 0, 1, 15000, 0 - + int16_t acIdleRpmBump;+Extra idle target speed when A/C is enabled. Some cars need the extra speed to keep the AC efficient while idling.;"RPM", 1, 0, 0, 1000, 0 int16_t warningPeriod;set warningPeriod X;"seconds", 1, 0, 0, 60, 0 diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 547cd4d4fa..76d6cfcc07 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -2631,8 +2631,9 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" dialog = idleOpenLoop, "Open Loop Idle" slider = "Open loop base position", manIdlePosition, horizontal field = "A/C adder", acIdleExtraOffset + field = "A/C target adder", acIdleRpmBump field = "Fan #1 adder", fan1ExtraIdle - ;field = "Fan #2 adder", fan2ExtraIdle + field = "Fan #2 adder", fan2ExtraIdle field = "Extra idle air if throttle pressed", iacByTpsTaper dialog = idleGating, "Idle Detection Thresholds" diff --git a/unit_tests/tests/test_idle_controller.cpp b/unit_tests/tests/test_idle_controller.cpp index eb1dfee648..03cb6ddefa 100644 --- a/unit_tests/tests/test_idle_controller.cpp +++ b/unit_tests/tests/test_idle_controller.cpp @@ -223,14 +223,14 @@ TEST(idle_v2, runningFanAcBump) { enginePins.fanRelay.setValue(0); // Turn on the other fan! - //enginePins.fanRelay2.setValue(1); - //EXPECT_FLOAT_EQ(50 + 3, dut.getRunningOpenLoop(10, 0)); + enginePins.fanRelay2.setValue(1); + EXPECT_FLOAT_EQ(50 + 3, dut.getRunningOpenLoop(10, 0)); // Turn on everything! engine->acSwitchState = true; enginePins.fanRelay.setValue(1); - ///nginePins.fanRelay2.setValue(1); - EXPECT_FLOAT_EQ(50 + 9 + 7 /* + 3 */, dut.getRunningOpenLoop(10, 0)); + enginePins.fanRelay2.setValue(1); + EXPECT_FLOAT_EQ(50 + 9 + 7 + 3, dut.getRunningOpenLoop(10, 0)); } TEST(idle_v2, runningOpenLoopTpsTaper) {