mirror of https://github.com/rusefi/speeduino.git
Large re-org in preparation for EEPROM and comms paging work
This commit is contained in:
parent
842f6a6e9c
commit
8e002150ee
38
comms.ino
38
comms.ino
|
@ -112,36 +112,34 @@ void sendPage()
|
|||
case vePage:
|
||||
//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;
|
||||
for(byte x=64;x<72;x++) { response[x] = fuelTable.axisX[(x-100)] / 100; } //RPM Bins for VE table
|
||||
for(byte y=72;y<80;y++) { response[y] = fuelTable.axisY[7-(y-108)]; } //MAP or TPS bins for VE table
|
||||
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[100] = 0;
|
||||
response[101] = 0;
|
||||
response[102] = 0;
|
||||
response[103] = 0;
|
||||
response[104] = 0;
|
||||
response[105] = 0;
|
||||
response[106] = (byte)req_fuel;
|
||||
response[107] = 0;
|
||||
response[108] = 0;
|
||||
response[109] = 0;
|
||||
response[110] = 0;
|
||||
response[111] = 0;
|
||||
response[112] = 0;
|
||||
response[113] = 0;
|
||||
response[114] = 0; //rpmk (16 bits)
|
||||
response[116] = ((engineCylinders-1) * 16) + (1 * 8) + ((engineStrokes / 4) * 4) + 2; // (engineCylinders * 16) + (1 * 8) + ((engineStrokes / 4) * 4) + 4
|
||||
response[117] = 0;
|
||||
response[118] = 0;
|
||||
|
@ -160,7 +158,7 @@ void sendPage()
|
|||
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[80] = triggerAngle;
|
||||
response[81] = 0;
|
||||
response[82] = 0;
|
||||
response[83] = 0;
|
||||
|
|
89
globals.h
89
globals.h
|
@ -1,8 +1,10 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
byte ms_version = 20;
|
||||
byte data_structure_version = 1; //This identifies the data structure when reading / writing.
|
||||
|
||||
//The status struct contains the current values for all 'live' variables
|
||||
//In current version this is 64 bytes
|
||||
struct statuses {
|
||||
volatile boolean hasSync;
|
||||
unsigned int RPM;
|
||||
|
@ -12,3 +14,90 @@ struct statuses {
|
|||
unsigned long PW; //In uS
|
||||
|
||||
};
|
||||
|
||||
|
||||
//Page 1 of the config - See the ini file for further reference
|
||||
//This mostly covers off variables that are required for fuel
|
||||
struct config1 {
|
||||
/*
|
||||
byte engineCylinders; 1 // May support more than 1 cyl later. Always will assume 1 injector per cylinder.
|
||||
byte engineInjectorSize; 80 // In cc/min
|
||||
byte engineStoich; 14.7 // Stoichiometric ratio of fuel used
|
||||
byte engineStrokes; 4 //Can be 2 stroke or 4 stroke, any other value will cause problems
|
||||
byte engineDwell; 3000 //The spark dwell time in uS
|
||||
*/
|
||||
|
||||
byte crankCold;
|
||||
byte crankHot;
|
||||
byte asePct;
|
||||
byte aseCount;
|
||||
byte wueBins[10];
|
||||
byte taeBins1;
|
||||
byte taeBins2;
|
||||
byte taeBins3;
|
||||
byte taeBins4;
|
||||
byte taeColdA;
|
||||
byte tpsThresh;
|
||||
byte taeTime;
|
||||
byte tdePct;
|
||||
byte egoTemp;
|
||||
byte egoCount;
|
||||
byte egoDelta;
|
||||
byte egoLimit;
|
||||
byte reqFuel;
|
||||
byte divider;
|
||||
byte alternate;
|
||||
byte injOpen;
|
||||
byte injOCfuel;
|
||||
byte injPwmP;
|
||||
byte injPwmT;
|
||||
byte battFac; //Whether to compensate pulsewidth for battery voltage (ms/v)
|
||||
int rpmk;
|
||||
|
||||
byte mapType;
|
||||
byte twoStroke;
|
||||
byte injType;
|
||||
byte nCylinders;
|
||||
byte cltType;
|
||||
byte matType;
|
||||
byte nInjectors;
|
||||
byte engineType;
|
||||
byte egoType;
|
||||
byte algorithm; //"Speed Density", "Alpha-N"
|
||||
byte baroCorr;
|
||||
byte primePulse;
|
||||
byte egoRPM;
|
||||
byte fastIdleT; //Fast idle temperature
|
||||
byte egoSwitch;
|
||||
byte taeColdM;
|
||||
|
||||
};
|
||||
|
||||
//Page 2 of the config - See the ini file for further reference
|
||||
//This mostly covers off variables that are required for ignition
|
||||
struct config2 {
|
||||
|
||||
byte trigerAngle;
|
||||
byte FixAng;
|
||||
byte Trim;
|
||||
byte CrankAng;
|
||||
byte IgHold;
|
||||
byte Trig_plus;
|
||||
byte TrigCrank;
|
||||
byte IgInv;
|
||||
byte oddfire;
|
||||
byte IdleAdv;
|
||||
byte IdleAdvTPS;
|
||||
byte IdleAdvRPM;
|
||||
byte IdleAdvCLT;
|
||||
byte IdleDelayTime;
|
||||
byte StgCycles;
|
||||
|
||||
byte dwellcont; //Fixed duty dwell control
|
||||
byte dwellcrank;
|
||||
byte dwellrun;
|
||||
|
||||
byte triggerTeeth; //The full count of teeth on the trigger wheel if there were no gaps
|
||||
byte triggerMissingTeeth; //The size of the tooth gap (ie number of missing teeth)
|
||||
|
||||
};
|
||||
|
|
|
@ -6,15 +6,7 @@
|
|||
/*
|
||||
Need to calculate the req_fuel figure here, preferably in pre-processor macro
|
||||
*/
|
||||
#define engineCapacity 148 // In cc
|
||||
#define engineCylinders 1 // May support more than 1 cyl later. Always will assume 1 injector per cylinder.
|
||||
#define engineInjectorSize 80 // In cc/min
|
||||
#define engineStoich 14.7 // Stoichiometric ratio of fuel used
|
||||
#define engineStrokes 4 //Can be 2 stroke or 4 stroke, any other value will cause problems
|
||||
#define engineDwell 3000 //The spark dwell time in uS
|
||||
#define triggerTeeth 12 //The full count of teeth on the trigger wheel if there were no gaps
|
||||
#define triggerMissingTeeth 1 //The size of the tooth gap (ie number of missing teeth)
|
||||
#define triggerAngle 110 // The angle (Degrees) from TDC that No 1 cylinder is at when tooth #1 passes the sensor. CANNOT BE 0
|
||||
|
||||
|
||||
//The following lines are configurable, but the defaults are probably pretty good for most applications
|
||||
#define engineInjectorDeadTime 1500 //Time in uS that the injector takes to open
|
||||
|
@ -36,8 +28,10 @@ Need to calculate the req_fuel figure here, preferably in pre-processor macro
|
|||
#include "fastAnalog.h"
|
||||
#include "digitalIOPerformance.h"
|
||||
|
||||
float req_fuel = ((engineCapacity / engineInjectorSize) / engineCylinders / engineStoich) * 100; // This doesn't seem quite correct, but I can't find why. It will be close enough to start an engine
|
||||
int req_fuel_uS = req_fuel * 1000; //Convert to uS and, importantly, an int. This is the only variable to be used in calculations
|
||||
//NEED TO LOAD FROM EEPROM HERE
|
||||
|
||||
//float req_fuel = ((engineCapacity / engineInjectorSize) / engineCylinders / engineStoich) * 100; // This doesn't seem quite correct, but I can't find why. It will be close enough to start an engine
|
||||
int req_fuel_uS = config1.req_fuel * 1000; //Convert to uS and an int. This is the only variable to be used in calculations
|
||||
|
||||
// Setup section
|
||||
// These aren't really configuration options, more so a description of how the hardware is setup. These are things that will be defined in the recommended hardware setup
|
||||
|
|
|
@ -83,46 +83,47 @@
|
|||
; name = array, type, offset, shape, units, scale, translate, lo, hi, digits
|
||||
; name = scalar, type, offset, units, scale, translate, lo, hi, digits
|
||||
veTable = array, U08, 0, [8x8], "%", 1.0, 0.0, 0.0, 255.0, 0
|
||||
crankCold = scalar, U08, 64, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
crankHot = scalar, U08, 65, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
asePct = scalar, U08, 66, "%", 1.0, 0.0, 0.0, 95.0, 0
|
||||
aseCount = scalar, U08, 67, "", 1.0, 0.0, 0.0, 254.0, 0
|
||||
wueBins = array, U08, 68, [ 10], "%", 1.0, 0.0, 100.0, 255.0, 0
|
||||
taeBins = array, U08, 78, [ 4], "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeBins1 = scalar, U08, 78, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeBins2 = scalar, U08, 79, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeBins3 = scalar, U08, 80, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeBins4 = scalar, U08, 81, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeColdA = scalar, U08, 82, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
tpsThresh = scalar, U08, 83, "v/s",0.1953125, 0.0, 0.2, 49.8, 3
|
||||
taeTime = scalar, U08, 84, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
tdePct = scalar, U08, 85, "%", 1.0, 0.0, 0.0, 255.0, 0
|
||||
#if CELSIUS
|
||||
egoTemp = scalar, U08, 86, "°C", 0.555, -72, -40, 102.0, 0
|
||||
#else
|
||||
egoTemp = scalar, U08, 86, "°F", 1.0, -40, -40, 215.0, 0
|
||||
#endif
|
||||
egoCount = scalar, U08, 87, "", 1.0, 0.0, 0.0, 255.0, 0
|
||||
egoDelta = scalar, U08, 88, "%", 1.0, 0.0, 0.0, 255.0, 0
|
||||
egoLimit = scalar, U08, 89, "%", 1.0, 0.0, 0.0, 255.0, 0
|
||||
reqFuel = scalar, U08, 90, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
divider = scalar, U08, 91, "", 1.0, 0.0
|
||||
alternate = bits, U08, 92, [0:0], "Simultaneous", "Alternating"
|
||||
injOpen = scalar, U08, 93, "ms", 0.1, 0.0, 0.1, 25.5, 1
|
||||
injOCfuel = scalar, U08, 94, "ms", 0.1, 0.0, 0.0, 0.0, 0
|
||||
injPwmP = scalar, U08, 95, "%", 1.0, 0.0, 0.0, 100.0, 0
|
||||
injPwmT = scalar, U08, 96, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
battFac = scalar, U08, 97, "ms/v",0.0166667, 0.0, 0.0, 1.0, 2
|
||||
rpmk = scalar, U16, 98, "", 1.0, 0.0
|
||||
rpmBins = array, U08, 100, [ 8], "RPM", 100.0, 0.0, 100.0, 25500.0, 0
|
||||
rpmBins = array, U08, 64, [ 8], "RPM", 100.0, 0.0, 100.0, 25500.0, 0
|
||||
#if SPEED_DENSITY
|
||||
mapBins = array, U08, 108, [ 8], "kPa", 1.0, 0.0, 0.0, 255.0, 0
|
||||
mapBins = array, U08, 72, [ 8], "kPa", 1.0, 0.0, 0.0, 255.0, 0
|
||||
#elif ALPHA_N
|
||||
tpsBins = array, U08, 108, [ 8], "TPS", 1.0, 0.0, 0.0, 255.0, 0
|
||||
tpsBins = array, U08, 72, [ 8], "TPS", 1.0, 0.0, 0.0, 255.0, 0
|
||||
#elif AIR_FLOW_METER
|
||||
#error "MSnS does not support MAF"
|
||||
#exit
|
||||
#endif
|
||||
crankCold = scalar, U08, 80, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
crankHot = scalar, U08, 81, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
asePct = scalar, U08, 82, "%", 1.0, 0.0, 0.0, 95.0, 0
|
||||
aseCount = scalar, U08, 83, "", 1.0, 0.0, 0.0, 254.0, 0
|
||||
wueBins = array, U08, 84, [ 10], "%", 1.0, 0.0, 100.0, 255.0, 0
|
||||
taeBins = array, U08, 94, [ 4], "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeBins1 = scalar, U08, 94, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeBins2 = scalar, U08, 95, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeBins3 = scalar, U08, 96, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeBins4 = scalar, U08, 97, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
taeColdA = scalar, U08, 98, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
tpsThresh = scalar, U08, 99, "v/s",0.1953125, 0.0, 0.2, 49.8, 3
|
||||
taeTime = scalar, U08, 100, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
tdePct = scalar, U08, 101, "%", 1.0, 0.0, 0.0, 255.0, 0
|
||||
#if CELSIUS
|
||||
egoTemp = scalar, U08, 102, "°C", 0.555, -72, -40, 102.0, 0
|
||||
#else
|
||||
egoTemp = scalar, U08, 102, "°F", 1.0, -40, -40, 215.0, 0
|
||||
#endif
|
||||
egoCount = scalar, U08, 103, "", 1.0, 0.0, 0.0, 255.0, 0
|
||||
egoDelta = scalar, U08, 104, "%", 1.0, 0.0, 0.0, 255.0, 0
|
||||
egoLimit = scalar, U08, 105, "%", 1.0, 0.0, 0.0, 255.0, 0
|
||||
reqFuel = scalar, U08, 106, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
divider = scalar, U08, 107, "", 1.0, 0.0
|
||||
alternate = bits, U08, 108, [0:0], "Simultaneous", "Alternating"
|
||||
injOpen = scalar, U08, 109, "ms", 0.1, 0.0, 0.1, 25.5, 1
|
||||
injOCfuel = scalar, U08, 110, "ms", 0.1, 0.0, 0.0, 0.0, 0
|
||||
injPwmP = scalar, U08, 111, "%", 1.0, 0.0, 0.0, 100.0, 0
|
||||
injPwmT = scalar, U08, 112, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
battFac = scalar, U08, 113, "ms/v",0.0166667, 0.0, 0.0, 1.0, 2
|
||||
rpmk = scalar, U16, 114, "", 1.0, 0.0
|
||||
|
||||
; Config1
|
||||
mapType = bits, U08, 116, [0:1], "115 kPa", "250 kPa", "INVALID", "INVALID"
|
||||
twoStroke = bits, U08, 116, [2:2], "Four-stroke", "Two-stroke"
|
||||
|
@ -149,6 +150,7 @@
|
|||
egoSwitch = scalar, U08, 122, "v", 0.0196, 0.0, 0.0, 5.0, 3
|
||||
taeColdM = scalar, U08, 123, "%", 1.0, 0.0, 0.0, 250.0, 0
|
||||
|
||||
|
||||
;--------------------------------------------------
|
||||
;Start Ignition table (Table 2)
|
||||
;--------------------------------------------------
|
||||
|
@ -185,19 +187,14 @@
|
|||
#endif
|
||||
IdleDelayTime = scalar, U08, 90, "sec", 1, 0, 0, 5, 0
|
||||
StgCycles = scalar, U08, 91, "cycles", 1, 0, 0, 255, 0
|
||||
#if MPXH6300A
|
||||
Stg2ndParmKPA = scalar, U08, 92, "KPa", 1.213675, 1.53, 0, 304.0, 0
|
||||
Stg2ndParmDlt = scalar, U08, 93, "KPa", 1.213675, 1.53, 0, 304.0, 0
|
||||
#elif MPXH6400A
|
||||
Stg2ndParmKPA = scalar, U08, 92, "KPa", 1.6197783, 2.147, 20.0, 400.0, 0
|
||||
Stg2ndParmDlt = scalar, U08, 93, "KPa", 1.6197783, 2.147, 20.0, 400.0, 0
|
||||
#else
|
||||
Stg2ndParmKPA = scalar, U08, 92, "kPa", 1, 0, 0, 255, 0
|
||||
Stg2ndParmDlt = scalar, U08, 93, "kPa", 1,0,0,255,0
|
||||
#endif
|
||||
spare2_94 = scalar, U08, 94, "", 1, 0, 0, 255, 0
|
||||
spare2_95 = scalar, U08, 95, "", 1, 0, 0, 255, 0
|
||||
spare2_96 = scalar, U08, 96, "", 1, 0, 0, 255, 0
|
||||
|
||||
;Dwell control
|
||||
;running dwell variable railed to 8 - who needs more than 8ms?
|
||||
dwellcont = bits, U08, 92, [1:1], "Fixed duty*^", "Dwell control"
|
||||
dwellcrank = scalar, U08, 93, "ms", 0.1, 0, 0, 25, 1
|
||||
dwellrun = scalar, U08, 94, "ms", 0.1, 0, 0, 8, 1
|
||||
triggerTeeth = scalar, U08, 95, "teeth", 1.0, 0.0, 0.0, 255, 0 ; * ( 1 byte)
|
||||
No_Miss_Teeth = scalar, U08, 96, "teeth", 1.0, 0.0, 0.0, 255, 0 ; * ( 1 byte )
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#include <EEPROM.h>
|
||||
|
||||
void writeConfig();
|
||||
void writeTables();
|
||||
|
||||
void loadConfig();
|
||||
void loadTables();
|
||||
|
||||
/*
|
||||
Current layout of data (Version 1) is as follows (All sizes are in bytes):
|
||||
|---------------------------------------------------|
|
||||
|Byte # |Size | Description |
|
||||
|---------------------------------------------------|
|
||||
| 0 |1 | Data structure version |
|
||||
| 1 |2 | X and Y sizes for VE table |
|
||||
| 3 |125 | Config Page 1 (VE Table) |
|
||||
| 128 |2 | X and Y sizes for Ign table |
|
||||
| 130 |125 | Config Page 2 (Ign Table) |
|
||||
-----------------------------------------------------
|
||||
*/
|
||||
|
||||
#define EEPROM_CONFIG1 3
|
||||
#define EEPROM_CONFIG2 130
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
|
4
table.h
4
table.h
|
@ -4,8 +4,8 @@ This file is used for everything related to maps/tables including their definiti
|
|||
#include <Arduino.h>
|
||||
struct table {
|
||||
//All tables must be the same size for simplicity
|
||||
const static int xSize = 8;
|
||||
const static int ySize = 8;
|
||||
const static byte xSize = 8;
|
||||
const static byte ySize = 8;
|
||||
|
||||
byte values[ySize][xSize];
|
||||
int axisX[xSize];
|
||||
|
|
Loading…
Reference in New Issue