Load and save routines for the 4 fuel trim tables
This commit is contained in:
parent
a4593ae339
commit
1f87c31e01
|
@ -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
|
||||
|
@ -1212,6 +1220,49 @@ menuDialog = main
|
|||
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)"
|
||||
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
|
||||
[GaugeConfigurations]
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
@ -739,6 +747,19 @@ void setup()
|
|||
}
|
||||
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)
|
||||
ign1StartFunction = beginCoil1Charge;
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
21
storage.h
21
storage.h
|
@ -73,6 +73,27 @@ Current layout of EEPROM data (Version 3) is as follows (All sizes are in bytes)
|
|||
#define EEPROM_CONFIG8_XBINS2 1275
|
||||
#define EEPROM_CONFIG8_YBINS2 1283
|
||||
#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
|
||||
|
|
126
storage.ino
126
storage.ino
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue