From 1ba1dabbfba4af9b9a24c5b2c4ec34250781e98e Mon Sep 17 00:00:00 2001 From: "Vitor Moreno B. Sales" Date: Mon, 11 Apr 2022 00:38:23 -0300 Subject: [PATCH 1/2] Added idle advance start threshold (#747) * Added idle advance start threshold On lower temp and/or on ethanol the engine need to crank more, without this my starter get a kick and the engine backfires. This enable it only at 200 RPM below the target * Use define to idle advance RPM threshold Co-authored-by: Josh Stewart --- speeduino/corrections.h | 2 ++ speeduino/corrections.ino | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/speeduino/corrections.h b/speeduino/corrections.h index ccc39c68..bfed31f3 100644 --- a/speeduino/corrections.h +++ b/speeduino/corrections.h @@ -5,6 +5,8 @@ All functions in the gamma file return #ifndef CORRECTIONS_H #define CORRECTIONS_H +#define IGN_IDLE_THRESHOLD 200 //RPM threshold (below CL idle target) for when ign based idle control will engage + void initialiseCorrections(); uint16_t correctionsFuel(); diff --git a/speeduino/corrections.ino b/speeduino/corrections.ino index c034d537..b7de611c 100644 --- a/speeduino/corrections.ino +++ b/speeduino/corrections.ino @@ -43,6 +43,7 @@ int TPS_rateOfChange; byte activateMAPDOT; //The mapDOT value seen when the MAE was activated. byte activateTPSDOT; //The tpsDOT value seen when the MAE was activated. +bool idleAdvActive = false; uint16_t AFRnextCycle; unsigned long knockStartTime; byte lastKnockCount; @@ -761,7 +762,7 @@ int8_t correctionIdleAdvance(int8_t advance) int8_t ignIdleValue = advance; //Adjust the advance based on idle target rpm. - if( (configPage2.idleAdvEnabled >= 1) && (runSecsX10 >= (configPage2.idleAdvDelay * 5)) ) + if( (configPage2.idleAdvEnabled >= 1) && (runSecsX10 >= (configPage2.idleAdvDelay * 5)) && idleAdvActive) { currentStatus.CLIdleTarget = (byte)table2D_getValue(&idleTargetTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //All temps are offset by 40 degrees int idleRPMdelta = (currentStatus.CLIdleTarget - (currentStatus.RPM / 10) ) + 50; @@ -784,6 +785,10 @@ int8_t correctionIdleAdvance(int8_t advance) } else { idleAdvTaper = 0; } } + + if ( !idleAdvActive && BIT_CHECK(currentStatus.engine, BIT_ENGINE_RUN) && (currentStatus.RPM > (((uint16_t)currentStatus.CLIdleTarget * 10) - (uint16_t)IGN_IDLE_THRESHOLD)) ) { idleAdvActive = true; } //Active only after the engine is 200 RPM below target on first time + else if (idleAdvActive && !BIT_CHECK(currentStatus.engine, BIT_ENGINE_RUN)) { idleAdvActive = false; } //Clear flag if engine isn't running anymore + return ignIdleValue; } /** Ignition soft revlimit correction. From 7933bb68c4bf08aaf34a77b370bee164735e9094 Mon Sep 17 00:00:00 2001 From: tx_haggis <13982343+adbancroft@users.noreply.github.com> Date: Sun, 10 Apr 2022 23:16:26 -0500 Subject: [PATCH 2/2] Remove previousLoopTime - never used (#706) --- speeduino/globals.h | 1 - speeduino/globals.ino | 1 - speeduino/init.ino | 1 - speeduino/speeduino.ino | 1 - 4 files changed, 4 deletions(-) diff --git a/speeduino/globals.h b/speeduino/globals.h index 8bd345f7..71a178b1 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -583,7 +583,6 @@ extern volatile bool fpPrimed; //Tracks whether or not the fuel pump priming has extern volatile bool injPrimed; //Tracks whether or not the injector priming has been completed yet extern volatile unsigned int toothHistoryIndex; extern unsigned long currentLoopTime; /**< The time (in uS) that the current mainloop started */ -extern unsigned long previousLoopTime; /**< The time (in uS) that the previous mainloop started */ extern volatile uint16_t ignitionCount; /**< The count of ignition events that have taken place since the engine started */ //The below shouldn't be needed and probably should be cleaned up, but the Atmel SAM (ARM) boards use a specific type for the trigger edge values rather than a simple byte/int #if defined(CORE_SAMD21) diff --git a/speeduino/globals.ino b/speeduino/globals.ino index 4e3e1b40..56f496c0 100644 --- a/speeduino/globals.ino +++ b/speeduino/globals.ino @@ -139,7 +139,6 @@ volatile bool fpPrimed = false; ///< Tracks whether or not the fuel pump priming volatile bool injPrimed = false; ///< Tracks whether or not the injectors priming has been completed yet volatile unsigned int toothHistoryIndex = 0; ///< Current index to @ref toothHistory array unsigned long currentLoopTime; /**< The time (in uS) that the current mainloop started */ -unsigned long previousLoopTime; /**< The time (in uS) that the previous mainloop started */ volatile uint16_t ignitionCount; /**< The count of ignition events that have taken place since the engine started */ #if defined(CORE_SAMD21) PinStatus primaryTriggerEdge; diff --git a/speeduino/init.ino b/speeduino/init.ino index 6e1864a7..d6bce263 100644 --- a/speeduino/init.ino +++ b/speeduino/init.ino @@ -429,7 +429,6 @@ void initialiseAll() } //Initial values for loop times - previousLoopTime = 0; currentLoopTime = micros_safe(); mainLoopCount = 0; diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index 1aae8bf3..7e413e3a 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -182,7 +182,6 @@ void loop() //Displays currently disabled // if (configPage2.displayType && (mainLoopCount & 255) == 1) { updateDisplay();} - previousLoopTime = currentLoopTime; currentLoopTime = micros_safe(); unsigned long timeToLastTooth = (currentLoopTime - toothLastToothTime); if ( (timeToLastTooth < MAX_STALL_TIME) || (toothLastToothTime > currentLoopTime) ) //Check how long ago the last tooth was seen compared to now. If it was more than half a second ago then the engine is probably stopped. toothLastToothTime can be greater than currentLoopTime if a pulse occurs between getting the latest time and doing the comparison