Load and save routines for the 4 fuel trim tables

This commit is contained in:
Josh Stewart 2016-10-25 17:31:44 +11:00
parent a4593ae339
commit 1f87c31e01
4 changed files with 266 additions and 47 deletions

View File

@ -496,7 +496,15 @@ page = 9
fuelTrim4loadBins = array, U08, 186,[ 6], "TPS", 1.0, 0.0, 0.0, 255.0, 0
#endif
unused9-192 = scalar, U08, 192, "RPM", 100.0, 0.0, 100, 25500, 0
fuelTrimEnabled = bits, U08, 192, [0:0], "No", "Yes"
unused9-192b = bits, U08, 192, [1:1], "No", "Yes"
unused9-192c = bits, U08, 192, [2:2], "No", "Yes"
unused9-192d = bits, U08, 192, [3:3], "No", "Yes"
unused9-192e = bits, U08, 192, [4:4], "No", "Yes"
unused9-192f = bits, U08, 192, [5:5], "No", "Yes"
unused9-192g = bits, U08, 192, [6:6], "No", "Yes"
unused9-192h = bits, U08, 192, [7:7], "No", "Yes"
unused9-193 = scalar, U08, 193, "RPM", 100.0, 0.0, 100, 25500, 0
unused9-194 = scalar, U08, 194, "RPM", 100.0, 0.0, 100, 25500, 0
unused9-195 = scalar, U08, 195, "RPM", 100.0, 0.0, 100, 25500, 0
@ -1000,13 +1008,13 @@ menuDialog = main
;Fuel trim composite dialog
dialog = inj_trim1TblTitle, "Channel #1"
panel = fuelTrimTable1Tbl, Center
panel = fuelTrimTable1Tbl, Center, { fuelTrimEnabled }
dialog = inj_trim2TblTitle, "Channel #2"
panel = fuelTrimTable1Tbl
panel = fuelTrimTable2Tbl, { fuelTrimEnabled }
dialog = inj_trim3TblTitle, "Channel #3"
panel = fuelTrimTable1Tbl
panel = fuelTrimTable3Tbl, { fuelTrimEnabled }
dialog = inj_trim4TblTitle, "Channel #4"
panel = fuelTrimTable1Tbl
panel = fuelTrimTable4Tbl, { fuelTrimEnabled }
dialog = inj_trimadt, "", xAxis
panel = inj_trim1TblTitle
@ -1016,9 +1024,9 @@ menuDialog = main
panel = inj_trim4TblTitle
dialog = inj_trimad,"Injector Cyl 1-4 Trims", yAxis
topicHelp = "file://$getProjectsDirPath()/docs/Megasquirt3_TunerStudio_MS_Lite_Reference-1.4.pdf#injtrim1-4"
panel = inj_trimadt
panel = inj_trimadb
field = "Individual fuel trim enabled", fuelTrimEnabled
panel = inj_trimadt, North
panel = inj_trimadb, South
;-------------------------------------------------------------------------------
; General help text
@ -1198,19 +1206,62 @@ menuDialog = main
upDownLabel = "HIGHER", "LOWER"
;--------- Sequential fuel trim maps -----------
table = fuelTrimTable1Tbl, fuelTrimTable1Map, "Fuel trim Table", 9
topicHelp = "http://speeduino.com/wiki/index.php/Tuning"
xBins = fuelTrim1rpmBins, rpm
#if SPEED_DENSITY
yBins = fuelTrim1loadBins, map
#else
yBins = fuelTrim1loadBins, throttle
#endif
zBins = fuelTrim1Table
table = fuelTrimTable1Tbl, fuelTrimTable1Map, "Fuel trim Table", 9
topicHelp = "http://speeduino.com/wiki/index.php/Tuning"
xBins = fuelTrim1rpmBins, rpm
#if SPEED_DENSITY
yBins = fuelTrim1loadBins, map
#else
yBins = fuelTrim1loadBins, throttle
#endif
zBins = fuelTrim1Table
gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"
gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"
table = fuelTrimTable2Tbl, fuelTrimTable2Map, "Fuel trim Table", 9
topicHelp = "http://speeduino.com/wiki/index.php/Tuning"
xBins = fuelTrim2rpmBins, rpm
#if SPEED_DENSITY
yBins = fuelTrim2loadBins, map
#else
yBins = fuelTrim2loadBins, throttle
#endif
zBins = fuelTrim2Table
gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"
table = fuelTrimTable3Tbl, fuelTrimTable3Map, "Fuel trim Table", 9
topicHelp = "http://speeduino.com/wiki/index.php/Tuning"
xBins = fuelTrim3rpmBins, rpm
#if SPEED_DENSITY
yBins = fuelTrim3loadBins, map
#else
yBins = fuelTrim3loadBins, throttle
#endif
zBins = fuelTrim3Table
gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"
table = fuelTrimTable4Tbl, fuelTrimTable4Map, "Fuel trim Table", 9
topicHelp = "http://speeduino.com/wiki/index.php/Tuning"
xBins = fuelTrim4rpmBins, rpm
#if SPEED_DENSITY
yBins = fuelTrim4loadBins, map
#else
yBins = fuelTrim4loadBins, throttle
#endif
zBins = fuelTrim4Table
gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"
;-------------------------------------------------------------------------------

View File

@ -74,6 +74,10 @@ struct table3D ignitionTable; //16x16 ignition map
struct table3D afrTable; //16x16 afr target map
struct table3D boostTable; //8x8 boost map
struct table3D vvtTable; //8x8 vvt map
struct table3D trim1Table; //6x6 Fuel trim 1 map
struct table3D trim2Table; //6x6 Fuel trim 2 map
struct table3D trim3Table; //6x6 Fuel trim 3 map
struct table3D trim4Table; //6x6 Fuel trim 4 map
struct table2D taeTable; //4 bin TPS Acceleration Enrichment map (2D)
struct table2D WUETable; //10 bin Warm Up Enrichment map (2D)
struct table2D dwellVCorrectionTable; //6 bin dwell voltage correction (2D)
@ -163,6 +167,10 @@ void setup()
table3D_setSize(&afrTable, 16);
table3D_setSize(&boostTable, 8);
table3D_setSize(&vvtTable, 8);
table3D_setSize(&trim1Table, 6);
table3D_setSize(&trim2Table, 6);
table3D_setSize(&trim3Table, 6);
table3D_setSize(&trim4Table, 6);
loadConfig();
@ -738,6 +746,19 @@ void setup()
ign5EndFunction = endCoil5Charge;
}
break;
case IGN_MODE_SEQUENTIAL:
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
ign3StartFunction = beginCoil3Charge;
ign3EndFunction = endCoil3Charge;
ign4StartFunction = beginCoil4Charge;
ign4EndFunction = endCoil4Charge;
ign5StartFunction = beginCoil5Charge;
ign5EndFunction = endCoil5Charge;
break;
default:
//Wasted spark (Shouldn't ever happen anyway)
@ -873,7 +894,7 @@ void loop()
//And check whether the tooth log buffer is ready
if(toothHistoryIndex > TOOTH_LOG_SIZE) { BIT_SET(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); }
}
if(toothHistoryIndex > TOOTH_LOG_SIZE) { BIT_SET(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); }
//The IAT and CLT readings can be done less frequently. This still runs about 4 times per second
if ((mainLoopCount & 255) == 1)
{

View File

@ -39,40 +39,61 @@ Current layout of EEPROM data (Version 3) is as follows (All sizes are in bytes)
-----------------------------------------------------
*/
#define EEPROM_CONFIG1_XSIZE 1
#define EEPROM_CONFIG1_YSIZE 2
#define EEPROM_CONFIG1_MAP 3
#define EEPROM_CONFIG1_XBINS 259
#define EEPROM_CONFIG1_YBINS 275
#define EEPROM_CONFIG2_START 291
#define EEPROM_CONFIG2_END 355 // +64 131
#define EEPROM_CONFIG3_XSIZE 355
#define EEPROM_CONFIG3_YSIZE 356
#define EEPROM_CONFIG3_MAP 357
#define EEPROM_CONFIG3_XBINS 613
#define EEPROM_CONFIG3_YBINS 629
#define EEPROM_CONFIG4_START 645
#define EEPROM_CONFIG4_END 709
#define EEPROM_CONFIG5_XSIZE 709
#define EEPROM_CONFIG5_YSIZE 710
#define EEPROM_CONFIG5_MAP 711
#define EEPROM_CONFIG5_XBINS 967
#define EEPROM_CONFIG5_YBINS 983
#define EEPROM_CONFIG6_START 999
#define EEPROM_CONFIG6_END 1063
#define EEPROM_CONFIG7_START 1063
#define EEPROM_CONFIG7_END 1127
#define EEPROM_CONFIG1_XSIZE 1
#define EEPROM_CONFIG1_YSIZE 2
#define EEPROM_CONFIG1_MAP 3
#define EEPROM_CONFIG1_XBINS 259
#define EEPROM_CONFIG1_YBINS 275
#define EEPROM_CONFIG2_START 291
#define EEPROM_CONFIG2_END 355 // +64 131
#define EEPROM_CONFIG3_XSIZE 355
#define EEPROM_CONFIG3_YSIZE 356
#define EEPROM_CONFIG3_MAP 357
#define EEPROM_CONFIG3_XBINS 613
#define EEPROM_CONFIG3_YBINS 629
#define EEPROM_CONFIG4_START 645
#define EEPROM_CONFIG4_END 709
#define EEPROM_CONFIG5_XSIZE 709
#define EEPROM_CONFIG5_YSIZE 710
#define EEPROM_CONFIG5_MAP 711
#define EEPROM_CONFIG5_XBINS 967
#define EEPROM_CONFIG5_YBINS 983
#define EEPROM_CONFIG6_START 999
#define EEPROM_CONFIG6_END 1063
#define EEPROM_CONFIG7_START 1063
#define EEPROM_CONFIG7_END 1127
#define EEPROM_CONFIG8_XSIZE1 1127
#define EEPROM_CONFIG8_YSIZE1 1128
#define EEPROM_CONFIG8_MAP1 1129
#define EEPROM_CONFIG8_MAP1 1129
#define EEPROM_CONFIG8_XBINS1 1193
#define EEPROM_CONFIG8_YBINS1 1201
#define EEPROM_CONFIG8_XSIZE2 1209
#define EEPROM_CONFIG8_YSIZE2 1210
#define EEPROM_CONFIG8_MAP2 1211
#define EEPROM_CONFIG8_MAP2 1211
#define EEPROM_CONFIG8_XBINS2 1275
#define EEPROM_CONFIG8_YBINS2 1283
#define EEPROM_CONFIG8_END 1291
#define EEPROM_CONFIG8_END 1291
#define EEPROM_CONFIG9_XSIZE1 1291
#define EEPROM_CONFIG9_YSIZE1 1292
#define EEPROM_CONFIG9_MAP1 1293
#define EEPROM_CONFIG9_XBINS1 1329
#define EEPROM_CONFIG9_YBINS1 1335
#define EEPROM_CONFIG9_XSIZE2 1341
#define EEPROM_CONFIG9_YSIZE2 1342
#define EEPROM_CONFIG9_MAP2 1343
#define EEPROM_CONFIG9_XBINS2 1379
#define EEPROM_CONFIG9_YBINS2 1385
//BELOW VALUES NOT YET RIGHT!!
#define EEPROM_CONFIG9_XSIZE3 1341
#define EEPROM_CONFIG9_YSIZE3 1342
#define EEPROM_CONFIG9_MAP3 1343
#define EEPROM_CONFIG9_XBINS3 1379
#define EEPROM_CONFIG9_YBINS3 1385
#define EEPROM_CONFIG9_XSIZE4 1341
#define EEPROM_CONFIG9_YSIZE4 1342
#define EEPROM_CONFIG9_MAP4 1343
#define EEPROM_CONFIG9_XBINS4 1379
#define EEPROM_CONFIG9_YBINS4 1385
//Calibration data is stored at the end of the EEPROM (This is in case any further calibration tables are needed as they are large blocks)
#define EEPROM_CALIBRATION_O2 2559

View File

@ -196,6 +196,74 @@ void writeConfig()
if(EEPROM.read(y) != vvtTable.axisY[offset]) { EEPROM.write(y, vvtTable.axisY[offset]); }
y++;
}
/*---------------------------------------------------
| Fuel trim tables (See storage.h for data layout) - Page 9
| 6x6 tables itself + the 6 values along each of the axis
-----------------------------------------------------*/
//Begin writing the 2 tables, basically the same thing as above but we're doing these 2 together (2 tables per page instead of 1)
EEPROM.update(EEPROM_CONFIG9_XSIZE1,trim1Table.xSize); //Write the boost Table RPM dimension size
EEPROM.update(EEPROM_CONFIG9_YSIZE1,trim1Table.ySize); //Write the boost Table MAP/TPS dimension size
EEPROM.update(EEPROM_CONFIG9_XSIZE2,trim2Table.xSize); //Write the boost Table RPM dimension size
EEPROM.update(EEPROM_CONFIG9_YSIZE2,trim2Table.ySize); //Write the boost Table MAP/TPS dimension size
EEPROM.update(EEPROM_CONFIG9_XSIZE3,trim3Table.xSize); //Write the boost Table RPM dimension size
EEPROM.update(EEPROM_CONFIG9_YSIZE3,trim3Table.ySize); //Write the boost Table MAP/TPS dimension size
EEPROM.update(EEPROM_CONFIG9_XSIZE4,trim4Table.xSize); //Write the boost Table RPM dimension size
EEPROM.update(EEPROM_CONFIG9_YSIZE4,trim4Table.ySize); //Write the boost Table MAP/TPS dimension size
y = EEPROM_CONFIG9_MAP2; //We do the 4 maps together in the same loop
int z = EEPROM_CONFIG9_MAP3; //We do the 4 maps together in the same loop
int i = EEPROM_CONFIG9_MAP4; //We do the 4 maps together in the same loop
for(int x=EEPROM_CONFIG9_MAP1; x<EEPROM_CONFIG9_XBINS1; x++)
{
offset = x - EEPROM_CONFIG9_MAP1;
EEPROM.update(x, trim1Table.values[5-offset/6][offset%6]); //Write the 6x6 map
offset = y - EEPROM_CONFIG9_MAP2;
EEPROM.update(y, trim2Table.values[5-offset/6][offset%6]); //Write the 6x6 map
offset = z - EEPROM_CONFIG9_MAP3;
EEPROM.update(z, trim3Table.values[5-offset/6][offset%6]); //Write the 6x6 map
offset = i - EEPROM_CONFIG9_MAP4;
EEPROM.update(i, trim4Table.values[5-offset/6][offset%6]); //Write the 6x6 map
y++;
z++;
i++;
}
//RPM bins
y = EEPROM_CONFIG9_XBINS2;
z = EEPROM_CONFIG9_XBINS3;
i = EEPROM_CONFIG9_XBINS4;
for(int x=EEPROM_CONFIG9_XBINS1; x<EEPROM_CONFIG9_YBINS1; x++)
{
offset = x - EEPROM_CONFIG9_XBINS1;
EEPROM.update(x, byte(trim1Table.axisX[offset]/100)); //RPM bins are divided by 100 and converted to a byte
offset = y - EEPROM_CONFIG9_XBINS2;
EEPROM.update(y, byte(trim2Table.axisX[offset]/100)); //RPM bins are divided by 100 and converted to a byte
offset = z - EEPROM_CONFIG9_XBINS3;
EEPROM.update(z, byte(trim3Table.axisX[offset]/100)); //RPM bins are divided by 100 and converted to a byte
offset = i - EEPROM_CONFIG9_XBINS4;
EEPROM.update(i, byte(trim4Table.axisX[offset]/100)); //RPM bins are divided by 100 and converted to a byte
y++;
z++;
i++;
}
//TPS/MAP bins
y=EEPROM_CONFIG9_YBINS2;
z=EEPROM_CONFIG9_YBINS3;
i=EEPROM_CONFIG9_YBINS4;
for(int x=EEPROM_CONFIG9_YBINS1; x<EEPROM_CONFIG9_XSIZE2; x++)
{
offset = x - EEPROM_CONFIG9_YBINS1;
EEPROM.update(x, trim1Table.axisY[offset]);
offset = y - EEPROM_CONFIG9_YBINS2;
EEPROM.update(y, trim2Table.axisY[offset]);
offset = z - EEPROM_CONFIG9_YBINS3;
EEPROM.update(z, trim3Table.axisY[offset]);
offset = i - EEPROM_CONFIG9_YBINS4;
EEPROM.update(i, trim4Table.axisY[offset]);
y++;
z++;
i++;
}
}
void loadConfig()
@ -342,6 +410,64 @@ void loadConfig()
vvtTable.axisY[offset] = EEPROM.read(y);
y++;
}
//*********************************************************************************************************************************************************************************
// Fuel trim tables load
y = EEPROM_CONFIG9_MAP2;
int z = EEPROM_CONFIG9_MAP3;
int i = EEPROM_CONFIG9_MAP4;
for(int x=EEPROM_CONFIG9_MAP1; x<EEPROM_CONFIG9_XBINS1; x++)
{
offset = x - EEPROM_CONFIG9_MAP1;
trim1Table.values[5-offset/6][offset%6] = EEPROM.read(x); //Read the 6x6 map
offset = y - EEPROM_CONFIG9_MAP2;
trim2Table.values[5-offset/6][offset%6] = EEPROM.read(y); //Read the 6x6 map
offset = z - EEPROM_CONFIG9_MAP3;
trim3Table.values[5-offset/6][offset%6] = EEPROM.read(z); //Read the 6x6 map
offset = i - EEPROM_CONFIG9_MAP4;
trim4Table.values[5-offset/6][offset%6] = EEPROM.read(i); //Read the 6x6 map
y++;
z++;
i++;
}
//RPM bins
y = EEPROM_CONFIG9_XBINS2;
z = EEPROM_CONFIG9_XBINS3;
i = EEPROM_CONFIG9_XBINS4;
for(int x=EEPROM_CONFIG9_XBINS1; x<EEPROM_CONFIG9_YBINS1; x++)
{
offset = x - EEPROM_CONFIG9_XBINS1;
trim1Table.axisX[offset] = (EEPROM.read(x) * 100); //RPM bins are divided by 100 when stored. Multiply them back now
offset = y - EEPROM_CONFIG9_XBINS2;
trim2Table.axisX[offset] = (EEPROM.read(y) * 100); //RPM bins are divided by 100 when stored. Multiply them back now
offset = z - EEPROM_CONFIG9_XBINS3;
trim3Table.axisX[offset] = (EEPROM.read(z) * 100); //RPM bins are divided by 100 when stored. Multiply them back now
offset = i - EEPROM_CONFIG9_XBINS4;
trim4Table.axisX[offset] = (EEPROM.read(i) * 100); //RPM bins are divided by 100 when stored. Multiply them back now
y++;
z++;
i++;
}
//TPS/MAP bins
y = EEPROM_CONFIG9_YBINS2;
z = EEPROM_CONFIG9_YBINS3;
i = EEPROM_CONFIG9_YBINS4;
for(int x=EEPROM_CONFIG9_YBINS1; x<EEPROM_CONFIG9_XSIZE2; x++)
{
offset = x - EEPROM_CONFIG9_YBINS1;
trim1Table.axisY[offset] = EEPROM.read(x);
offset = y - EEPROM_CONFIG9_YBINS2;
trim2Table.axisY[offset] = EEPROM.read(y);
offset = z - EEPROM_CONFIG9_YBINS3;
trim3Table.axisY[offset] = EEPROM.read(z);
offset = i - EEPROM_CONFIG9_YBINS4;
trim4Table.axisY[offset] = EEPROM.read(i);
y++;
z++;
i++;
}
}
/*