[AE] Introduce ReqFuel % multiplier (#332)

Co-authored-by: Josh Stewart <josh@noisymime.org>
This commit is contained in:
Vitor Moreno B. Sales 2020-08-15 20:44:03 -03:00 committed by GitHub
parent 20ee2c88a5
commit 8299c74d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View File

@ -248,7 +248,8 @@ page = 1
aeMode = bits, U08, 3, [0:1], "TPS", "MAP", "INVALID", "INVALID"
battVCorMode = bits, U08, 3, [2:2], "Whole PW", "Open Time only"
SoftLimitMode = bits, U08, 3, [3:3], "Fixed", "Relative "
unused1-3c = bits, U08, 3, [4:5], "MAP", "TPS", "INVALID", "INVALID"
unused1-3c = bits, U08, 3, [4:4], "MAP", "TPS"
aeApplyMode = bits, U08, 3, [5:5], "PW Multiplier", "PW Adder"
multiplyMAP = bits, U08, 3, [6:7], "Off", "Baro", "Fixed", "INVALID"
wueRates = array, U08, 4, [10], "%", 1.0, 0.0, 0.0, 255, 0
crankingPct = scalar, U08, 14, "%", 1.0, 0.0, 0.0, 255, 0
@ -1344,6 +1345,7 @@ page = 13
defaultValue = aeColdTaperMax, 60
defaultValue = aeMode, 0 ;Set aeMode to TPS
defaultValue = batVoltCorrect, 0
defaultValue = aeApplyMode, 0
defaultValue = legacyMAP, 0
defaultValue = battVCorMode, 1
defaultValue = idleAdvEnabled, 0 ;Idle advance control turned off
@ -2186,6 +2188,7 @@ menuDialog = main
dialog = accelEnrichments_aeSettings, ""
field = "Enrichment mode", aeMode
field = "Enrichment method", aeApplyMode
field = "TPSdot Threshold", taeThresh, { aeMode == 0 }
field = "MAPdot Threshold", maeThresh, { aeMode == 1 }
field = "Accel Time", aeTime

View File

@ -65,8 +65,11 @@ uint16_t correctionsFuel()
if (activeCorrections == MAX_CORRECTIONS) { sumCorrections = sumCorrections / powint(100,activeCorrections); activeCorrections = 0; } // Need to check this to ensure that sumCorrections doesn't overflow. Can occur when the number of corrections is greater than 3 (Which is 100^4) as 100^5 can overflow
currentStatus.AEamount = correctionAccel();
if (configPage2.aeApplyMode == AE_MODE_MULTIPLIER)
{
if (currentStatus.AEamount != 100) { sumCorrections = (sumCorrections * currentStatus.AEamount); activeCorrections++; }
if (activeCorrections == MAX_CORRECTIONS) { sumCorrections = sumCorrections / powint(100,activeCorrections); activeCorrections = 0; }
}
result = correctionFloodClear();
if (result != 100) { sumCorrections = (sumCorrections * result); activeCorrections++; }

View File

@ -245,6 +245,9 @@
#define AE_MODE_TPS 0
#define AE_MODE_MAP 1
#define AE_MODE_MULTIPLIER 0
#define AE_MODE_ADDER 1
#define KNOCK_MODE_OFF 0
#define KNOCK_MODE_DIGITAL 1
#define KNOCK_MODE_ANALOG 2
@ -619,7 +622,8 @@ struct config2 {
byte aeMode : 2; /**< Acceleration Enrichment mode. 0 = TPS, 1 = MAP. Values 2 and 3 reserved for potential future use (ie blended TPS / MAP) */
byte battVCorMode : 1;
byte SoftLimitMode : 1;
byte unused1_3c : 2;
byte unused1_3c : 1;
byte aeApplyMode : 1;
byte multiplyMAP : 2; //0 = off | 1 = baro | 2 = 100
byte wueValues[10]; //Warm up enrichment array (10 bytes)
byte crankingPct; //Cranking enrichment

View File

@ -1281,6 +1281,11 @@ uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
{
//If intermeditate is not 0, we need to add the opening time (0 typically indicates that one of the full fuel cuts is active)
intermediate += injOpen; //Add the injector opening time
//AE Adds % of req_fuel
if ( configPage2.aeApplyMode == AE_MODE_ADDER )
{
intermediate += ( ((unsigned long)REQ_FUEL) * (currentStatus.AEamount - 100) ) / 100;
}
if ( intermediate > 65535)
{
intermediate = 65535; //Make sure this won't overflow when we convert to uInt. This means the maximum pulsewidth possible is 65.535mS