From 1fefada496265371aadf4f215c49133cc991c1a3 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Tue, 21 Jun 2016 17:26:05 +1000 Subject: [PATCH] IncludeAFR option added --- reference/speeduino.ini | 3 ++- utils.ino | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 1f70f423..a235fb78 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -627,6 +627,7 @@ page = 8 ignCranklock = "On certain low resolution ignition patterns, the cranking timing can be locked to occur when a pulse is recieved." multiplyMAP = "If enabled, the MAP reading is included directly into the pulsewidth calculation. This results in a flatter VE table that can be easier to tune in some instances" + includeAFR = "When enabled, the current AFR reading is included directly in the pulsewidth calculation as a percentage of the stoichiometric ration." [UserDefinedTS] @@ -688,7 +689,7 @@ page = 8 dialog = veTableDialog_south, "" field = "Multiply VE value by MAP", multiplyMAP - field = "Include AFR directly", includeAFR, { 1 == 0 } + field = "Include AFR directly", includeAFR, { egoType == 2 } dialog = veTableDialog, "VE Table" panel = veTableDialog_north, North diff --git a/utils.ino b/utils.ino index 3c2027b7..29538ac0 100644 --- a/utils.ino +++ b/utils.ino @@ -327,17 +327,19 @@ unsigned int PW(int REQ_FUEL, byte VE, byte MAP, int corrections, int injOpen, b //Standard float version of the calculation //return (REQ_FUEL * (float)(VE/100.0) * (float)(MAP/100.0) * (float)(TPS/100.0) * (float)(corrections/100.0) + injOpen); //Note: The MAP and TPS portions are currently disabled, we use VE and corrections only - int iVE, iMAP, iCorrections, iTPS; + int iVE, iMAP, iAFR, iCorrections, iTPS; //100% float free version, does sacrifice a little bit of accuracy, but not much. iVE = ((int)VE << 7) / 100; - if( configPage1.multiplyMAP ) { iMAP = ((int)MAP << 7) / currentStatus.baro; } + if( configPage1.multiplyMAP ) { iMAP = ((int)MAP << 7) / currentStatus.baro; } //Include multiply MAP (vs baro) if enabled + if( configPage1.includeAFR ) { iAFR = ((int)currentStatus.O2 << 7) / configPage1.stoich; } //Include AFR (vs stoich) if enabled iCorrections = (corrections << 7) / 100; //int iTPS = ((int)TPS << 7) / 100; unsigned long intermediate = ((long)REQ_FUEL * (long)iVE) >> 7; //Need to use an intermediate value to avoid overflowing the long if( configPage1.multiplyMAP ) { intermediate = (intermediate * iMAP) >> 7; } + if( configPage1.includeAFR ) { intermediate = (intermediate * iAFR) >> 7; } intermediate = (intermediate * iCorrections) >> 7; //intermediate = (intermediate * iTPS) >> 7; if(intermediate == 0) { return 0; } //If the pulsewidth is 0, we return here before the opening time gets added