diff --git a/comms.ino b/comms.ino index 3727b2f3..e8e192d0 100644 --- a/comms.ino +++ b/comms.ino @@ -120,7 +120,7 @@ This function returns the current values of a fixed group of variables */ void sendValues(int length) { - byte packetSize = 28; + byte packetSize = 29; byte response[packetSize]; response[0] = currentStatus.secl; //secl is simply a counter that increments each second. Used to track unexpected resets (Which will reset this count to 0) @@ -156,8 +156,7 @@ void sendValues(int length) response[26] = highByte(currentStatus.freeRAM); //(byte)((currentStatus.loopsPerSecond >> 8) & 0xFF); response[27] = lowByte(currentStatus.freeRAM); - //response[26] = highByte(cltCalibrationTable.axisX16[0]); //(byte)((currentStatus.loopsPerSecond >> 8) & 0xFF); - //response[27] = lowByte(cltCalibrationTable.axisX16[0]); + response[28] = currentStatus.batCorrection; //Battery voltage correction (%) Serial.write(response, (size_t)packetSize); diff --git a/corrections.ino b/corrections.ino index 65d675fd..004030ba 100644 --- a/corrections.ino +++ b/corrections.ino @@ -32,6 +32,8 @@ byte correctionsTotal() if (result != 100) { sumCorrections = div((sumCorrections * result), 100).quot; } currentStatus.egoCorrection = correctionsAFRClosedLoop(); if (currentStatus.egoCorrection != 100) { sumCorrections = div((sumCorrections * currentStatus.egoCorrection), 100).quot; } + currentStatus.batCorrection = correctionsBatVoltage(); + if (currentStatus.batCorrection != 100) { sumCorrections = div((sumCorrections * currentStatus.batCorrection), 100).quot; } if(sumCorrections > 255) { sumCorrections = 255; } //This is the maximum allowable increase return (byte)sumCorrections; @@ -139,6 +141,15 @@ byte correctionFloodClear() return 100; } +/* +Battery Voltage correction +Uses a 2D enrichment table (WUETable) where the X axis is engine temp and the Y axis is the amount of extra fuel to add +*/ +byte correctionsBatVoltage() +{ + return table2D_getValue(injectorVCorrectionTable, currentStatus.battery10); +} + /* Lookup the AFR target table and perform either a simple or PID adjustment based on this diff --git a/globals.h b/globals.h index ebc427c7..c29b2aea 100644 --- a/globals.h +++ b/globals.h @@ -66,7 +66,8 @@ struct statuses { byte corrections; byte TAEamount; //The amount of accleration enrichment currently being applied byte egoCorrection; //The amount of closed loop AFR enrichment currently being applied - byte wueCorrection; //The amount of closed loop AFR enrichment currently being applied + byte wueCorrection; //The amount of warmup enrichment currently being applied + byte batCorrection; //The amount of battery voltage enrichment currently being applied byte afrTarget; unsigned long TAEEndTime; //The target end time used whenever TAE is turned on volatile byte squirt; diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 65be0679..f252acea 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -897,7 +897,7 @@ help = helpEnrichments, "Enrichments Help" ochGetCommand = "A" - ochBlockSize = 28 + ochBlockSize = 29 secl = scalar, U08, 0, "sec", 1.000, 0.000 squirt = scalar, U08, 1, "bits", 1.000, 0.000 @@ -941,6 +941,7 @@ help = helpEnrichments, "Enrichments Help" tps = scalar, U08, 23, "%", 1.000, 0.000 loopsPerSecond = scalar, S16, 24, "loops", 1.000, 0.000 freeRAM = scalar, S16, 26, "bytes", 1.000, 0.000 + batCorrection = scalar, U08, 28, "%", 1.000, 0.000 ; Computed output channels. See "megatuneExamples.ini" for all the ; pre-defined variables, search for "???" and you'll see them.