Working VE and IGN table comms
This commit is contained in:
parent
1c7fd9846e
commit
3d1cdb6f4d
109
comms.ino
109
comms.ino
|
@ -15,10 +15,14 @@ void command()
|
|||
break;
|
||||
|
||||
case 'P': // set the current page
|
||||
//Blue
|
||||
digitalWrite(10, HIGH);
|
||||
digitalWrite(9, LOW);
|
||||
digitalWrite(13, LOW);
|
||||
currentPage = Serial.read(); //Not doing anything with this currently, but need to read the 2nd byte from the buffer
|
||||
while (Serial.available() == 0)
|
||||
{
|
||||
}
|
||||
currentPage = Serial.read();
|
||||
break;
|
||||
|
||||
case 'R': // send 39 bytes of realtime values
|
||||
|
@ -30,6 +34,7 @@ void command()
|
|||
break;
|
||||
|
||||
case 'Q': // send code version
|
||||
//Off
|
||||
digitalWrite(9, LOW);
|
||||
digitalWrite(10, LOW);
|
||||
digitalWrite(13, LOW);
|
||||
|
@ -37,6 +42,7 @@ void command()
|
|||
break;
|
||||
|
||||
case 'V': // send VE table and constants
|
||||
//Red
|
||||
digitalWrite(9, LOW);
|
||||
digitalWrite(10, LOW);
|
||||
digitalWrite(13, HIGH);
|
||||
|
@ -44,6 +50,7 @@ void command()
|
|||
break;
|
||||
|
||||
case 'W': // receive new VE or constant at 'W'+<offset>+<newbyte>
|
||||
//Green
|
||||
digitalWrite(9, HIGH);
|
||||
digitalWrite(10, LOW);
|
||||
digitalWrite(13, LOW);
|
||||
|
@ -98,16 +105,108 @@ void saveConfig()
|
|||
|
||||
void sendPage()
|
||||
{
|
||||
byte response[125];
|
||||
|
||||
switch (currentPage)
|
||||
switch ((int)currentPage)
|
||||
{
|
||||
case vePage:
|
||||
Serial.write((uint8_t *)&fuelTable.values, sizeof(fuelTable.values));
|
||||
//Need to perform a translation of the values[MAP/TPS][RPM] into the MS expected format
|
||||
for(byte x=0;x<64;x++) { response[x] = fuelTable.values[7-x/8][x%8]; }
|
||||
|
||||
response[64] = 0;
|
||||
response[65] = 0;
|
||||
response[66] = 0;
|
||||
response[67] = 0;
|
||||
response[68] = 0;
|
||||
response[78] = 0;
|
||||
response[79] = 0;
|
||||
response[80] = 0;
|
||||
response[81] = 0;
|
||||
response[82] = 0;
|
||||
response[83] = 0;
|
||||
response[84] = 0;
|
||||
response[85] = 0;
|
||||
response[86] = 0;
|
||||
response[87] = 0;
|
||||
response[88] = 0;
|
||||
response[89] = 0;
|
||||
response[90] = (byte)req_fuel;
|
||||
response[91] = 0;
|
||||
response[92] = 0;
|
||||
response[93] = 0;
|
||||
response[94] = 0;
|
||||
response[95] = 0;
|
||||
response[96] = 0;
|
||||
response[97] = 0;
|
||||
response[98] = 0;
|
||||
response[99] = 0;
|
||||
for(byte x=100;x<108;x++) { response[x] = fuelTable.axisX[(x-100)] / 100; }
|
||||
for(byte y=108;y<116;y++) { response[y] = fuelTable.axisY[7-(y-108)]; }
|
||||
response[116] = 0;
|
||||
response[117] = 0;
|
||||
response[118] = 0;
|
||||
response[119] = 0;
|
||||
response[120] = 0;
|
||||
response[121] = 0;
|
||||
response[122] = 0;
|
||||
response[123] = 0;
|
||||
response[124] = 0;
|
||||
|
||||
Serial.write((uint8_t *)&response, sizeof(response));
|
||||
break;
|
||||
case ignPage:
|
||||
Serial.write((uint8_t *)&ignitionTable.values, sizeof(ignitionTable.values));
|
||||
break;
|
||||
//Need to perform a translation of the values[MAP/TPS][RPM] into the MS expected format
|
||||
for(byte x=0;x<64;x++) { response[x] = ignitionTable.values[7-x/8][x%8]; }
|
||||
for(byte x=64;x<72;x++) { response[x] = ignitionTable.axisX[(x-64)] / 100; }
|
||||
for(byte y=72;y<80;y++) { response[y] = ignitionTable.axisY[7-(y-72)]; }
|
||||
response[80] = 0;
|
||||
response[81] = 0;
|
||||
response[82] = 0;
|
||||
response[83] = 0;
|
||||
response[84] = 0;
|
||||
response[85] = 0;
|
||||
response[86] = 0;
|
||||
response[87] = 0;
|
||||
response[88] = 0;
|
||||
response[89] = 0;
|
||||
response[90] = 0;
|
||||
response[91] = 0;
|
||||
response[92] = 0;
|
||||
response[93] = 0;
|
||||
response[94] = 0;
|
||||
response[95] = 0;
|
||||
response[96] = 0;
|
||||
response[97] = 0;
|
||||
response[98] = 0;
|
||||
response[99] = 0;
|
||||
response[100] = 0;
|
||||
response[101] = 0;
|
||||
response[102] = 0;
|
||||
response[103] = 0;
|
||||
response[104] = 0;
|
||||
response[105] = 0;
|
||||
response[106] = 0;
|
||||
response[107] = 0;
|
||||
response[108] = 0;
|
||||
response[109] = 0;
|
||||
response[110] = 0;
|
||||
response[111] = 0;
|
||||
response[112] = 0;
|
||||
response[113] = 0;
|
||||
response[114] = 0;
|
||||
response[115] = 0;
|
||||
response[116] = 0;
|
||||
response[117] = 0;
|
||||
response[118] = 0;
|
||||
response[119] = 0;
|
||||
response[120] = 0;
|
||||
response[121] = 0;
|
||||
response[122] = 0;
|
||||
response[123] = 0;
|
||||
response[124] = 0;
|
||||
Serial.write((uint8_t *)&response, sizeof(response));
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ void setup() {
|
|||
req_fuel_uS = req_fuel_uS / engineSquirtsPerCycle; //The req_fuel calculation above gives the total required fuel (At VE 100%) in the full cycle. If we're doing more than 1 squirt per cycle then we need to split the amount accordingly. (Note that in a non-sequential 4-stroke setup you cannot have less than 2 squirts as you cannot determine the stroke to make the single squirt on)
|
||||
|
||||
Serial.begin(9600);
|
||||
//Serial.begin(115200);
|
||||
|
||||
//This sets the ADC (Analog to Digitial Converter) to run at 1Mhz, greatly reducing analog read times (MAP/TPS)
|
||||
//1Mhz is the fastest speed permitted by the CPU without affecting accuracy
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
;--------------------------------------------------
|
||||
|
||||
page = 2
|
||||
advTable1 = array, U08, 0,[8x8], "deg", 0.352, -28.4, -10.0, 80.0, 0
|
||||
advTable1 = array, U08, 0,[8x8], "deg", 1.0, 0.0, 0.0, 255.0, 0
|
||||
rpmBins2 = array, U08, 64,[ 8], "RPM", 100.0, 0.0, 100, 25500, 0
|
||||
|
||||
#if SPEED_DENSITY
|
||||
|
|
4
table.h
4
table.h
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
This file is used for everything related to maps/tables including their definition, functions etc
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
struct table {
|
||||
//All tables must be the same size for simplicity
|
||||
const static int xSize = 8;
|
||||
const static int ySize = 8;
|
||||
|
||||
int values[ySize][xSize];
|
||||
byte values[ySize][xSize];
|
||||
int axisX[xSize];
|
||||
int axisY[ySize];
|
||||
|
||||
|
|
76
testing.h
76
testing.h
|
@ -48,29 +48,29 @@ void dummyFuelTable(struct table *myFuelTable)
|
|||
//table myFuelTable;
|
||||
|
||||
int tempXAxis[8] = {500,1500,2000,2500,3000,4000,5000,6000};
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->axisX[x] = tempXAxis[x]; }
|
||||
for (byte x = 0; x< myFuelTable->xSize; x++) { myFuelTable->axisX[x] = tempXAxis[x]; }
|
||||
//*myFuelTable->axisX = *tempXAxis;
|
||||
int tempYAxis[8] = {100,88,75,63,50,38,25,13};
|
||||
for (int x = 0; x< myFuelTable->ySize; x++) { myFuelTable->axisY[x] = tempYAxis[x]; }
|
||||
int tempYAxis[8] = {100,88,75,63,50,30,20,10};
|
||||
for (byte x = 0; x< myFuelTable->ySize; x++) { myFuelTable->axisY[x] = tempYAxis[x]; }
|
||||
//*myFuelTable->axisY = *tempYAxis;
|
||||
|
||||
//Go through the 8 rows and add the column values
|
||||
int tempRow1[8] = {78,88,92,95,97,101,107,110};
|
||||
int tempRow2[8] = {58,88,75,63,50,38,25,13};
|
||||
int tempRow3[8] = {45,88,75,63,50,38,25,13};
|
||||
int tempRow4[8] = {35,88,75,63,50,38,25,13};
|
||||
int tempRow5[8] = {28,88,75,63,50,38,25,13};
|
||||
int tempRow6[8] = {22,23,75,63,50,38,25,13};
|
||||
int tempRow7[8] = {17,21,75,63,50,38,25,13};
|
||||
int tempRow8[8] = {15,20,25,63,50,38,25,13};
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[0][x] = tempRow1[x]; }
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[1][x] = tempRow2[x]; }
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[2][x] = tempRow3[x]; }
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[3][x] = tempRow4[x]; }
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[4][x] = tempRow5[x]; }
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[5][x] = tempRow6[x]; }
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[6][x] = tempRow7[x]; }
|
||||
for (int x = 0; x< myFuelTable->xSize; x++) { myFuelTable->values[7][x] = tempRow8[x]; }
|
||||
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]; }
|
||||
|
||||
}
|
||||
|
||||
|
@ -80,28 +80,28 @@ Populates a table with some reasonably realistic ignition advance data
|
|||
void dummyIgnitionTable(struct table *mySparkTable)
|
||||
{
|
||||
int tempXAxis[8] = {500,1500,2000,2500,3000,4000,5000,6000};
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->axisX[x] = tempXAxis[x]; }
|
||||
for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->axisX[x] = tempXAxis[x]; }
|
||||
//*myFuelTable->axisX = *tempXAxis;
|
||||
int tempYAxis[8] = {100,88,75,63,50,38,25,13};
|
||||
for (int x = 0; x< mySparkTable->ySize; x++) { mySparkTable->axisY[x] = tempYAxis[x]; }
|
||||
int tempYAxis[8] = {100,88,75,63,50,30,20,10};
|
||||
for (byte x = 0; x< mySparkTable->ySize; x++) { mySparkTable->axisY[x] = tempYAxis[x]; }
|
||||
//*myFuelTable->axisY = *tempYAxis;
|
||||
|
||||
//Go through the 8 rows and add the column values
|
||||
int tempRow1[8] = {10,15,20,26,35,40,43,44};
|
||||
int tempRow2[8] = {10,88,75,63,50,38,25,44};
|
||||
int tempRow3[8] = {12,88,75,63,50,38,25,40};
|
||||
int tempRow4[8] = {12,88,75,63,50,38,25,36};
|
||||
int tempRow5[8] = {28,88,75,63,50,38,25,13};
|
||||
int tempRow6[8] = {22,23,75,63,50,38,25,13};
|
||||
int tempRow7[8] = {17,21,75,63,50,38,25,13};
|
||||
int tempRow8[8] = {15,20,25,63,50,38,25,13};
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[0][x] = tempRow1[x]; }
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[1][x] = tempRow2[x]; }
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[2][x] = tempRow3[x]; }
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[3][x] = tempRow4[x]; }
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[4][x] = tempRow5[x]; }
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[5][x] = tempRow6[x]; }
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[6][x] = tempRow7[x]; }
|
||||
for (int x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[7][x] = tempRow8[x]; }
|
||||
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]; }
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue