diff --git a/firmware/controllers/actuators/idle_state.txt b/firmware/controllers/actuators/idle_state.txt index 7088b6baaa..40b00221e1 100644 --- a/firmware/controllers/actuators/idle_state.txt +++ b/firmware/controllers/actuators/idle_state.txt @@ -5,6 +5,7 @@ custom idle_state_e 4 bits, S32, @OFFSET@, [0:2], "not important" custom percent_t 4 bits, F32, @OFFSET@, [0:2], "not important" percent_t currentIdlePosition;that's current position with CLT and IAT corrections percent_t baseIdlePosition;current position without adjustments (iacByTpsTaper, afterCrankingIACtaperDuration) + percent_t iacByTpsTaper;iacByTpsTaper portion of idle int throttlePedalUpState;true in IDLE throttle pedal state, false if driver is touching the pedal\ntodo: better name for this field? bit mightResetPid;The idea of 'mightResetPid' is to reset PID only once - each time when TPS > idlePidDeactivationTpsThreshold.\nThe throttle pedal can be pressed for a long time, making the PID data obsolete (thus the reset is required).\nWe set 'mightResetPid' to true only if PID was actually used (i.e. idlePid.getOutput() was called) to save some CPU resources.\nSee automaticIdleController(). diff --git a/firmware/controllers/actuators/idle_state_generated.h b/firmware/controllers/actuators/idle_state_generated.h index c6854f944d..214fb8198c 100644 --- a/firmware/controllers/actuators/idle_state_generated.h +++ b/firmware/controllers/actuators/idle_state_generated.h @@ -1,4 +1,4 @@ -// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Tue Jan 11 14:08:37 EST 2022 +// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Sun Apr 03 19:52:33 EDT 2022 // by class com.rusefi.output.CHeaderConsumer // begin #pragma once @@ -19,10 +19,15 @@ struct idle_state_s { * offset 8 */ percent_t baseIdlePosition = (percent_t)0; + /** + * iacByTpsTaper portion of idle + * offset 12 + */ + percent_t iacByTpsTaper = (percent_t)0; /** * true in IDLE throttle pedal state, false if driver is touching the pedal * todo: better name for this field? - * offset 12 + * offset 16 */ int throttlePedalUpState = (int)0; /** @@ -30,113 +35,113 @@ struct idle_state_s { * The throttle pedal can be pressed for a long time, making the PID data obsolete (thus the reset is required). * We set 'mightResetPid' to true only if PID was actually used (i.e. idlePid.getOutput() was called) to save some CPU resources. * See automaticIdleController(). - offset 16 bit 0 */ + offset 20 bit 0 */ bool mightResetPid : 1 {}; /** - offset 16 bit 1 */ + offset 20 bit 1 */ bool shouldResetPid : 1 {}; /** * This is needed to slowly turn on the PID back after it was reset. - offset 16 bit 2 */ + offset 20 bit 2 */ bool wasResetPid : 1 {}; /** * This is used when the PID configuration is changed, to guarantee the reset - offset 16 bit 3 */ + offset 20 bit 3 */ bool mustResetPid : 1 {}; /** - offset 16 bit 4 */ + offset 20 bit 4 */ bool isCoasting : 1 {}; /** - offset 16 bit 5 */ + offset 20 bit 5 */ bool useIacTableForCoasting : 1 {}; /** - offset 16 bit 6 */ + offset 20 bit 6 */ bool notIdling : 1 {}; /** - offset 16 bit 7 */ + offset 20 bit 7 */ bool needReset : 1 {}; /** - offset 16 bit 8 */ + offset 20 bit 8 */ bool isInDeadZone : 1 {}; /** - offset 16 bit 9 */ + offset 20 bit 9 */ bool isBlipping : 1 {}; /** - offset 16 bit 10 */ + offset 20 bit 10 */ bool useClosedLoop : 1 {}; /** - offset 16 bit 11 */ + offset 20 bit 11 */ bool badTps : 1 {}; /** - offset 16 bit 12 */ + offset 20 bit 12 */ bool looksLikeRunning : 1 {}; /** - offset 16 bit 13 */ + offset 20 bit 13 */ bool looksLikeCoasting : 1 {}; /** - offset 16 bit 14 */ + offset 20 bit 14 */ bool looksLikeCrankToIdle : 1 {}; /** - offset 16 bit 15 */ + offset 20 bit 15 */ bool useInstantRpmForIdle : 1 {}; /** - offset 16 bit 16 */ + offset 20 bit 16 */ bool isVerboseIAC : 1 {}; /** - offset 16 bit 17 */ - bool unusedBit_21_17 : 1 {}; + offset 20 bit 17 */ + bool unusedBit_22_17 : 1 {}; /** - offset 16 bit 18 */ - bool unusedBit_21_18 : 1 {}; + offset 20 bit 18 */ + bool unusedBit_22_18 : 1 {}; /** - offset 16 bit 19 */ - bool unusedBit_21_19 : 1 {}; + offset 20 bit 19 */ + bool unusedBit_22_19 : 1 {}; /** - offset 16 bit 20 */ - bool unusedBit_21_20 : 1 {}; + offset 20 bit 20 */ + bool unusedBit_22_20 : 1 {}; /** - offset 16 bit 21 */ - bool unusedBit_21_21 : 1 {}; + offset 20 bit 21 */ + bool unusedBit_22_21 : 1 {}; /** - offset 16 bit 22 */ - bool unusedBit_21_22 : 1 {}; + offset 20 bit 22 */ + bool unusedBit_22_22 : 1 {}; /** - offset 16 bit 23 */ - bool unusedBit_21_23 : 1 {}; + offset 20 bit 23 */ + bool unusedBit_22_23 : 1 {}; /** - offset 16 bit 24 */ - bool unusedBit_21_24 : 1 {}; + offset 20 bit 24 */ + bool unusedBit_22_24 : 1 {}; /** - offset 16 bit 25 */ - bool unusedBit_21_25 : 1 {}; + offset 20 bit 25 */ + bool unusedBit_22_25 : 1 {}; /** - offset 16 bit 26 */ - bool unusedBit_21_26 : 1 {}; + offset 20 bit 26 */ + bool unusedBit_22_26 : 1 {}; /** - offset 16 bit 27 */ - bool unusedBit_21_27 : 1 {}; + offset 20 bit 27 */ + bool unusedBit_22_27 : 1 {}; /** - offset 16 bit 28 */ - bool unusedBit_21_28 : 1 {}; + offset 20 bit 28 */ + bool unusedBit_22_28 : 1 {}; /** - offset 16 bit 29 */ - bool unusedBit_21_29 : 1 {}; + offset 20 bit 29 */ + bool unusedBit_22_29 : 1 {}; /** - offset 16 bit 30 */ - bool unusedBit_21_30 : 1 {}; + offset 20 bit 30 */ + bool unusedBit_22_30 : 1 {}; /** - offset 16 bit 31 */ - bool unusedBit_21_31 : 1 {}; - /** - * offset 20 - */ - int targetRpmByClt = (int)0; + offset 20 bit 31 */ + bool unusedBit_22_31 : 1 {}; /** * offset 24 */ + int targetRpmByClt = (int)0; + /** + * offset 28 + */ int targetRpmAcBump = (int)0; - /** total size 28*/ + /** total size 32*/ }; // end -// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Tue Jan 11 14:08:37 EST 2022 +// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Sun Apr 03 19:52:33 EDT 2022 diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index a1daa617f1..f2737b89b6 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -87,7 +87,7 @@ float IdleController::getCrankingOpenLoop(float clt) const { return engineConfiguration->crankingIACposition * mult; } -percent_t IdleController::getRunningOpenLoop(float clt, SensorResult tps) const { +percent_t IdleController::getRunningOpenLoop(float clt, SensorResult tps) { float running = engineConfiguration->manIdlePosition // Base idle position (slider) * interpolate2d(clt, config->cltIdleCorrBins, config->cltIdleCorr); @@ -99,11 +99,13 @@ percent_t IdleController::getRunningOpenLoop(float clt, SensorResult tps) const // 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 - running += interpolateClamped( + iacByTpsTaper = interpolateClamped( 0, 0, engineConfiguration->idlePidDeactivationTpsThreshold, engineConfiguration->iacByTpsTaper, tps.value_or(0)); + running += iacByTpsTaper; + return clampF(0, running, 100); } diff --git a/firmware/controllers/actuators/idle_thread.h b/firmware/controllers/actuators/idle_thread.h index 1b4a17fbc4..6e2a7b3278 100644 --- a/firmware/controllers/actuators/idle_thread.h +++ b/firmware/controllers/actuators/idle_thread.h @@ -25,7 +25,7 @@ struct IIdleController { virtual Phase determinePhase(int rpm, int targetRpm, SensorResult tps, float vss, float crankingTaperFraction) = 0; virtual int getTargetRpm(float clt) = 0; virtual float getCrankingOpenLoop(float clt) const = 0; - virtual float getRunningOpenLoop(float clt, SensorResult tps) const = 0; + virtual float getRunningOpenLoop(float clt, SensorResult tps) = 0; virtual float getOpenLoop(Phase phase, float clt, SensorResult tps, float crankingTaperFraction) = 0; virtual float getClosedLoop(Phase phase, float tps, int rpm, int target) = 0; virtual float getCrankingTaperFraction() const = 0; @@ -50,7 +50,7 @@ public: // OPEN LOOP CORRECTIONS percent_t getCrankingOpenLoop(float clt) const override; - percent_t getRunningOpenLoop(float clt, SensorResult tps) const override; + percent_t getRunningOpenLoop(float clt, SensorResult tps) override; percent_t getOpenLoop(Phase phase, float clt, SensorResult tps, float crankingTaperFraction) override; float getIdleTimingAdjustment(int rpm) override; diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/IdleState.java b/java_console/models/src/main/java/com/rusefi/config/generated/IdleState.java index 66ee1bcadb..8bce594286 100644 --- a/java_console/models/src/main/java/com/rusefi/config/generated/IdleState.java +++ b/java_console/models/src/main/java/com/rusefi/config/generated/IdleState.java @@ -1,6 +1,6 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Tue Jan 11 14:08:37 EST 2022 +// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Sun Apr 03 19:52:33 EDT 2022 // by class com.rusefi.output.FileJavaFieldsConsumer import com.rusefi.config.*; @@ -9,45 +9,47 @@ public class IdleState { public static final Field IDLESTATE = Field.create("IDLESTATE", 0, FieldType.INT); public static final Field CURRENTIDLEPOSITION = Field.create("CURRENTIDLEPOSITION", 4, FieldType.FLOAT); public static final Field BASEIDLEPOSITION = Field.create("BASEIDLEPOSITION", 8, FieldType.FLOAT); - public static final Field THROTTLEPEDALUPSTATE = Field.create("THROTTLEPEDALUPSTATE", 12, FieldType.INT); - public static final Field MIGHTRESETPID = Field.create("MIGHTRESETPID", 16, FieldType.BIT, 0); - public static final Field SHOULDRESETPID = Field.create("SHOULDRESETPID", 16, FieldType.BIT, 1); - public static final Field WASRESETPID = Field.create("WASRESETPID", 16, FieldType.BIT, 2); - public static final Field MUSTRESETPID = Field.create("MUSTRESETPID", 16, FieldType.BIT, 3); - public static final Field ISCOASTING = Field.create("ISCOASTING", 16, FieldType.BIT, 4); - public static final Field USEIACTABLEFORCOASTING = Field.create("USEIACTABLEFORCOASTING", 16, FieldType.BIT, 5); - public static final Field NOTIDLING = Field.create("NOTIDLING", 16, FieldType.BIT, 6); - public static final Field NEEDRESET = Field.create("NEEDRESET", 16, FieldType.BIT, 7); - public static final Field ISINDEADZONE = Field.create("ISINDEADZONE", 16, FieldType.BIT, 8); - public static final Field ISBLIPPING = Field.create("ISBLIPPING", 16, FieldType.BIT, 9); - public static final Field USECLOSEDLOOP = Field.create("USECLOSEDLOOP", 16, FieldType.BIT, 10); - public static final Field BADTPS = Field.create("BADTPS", 16, FieldType.BIT, 11); - public static final Field LOOKSLIKERUNNING = Field.create("LOOKSLIKERUNNING", 16, FieldType.BIT, 12); - public static final Field LOOKSLIKECOASTING = Field.create("LOOKSLIKECOASTING", 16, FieldType.BIT, 13); - public static final Field LOOKSLIKECRANKTOIDLE = Field.create("LOOKSLIKECRANKTOIDLE", 16, FieldType.BIT, 14); - public static final Field USEINSTANTRPMFORIDLE = Field.create("USEINSTANTRPMFORIDLE", 16, FieldType.BIT, 15); - public static final Field ISVERBOSEIAC = Field.create("ISVERBOSEIAC", 16, FieldType.BIT, 16); - public static final Field UNUSEDBIT_21_17 = Field.create("UNUSEDBIT_21_17", 16, FieldType.BIT, 17); - public static final Field UNUSEDBIT_21_18 = Field.create("UNUSEDBIT_21_18", 16, FieldType.BIT, 18); - public static final Field UNUSEDBIT_21_19 = Field.create("UNUSEDBIT_21_19", 16, FieldType.BIT, 19); - public static final Field UNUSEDBIT_21_20 = Field.create("UNUSEDBIT_21_20", 16, FieldType.BIT, 20); - public static final Field UNUSEDBIT_21_21 = Field.create("UNUSEDBIT_21_21", 16, FieldType.BIT, 21); - public static final Field UNUSEDBIT_21_22 = Field.create("UNUSEDBIT_21_22", 16, FieldType.BIT, 22); - public static final Field UNUSEDBIT_21_23 = Field.create("UNUSEDBIT_21_23", 16, FieldType.BIT, 23); - public static final Field UNUSEDBIT_21_24 = Field.create("UNUSEDBIT_21_24", 16, FieldType.BIT, 24); - public static final Field UNUSEDBIT_21_25 = Field.create("UNUSEDBIT_21_25", 16, FieldType.BIT, 25); - public static final Field UNUSEDBIT_21_26 = Field.create("UNUSEDBIT_21_26", 16, FieldType.BIT, 26); - public static final Field UNUSEDBIT_21_27 = Field.create("UNUSEDBIT_21_27", 16, FieldType.BIT, 27); - public static final Field UNUSEDBIT_21_28 = Field.create("UNUSEDBIT_21_28", 16, FieldType.BIT, 28); - public static final Field UNUSEDBIT_21_29 = Field.create("UNUSEDBIT_21_29", 16, FieldType.BIT, 29); - public static final Field UNUSEDBIT_21_30 = Field.create("UNUSEDBIT_21_30", 16, FieldType.BIT, 30); - public static final Field UNUSEDBIT_21_31 = Field.create("UNUSEDBIT_21_31", 16, FieldType.BIT, 31); - public static final Field TARGETRPMBYCLT = Field.create("TARGETRPMBYCLT", 20, FieldType.INT); - public static final Field TARGETRPMACBUMP = Field.create("TARGETRPMACBUMP", 24, FieldType.INT); + public static final Field IACBYTPSTAPER = Field.create("IACBYTPSTAPER", 12, FieldType.FLOAT); + public static final Field THROTTLEPEDALUPSTATE = Field.create("THROTTLEPEDALUPSTATE", 16, FieldType.INT); + public static final Field MIGHTRESETPID = Field.create("MIGHTRESETPID", 20, FieldType.BIT, 0); + public static final Field SHOULDRESETPID = Field.create("SHOULDRESETPID", 20, FieldType.BIT, 1); + public static final Field WASRESETPID = Field.create("WASRESETPID", 20, FieldType.BIT, 2); + public static final Field MUSTRESETPID = Field.create("MUSTRESETPID", 20, FieldType.BIT, 3); + public static final Field ISCOASTING = Field.create("ISCOASTING", 20, FieldType.BIT, 4); + public static final Field USEIACTABLEFORCOASTING = Field.create("USEIACTABLEFORCOASTING", 20, FieldType.BIT, 5); + public static final Field NOTIDLING = Field.create("NOTIDLING", 20, FieldType.BIT, 6); + public static final Field NEEDRESET = Field.create("NEEDRESET", 20, FieldType.BIT, 7); + public static final Field ISINDEADZONE = Field.create("ISINDEADZONE", 20, FieldType.BIT, 8); + public static final Field ISBLIPPING = Field.create("ISBLIPPING", 20, FieldType.BIT, 9); + public static final Field USECLOSEDLOOP = Field.create("USECLOSEDLOOP", 20, FieldType.BIT, 10); + public static final Field BADTPS = Field.create("BADTPS", 20, FieldType.BIT, 11); + public static final Field LOOKSLIKERUNNING = Field.create("LOOKSLIKERUNNING", 20, FieldType.BIT, 12); + public static final Field LOOKSLIKECOASTING = Field.create("LOOKSLIKECOASTING", 20, FieldType.BIT, 13); + public static final Field LOOKSLIKECRANKTOIDLE = Field.create("LOOKSLIKECRANKTOIDLE", 20, FieldType.BIT, 14); + public static final Field USEINSTANTRPMFORIDLE = Field.create("USEINSTANTRPMFORIDLE", 20, FieldType.BIT, 15); + public static final Field ISVERBOSEIAC = Field.create("ISVERBOSEIAC", 20, FieldType.BIT, 16); + public static final Field UNUSEDBIT_22_17 = Field.create("UNUSEDBIT_22_17", 20, FieldType.BIT, 17); + public static final Field UNUSEDBIT_22_18 = Field.create("UNUSEDBIT_22_18", 20, FieldType.BIT, 18); + public static final Field UNUSEDBIT_22_19 = Field.create("UNUSEDBIT_22_19", 20, FieldType.BIT, 19); + public static final Field UNUSEDBIT_22_20 = Field.create("UNUSEDBIT_22_20", 20, FieldType.BIT, 20); + public static final Field UNUSEDBIT_22_21 = Field.create("UNUSEDBIT_22_21", 20, FieldType.BIT, 21); + public static final Field UNUSEDBIT_22_22 = Field.create("UNUSEDBIT_22_22", 20, FieldType.BIT, 22); + public static final Field UNUSEDBIT_22_23 = Field.create("UNUSEDBIT_22_23", 20, FieldType.BIT, 23); + public static final Field UNUSEDBIT_22_24 = Field.create("UNUSEDBIT_22_24", 20, FieldType.BIT, 24); + public static final Field UNUSEDBIT_22_25 = Field.create("UNUSEDBIT_22_25", 20, FieldType.BIT, 25); + public static final Field UNUSEDBIT_22_26 = Field.create("UNUSEDBIT_22_26", 20, FieldType.BIT, 26); + public static final Field UNUSEDBIT_22_27 = Field.create("UNUSEDBIT_22_27", 20, FieldType.BIT, 27); + public static final Field UNUSEDBIT_22_28 = Field.create("UNUSEDBIT_22_28", 20, FieldType.BIT, 28); + public static final Field UNUSEDBIT_22_29 = Field.create("UNUSEDBIT_22_29", 20, FieldType.BIT, 29); + public static final Field UNUSEDBIT_22_30 = Field.create("UNUSEDBIT_22_30", 20, FieldType.BIT, 30); + public static final Field UNUSEDBIT_22_31 = Field.create("UNUSEDBIT_22_31", 20, FieldType.BIT, 31); + public static final Field TARGETRPMBYCLT = Field.create("TARGETRPMBYCLT", 24, FieldType.INT); + public static final Field TARGETRPMACBUMP = Field.create("TARGETRPMACBUMP", 28, FieldType.INT); public static final Field[] VALUES = { IDLESTATE, CURRENTIDLEPOSITION, BASEIDLEPOSITION, + IACBYTPSTAPER, THROTTLEPEDALUPSTATE, MIGHTRESETPID, SHOULDRESETPID, @@ -66,21 +68,21 @@ public class IdleState { LOOKSLIKECRANKTOIDLE, USEINSTANTRPMFORIDLE, ISVERBOSEIAC, - UNUSEDBIT_21_17, - UNUSEDBIT_21_18, - UNUSEDBIT_21_19, - UNUSEDBIT_21_20, - UNUSEDBIT_21_21, - UNUSEDBIT_21_22, - UNUSEDBIT_21_23, - UNUSEDBIT_21_24, - UNUSEDBIT_21_25, - UNUSEDBIT_21_26, - UNUSEDBIT_21_27, - UNUSEDBIT_21_28, - UNUSEDBIT_21_29, - UNUSEDBIT_21_30, - UNUSEDBIT_21_31, + UNUSEDBIT_22_17, + UNUSEDBIT_22_18, + UNUSEDBIT_22_19, + UNUSEDBIT_22_20, + UNUSEDBIT_22_21, + UNUSEDBIT_22_22, + UNUSEDBIT_22_23, + UNUSEDBIT_22_24, + UNUSEDBIT_22_25, + UNUSEDBIT_22_26, + UNUSEDBIT_22_27, + UNUSEDBIT_22_28, + UNUSEDBIT_22_29, + UNUSEDBIT_22_30, + UNUSEDBIT_22_31, TARGETRPMBYCLT, TARGETRPMACBUMP, }; diff --git a/unit_tests/mocks.h b/unit_tests/mocks.h index 75c6dece9d..fb637373e0 100644 --- a/unit_tests/mocks.h +++ b/unit_tests/mocks.h @@ -122,7 +122,7 @@ class MockIdleController : public IIdleController { MOCK_METHOD(IIdleController::Phase, determinePhase, (int rpm, int targetRpm, SensorResult tps, float vss, float crankingTaperFraction), (override)); MOCK_METHOD(int, getTargetRpm, (float clt), (override)); MOCK_METHOD(float, getCrankingOpenLoop, (float clt), (const, override)); - MOCK_METHOD(float, getRunningOpenLoop, (float clt, SensorResult tps), (const, override)); + MOCK_METHOD(float, getRunningOpenLoop, (float clt, SensorResult tps), (override)); MOCK_METHOD(float, getOpenLoop, (IIdleController::Phase phase, float clt, SensorResult tps, float crankingTaperFraction), (override)); MOCK_METHOD(float, getClosedLoop, (IIdleController::Phase phase, float tps, int rpm, int target), (override)); MOCK_METHOD(float, getCrankingTaperFraction, (), (const, override)); diff --git a/unit_tests/tests/test_idle_controller.cpp b/unit_tests/tests/test_idle_controller.cpp index c0f27810fe..95881865c1 100644 --- a/unit_tests/tests/test_idle_controller.cpp +++ b/unit_tests/tests/test_idle_controller.cpp @@ -211,7 +211,7 @@ TEST(idle_v2, runningOpenLoopTpsTaper) { struct MockOpenLoopIdler : public IdleController { MOCK_METHOD(float, getCrankingOpenLoop, (float clt), (const, override)); - MOCK_METHOD(float, getRunningOpenLoop, (float clt, SensorResult tps), (const, override)); + MOCK_METHOD(float, getRunningOpenLoop, (float clt, SensorResult tps), (override)); }; TEST(idle_v2, testOpenLoopCranking) {