2013-02-05 00:27:06 -08:00
|
|
|
/*
|
|
|
|
This file has a few functions that are helpful for testing such as creating dummy maps and faking interrupts
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Aim is to create an 8x8 table that looks like the below:
|
2013-02-05 03:31:17 -08:00
|
|
|
MAP
|
|
|
|
______________________________________________
|
|
|
|
|100|| 78 | 88 | 92 | 95 | 97 |101 |107 |110 |
|
2014-01-09 23:54:33 -08:00
|
|
|
| 88|| 58 | 88 | 75 | 63 | 50 | 38 | 25 | 13 |
|
|
|
|
| 75|| 45 | 88 | 75 | 63 | 50 | 38 | 25 | 13 |
|
|
|
|
| 63|| 35 | 88 | 75 | 63 | 50 | 38 | 25 | 13 |
|
|
|
|
| 50|| 28 | 88 | 75 | 63 | 50 | 38 | 25 | 13 |
|
|
|
|
| 38|| 22 | 23 | 75 | 63 | 50 | 38 | 25 | 13 |
|
|
|
|
| 25|| 17 | 21 | 75 | 63 | 50 | 38 | 25 | 13 |
|
|
|
|
| 13|| 15 | 20 | 25 | 63 | 50 | 38 | 25 | 13 |
|
2013-02-05 03:31:17 -08:00
|
|
|
| || 500|1500|2000|2500|3000|4000|5000|6000| RPM
|
|
|
|
|
2014-01-09 23:54:33 -08:00
|
|
|
This is not really a realistic 8x8 VE vs RPM 2D map, but it's enough for testing
|
2013-02-05 03:31:17 -08:00
|
|
|
Here is a run through of how the interpolation would flow:
|
2013-02-05 02:11:59 -08:00
|
|
|
Pass in:
|
|
|
|
x = 1000
|
|
|
|
y = 20
|
|
|
|
|
|
|
|
yMax = 13
|
|
|
|
yMin = 25
|
|
|
|
|
|
|
|
xMax = 1500
|
|
|
|
xMin = 500
|
|
|
|
|
|
|
|
A 17
|
|
|
|
B 21
|
|
|
|
C 15
|
|
|
|
D 20
|
|
|
|
p (1000 - 500) / (1500 - 500) = 1/2 = 0.5
|
|
|
|
q (20 - 13) / (25 - 13) = 7/12 = 0.583
|
|
|
|
m (1 - 0.5) * (1 - 0.583) = 0.2083
|
|
|
|
n 0.5 * (1 - 0.583) = 0.2083
|
|
|
|
o (1 - 0.5) * 0.583 = 0.29166
|
|
|
|
r (0.5 * 0.583) = 0.29166
|
|
|
|
|
|
|
|
VE = ( (17 * 0.2083) + (21 * 0.2083) + (15 * 0.9166) + (20 * 0.29166) ) = 18.125
|
2013-02-05 00:27:06 -08:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-01-07 00:02:00 -08:00
|
|
|
void dummyFuelTable(struct table3D *myFuelTable)
|
2013-02-05 00:27:06 -08:00
|
|
|
{
|
2013-02-05 05:17:54 -08:00
|
|
|
//table myFuelTable;
|
2013-02-05 00:27:06 -08:00
|
|
|
|
2013-02-05 05:17:54 -08:00
|
|
|
int tempXAxis[8] = {500,1500,2000,2500,3000,4000,5000,6000};
|
2013-07-09 05:12:35 -07:00
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->axisX[x] = tempXAxis[x]; }
|
2013-02-05 05:17:54 -08:00
|
|
|
//*myFuelTable->axisX = *tempXAxis;
|
2013-07-09 05:12:35 -07:00
|
|
|
int tempYAxis[8] = {100,88,75,63,50,30,20,10};
|
|
|
|
for (byte x = 0; x< myFuelTable->ySize; x++) { myFuelTable->axisY[x] = tempYAxis[x]; }
|
2013-02-05 05:17:54 -08:00
|
|
|
//*myFuelTable->axisY = *tempYAxis;
|
|
|
|
|
|
|
|
//Go through the 8 rows and add the column values
|
2013-07-09 05:12:35 -07:00
|
|
|
byte tempRow1[8] = {78,88,92,95,97,101,107,110};
|
|
|
|
byte tempRow2[8] = {58,88,75,63,50,38,25,13};
|
|
|
|
byte tempRow3[8] = {45,88,75,63,50,38,25,13};
|
|
|
|
byte tempRow4[8] = {35,88,75,63,50,38,25,13};
|
|
|
|
byte tempRow5[8] = {28,88,75,63,50,38,25,13};
|
|
|
|
byte tempRow6[8] = {22,23,75,63,50,38,25,13};
|
|
|
|
byte tempRow7[8] = {17,21,75,63,50,38,25,13};
|
|
|
|
byte tempRow8[8] = {15,20,25,63,50,38,25,13};
|
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[0][x] = tempRow1[x]; }
|
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[1][x] = tempRow2[x]; }
|
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[2][x] = tempRow3[x]; }
|
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[3][x] = tempRow4[x]; }
|
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[4][x] = tempRow5[x]; }
|
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[5][x] = tempRow6[x]; }
|
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[6][x] = tempRow7[x]; }
|
|
|
|
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[7][x] = tempRow8[x]; }
|
2013-02-05 05:17:54 -08:00
|
|
|
|
2013-02-05 00:27:06 -08:00
|
|
|
}
|
2013-02-13 22:34:29 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
Populates a table with some reasonably realistic ignition advance data
|
|
|
|
*/
|
2014-01-07 00:02:00 -08:00
|
|
|
void dummyIgnitionTable(struct table3D *mySparkTable)
|
2013-02-13 22:34:29 -08:00
|
|
|
{
|
|
|
|
int tempXAxis[8] = {500,1500,2000,2500,3000,4000,5000,6000};
|
2013-07-09 05:12:35 -07:00
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->axisX[x] = tempXAxis[x]; }
|
2013-02-13 22:34:29 -08:00
|
|
|
//*myFuelTable->axisX = *tempXAxis;
|
2013-07-09 05:12:35 -07:00
|
|
|
int tempYAxis[8] = {100,88,75,63,50,30,20,10};
|
|
|
|
for (byte x = 0; x< mySparkTable->ySize; x++) { mySparkTable->axisY[x] = tempYAxis[x]; }
|
2013-02-13 22:34:29 -08:00
|
|
|
//*myFuelTable->axisY = *tempYAxis;
|
|
|
|
|
|
|
|
//Go through the 8 rows and add the column values
|
2013-07-09 05:12:35 -07:00
|
|
|
byte tempRow1[8] = {10,15,20,26,35,40,43,44};
|
|
|
|
byte tempRow2[8] = {10,88,75,63,50,38,25,44};
|
|
|
|
byte tempRow3[8] = {12,88,75,63,50,38,25,40};
|
|
|
|
byte tempRow4[8] = {12,88,75,63,50,38,25,36};
|
|
|
|
byte tempRow5[8] = {28,88,75,63,50,38,25,13};
|
|
|
|
byte tempRow6[8] = {22,23,75,63,50,38,25,13};
|
|
|
|
byte tempRow7[8] = {17,21,75,63,50,38,25,13};
|
|
|
|
byte tempRow8[8] = {15,20,25,63,50,38,25,13};
|
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[0][x] = tempRow1[x]; }
|
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[1][x] = tempRow2[x]; }
|
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[2][x] = tempRow3[x]; }
|
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[3][x] = tempRow4[x]; }
|
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[4][x] = tempRow5[x]; }
|
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[5][x] = tempRow6[x]; }
|
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[6][x] = tempRow7[x]; }
|
|
|
|
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[7][x] = tempRow8[x]; }
|
2013-02-13 22:34:29 -08:00
|
|
|
|
|
|
|
}
|