From 840b165f12b9735251f481cfc5681d776b9c7251 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 30 Aug 2019 18:17:10 -0400 Subject: [PATCH] NA6 pnp: automatic idle VS TPS #800 --- .../controllers/actuators/idle_thread.cpp | 21 +++++++++++++++---- .../generated/engine_state_generated.h | 8 ++++--- firmware/integration/engine_state.txt | 2 +- .../rusefi/config/generated/EngineState.java | 6 +++--- .../rusefi/ldmp/generated/IdleThreadMeta.java | 4 +++- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index a45219b666..0833e34e44 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -178,12 +178,21 @@ static void undoIdleBlipIfNeeded() { } } +static bool isOutOfAutomaticIdleCondition(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); + + if (CONFIG(throttlePedalUpPin) != GPIO_UNASSIGNED) + return !engine->engineState.idle.throttlePedalUpState; + + return tpsPos > CONFIGB(idlePidDeactivationTpsThreshold); + +} + /** * @return idle valve position percentage for automatic closed loop mode */ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); - if (tpsPos > CONFIGB(idlePidDeactivationTpsThreshold)) { + if (isOutOfAutomaticIdleCondition(PASS_ENGINE_PARAMETER_SIGNATURE)) { // Don't store old I and D terms if PID doesn't work anymore. // Otherwise they will affect the idle position much later, when the throttle is closed. if (mightResetPid) { @@ -221,6 +230,8 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // the state of PID has been changed, so we might reset it now, but only when needed (see idlePidDeactivationTpsThreshold) mightResetPid = true; + percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); + #if EFI_IDLE_INCREMENTAL_PID_CIC // Treat the 'newValue' as if it contains not an actual IAC position, but an incremental delta. // So we add this delta to the base IAC position, with a smooth taper for TPS transients. @@ -294,7 +305,7 @@ public: engine->clutchUpState = efiReadPin(CONFIGB(clutchUpPin)); } if (CONFIG(throttlePedalUpPin) != GPIO_UNASSIGNED) { - engine->engineState.idle.throttleUpState = efiReadPin(CONFIG(throttlePedalUpPin)); + engine->engineState.idle.throttlePedalUpState = efiReadPin(CONFIG(throttlePedalUpPin)); } if (engineConfiguration->brakePedalPin != GPIO_UNASSIGNED) { @@ -514,8 +525,10 @@ void startIdleThread(Logging*sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { DISPLAY_TEXT(Position_with_Adjustments); engine->engineState.idle.DISPLAY_FIELD(currentIdlePosition) = -100.0f; DISPLAY_TEXT(EOL); + DISPLAY_TEXT(EOL); + DISPLAY_SENSOR(TPS); DISPLAY_TEXT(Throttle_Up_State); - DISPLAY(DISPLAY_FIELD(throttleUpState)); + DISPLAY(DISPLAY_FIELD(throttlePedalUpState)); DISPLAY(DISPLAY_CONFIG(throttlePedalUpPin)); diff --git a/firmware/controllers/generated/engine_state_generated.h b/firmware/controllers/generated/engine_state_generated.h index 68066f0b69..06487bca45 100644 --- a/firmware/controllers/generated/engine_state_generated.h +++ b/firmware/controllers/generated/engine_state_generated.h @@ -1,4 +1,4 @@ -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Fri Aug 30 17:08:45 EDT 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Fri Aug 30 18:02:22 EDT 2019 // by class com.rusefi.output.CHeaderConsumer // begin #ifndef CONTROLLERS_GENERATED_ENGINE_STATE_GENERATED_H @@ -97,9 +97,11 @@ struct idle_state_s { */ percent_t baseIdlePosition = (percent_t)0; /** + * true in IDLE throttle pedal state, false if driver is touching the pedal + * todo: better name for this field? * offset 12 */ - int throttleUpState = (int)0; + int throttlePedalUpState = (int)0; /** total size 16*/ }; @@ -243,4 +245,4 @@ typedef struct engine_state2_s engine_state2_s; #endif // end -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Fri Aug 30 17:08:45 EDT 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Fri Aug 30 18:02:22 EDT 2019 diff --git a/firmware/integration/engine_state.txt b/firmware/integration/engine_state.txt index b189385f27..35d833c79b 100644 --- a/firmware/integration/engine_state.txt +++ b/firmware/integration/engine_state.txt @@ -40,7 +40,7 @@ struct_no_prefix idle_state_s idle_state_e idleState percent_t currentIdlePosition;that's current position with CLT and IAT corrections percent_t baseIdlePosition;current position without adjustments (iacByTpsTaper, afterCrankingIACtaperDuration) - int throttleUpState + int throttlePedalUpState;true in IDLE throttle pedal state, false if driver is touching the pedal\ntodo: better name for this field? ! end of idle_state_s structure definition end_struct diff --git a/java_console/models/src/com/rusefi/config/generated/EngineState.java b/java_console/models/src/com/rusefi/config/generated/EngineState.java index e043ef59c7..3c42a76e90 100644 --- a/java_console/models/src/com/rusefi/config/generated/EngineState.java +++ b/java_console/models/src/com/rusefi/config/generated/EngineState.java @@ -1,6 +1,6 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Fri Aug 30 17:08:45 EDT 2019 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Fri Aug 30 18:02:22 EDT 2019 // by class com.rusefi.output.JavaFieldsConsumer import com.rusefi.config.*; @@ -23,7 +23,7 @@ public class EngineState { public static final Field IDLESTATE = Field.create("IDLESTATE", 32, FieldType.INT); public static final Field CURRENTIDLEPOSITION = Field.create("CURRENTIDLEPOSITION", 36, FieldType.FLOAT); public static final Field BASEIDLEPOSITION = Field.create("BASEIDLEPOSITION", 40, FieldType.FLOAT); - public static final Field THROTTLEUPSTATE = Field.create("THROTTLEUPSTATE", 44, FieldType.INT); + public static final Field THROTTLEPEDALUPSTATE = Field.create("THROTTLEPEDALUPSTATE", 44, FieldType.INT); public static final Field TARGETAFR = Field.create("TARGETAFR", 48, FieldType.FLOAT); public static final Field ENGINECYCLEDURATIONMS = Field.create("ENGINECYCLEDURATIONMS", 52, FieldType.FLOAT); public static final Field MINRPMKCURRENTTPS = Field.create("MINRPMKCURRENTTPS", 56, FieldType.FLOAT); @@ -64,7 +64,7 @@ public class EngineState { IDLESTATE, CURRENTIDLEPOSITION, BASEIDLEPOSITION, - THROTTLEUPSTATE, + THROTTLEPEDALUPSTATE, TARGETAFR, ENGINECYCLEDURATIONMS, MINRPMKCURRENTTPS, diff --git a/java_console/ui/src/com/rusefi/ldmp/generated/IdleThreadMeta.java b/java_console/ui/src/com/rusefi/ldmp/generated/IdleThreadMeta.java index 1594a0726d..07d6dcc2c6 100644 --- a/java_console/ui/src/com/rusefi/ldmp/generated/IdleThreadMeta.java +++ b/java_console/ui/src/com/rusefi/ldmp/generated/IdleThreadMeta.java @@ -12,8 +12,10 @@ public class IdleThreadMeta { new TextRequest("Position_with_Adjustments"), new FieldRequest("currentIdlePosition"), new TextRequest("EOL"), + new TextRequest("EOL"), + new SensorRequest("TPS"), new TextRequest("Throttle_Up_State"), - new FieldRequest("throttleUpState"), + new FieldRequest("throttlePedalUpState"), new ConfigRequest("throttlePedalUpPin"), }; } \ No newline at end of file