Add battery voltage correction code

This commit is contained in:
Josh Stewart 2015-04-04 21:10:13 +11:00
parent 3f2cd5cad3
commit 234612ad04
4 changed files with 17 additions and 5 deletions

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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.