Initial memory reduction work on temp tables (WILL BREAK CALIBRATION)
This commit is contained in:
parent
1ec7e7ee86
commit
ac6f1d1b25
|
@ -418,14 +418,14 @@ void command()
|
|||
{
|
||||
Serial.print(x);
|
||||
Serial.print(", ");
|
||||
Serial.println(cltCalibrationTable[x]);
|
||||
//Serial.println(cltCalibrationTable[x]);
|
||||
}
|
||||
Serial.println(F("Inlet temp"));
|
||||
for (int x = 0; x < CALIBRATION_TABLE_SIZE; x++)
|
||||
{
|
||||
Serial.print(x);
|
||||
Serial.print(", ");
|
||||
Serial.println(iatCalibrationTable[x]);
|
||||
//Serial.println(iatCalibrationTable[x]);
|
||||
}
|
||||
Serial.println(F("O2"));
|
||||
for (int x = 0; x < CALIBRATION_TABLE_SIZE; x++)
|
||||
|
@ -1656,7 +1656,7 @@ void receiveCalibration(byte tableID)
|
|||
{
|
||||
case 0:
|
||||
//coolant table
|
||||
pnt_TargetTable = (byte *)&cltCalibrationTable;
|
||||
//pnt_TargetTable = (byte *)&cltCalibrationTable;
|
||||
OFFSET = CALIBRATION_TEMPERATURE_OFFSET; //
|
||||
DIVISION_FACTOR = 10;
|
||||
BYTES_PER_VALUE = 2;
|
||||
|
@ -1664,7 +1664,7 @@ void receiveCalibration(byte tableID)
|
|||
break;
|
||||
case 1:
|
||||
//Inlet air temp table
|
||||
pnt_TargetTable = (byte *)&iatCalibrationTable;
|
||||
//pnt_TargetTable = (byte *)&iatCalibrationTable;
|
||||
OFFSET = CALIBRATION_TEMPERATURE_OFFSET;
|
||||
DIVISION_FACTOR = 10;
|
||||
BYTES_PER_VALUE = 2;
|
||||
|
|
|
@ -92,6 +92,6 @@ byte checkAFRLimit()
|
|||
{
|
||||
byte checkAFRLimitActive = 0;
|
||||
|
||||
return checkAFRLimitActive ;
|
||||
return checkAFRLimitActive;
|
||||
}
|
||||
|
||||
|
|
|
@ -1212,10 +1212,18 @@ extern struct config4 configPage4;
|
|||
extern struct config6 configPage6;
|
||||
extern struct config9 configPage9;
|
||||
extern struct config10 configPage10;
|
||||
extern byte cltCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the coolant sensor calibration values */
|
||||
extern byte iatCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the inlet air temperature sensor calibration values */
|
||||
//extern byte cltCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the coolant sensor calibration values */
|
||||
//extern byte iatCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the inlet air temperature sensor calibration values */
|
||||
extern byte o2CalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the O2 sensor calibration values */
|
||||
|
||||
extern uint16_t cltCalibration_bins[32];
|
||||
extern uint16_t cltCalibration_values[32];
|
||||
extern uint16_t iatCalibration_bins[32];
|
||||
extern uint16_t iatCalibration_values[32];
|
||||
extern struct table2D cltCalibrationTable_new; /**< A 32 bin array containing the coolant temperature sensor calibration values */
|
||||
extern struct table2D iatCalibrationTable_new; /**< A 32 bin array containing the inlet air temperature sensor calibration values */
|
||||
extern struct table2D o2CalibrationTable_new; /**< A 32 bin array containing the O2 sensor calibration values */
|
||||
|
||||
static_assert(sizeof(struct config2) == 128, "configPage2 size is not 128");
|
||||
static_assert(sizeof(struct config4) == 128, "configPage4 size is not 128");
|
||||
static_assert(sizeof(struct config6) == 128, "configPage6 size is not 128");
|
||||
|
|
|
@ -223,6 +223,13 @@ struct config6 configPage6;
|
|||
struct config9 configPage9;
|
||||
struct config10 configPage10;
|
||||
|
||||
byte cltCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the coolant sensor calibration values */
|
||||
byte iatCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the inlet air temperature sensor calibration values */
|
||||
//byte cltCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the coolant sensor calibration values */
|
||||
//byte iatCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the inlet air temperature sensor calibration values */
|
||||
byte o2CalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the O2 sensor calibration values */
|
||||
|
||||
uint16_t cltCalibration_bins[32];
|
||||
uint16_t cltCalibration_values[32];
|
||||
struct table2D cltCalibrationTable_new;
|
||||
uint16_t iatCalibration_bins[32];
|
||||
uint16_t iatCalibration_values[32];
|
||||
struct table2D iatCalibrationTable_new;
|
||||
|
|
|
@ -188,6 +188,18 @@ void initialiseAll()
|
|||
oilPressureProtectTable.values = configPage10.oilPressureProtMins;
|
||||
oilPressureProtectTable.axisX = configPage10.oilPressureProtRPM;
|
||||
|
||||
cltCalibrationTable_new.valueSize = SIZE_INT;
|
||||
cltCalibrationTable_new.axisSize = SIZE_INT;
|
||||
cltCalibrationTable_new.xSize = 32;
|
||||
cltCalibrationTable_new.values = cltCalibration_values;
|
||||
cltCalibrationTable_new.axisX = cltCalibration_bins;
|
||||
|
||||
iatCalibrationTable_new.valueSize = SIZE_INT;
|
||||
iatCalibrationTable_new.axisSize = SIZE_INT;
|
||||
iatCalibrationTable_new.xSize = 32;
|
||||
iatCalibrationTable_new.values = iatCalibration_values;
|
||||
iatCalibrationTable_new.axisX = iatCalibration_bins;
|
||||
|
||||
//Setup the calibration tables
|
||||
loadCalibration();
|
||||
|
||||
|
|
|
@ -409,7 +409,8 @@ void readCLT(bool useFilter)
|
|||
if(useFilter == true) { currentStatus.cltADC = ADC_FILTER(tempReading, configPage4.ADCFILTER_CLT, currentStatus.cltADC); }
|
||||
else { currentStatus.cltADC = tempReading; }
|
||||
|
||||
currentStatus.coolant = cltCalibrationTable[currentStatus.cltADC] - CALIBRATION_TEMPERATURE_OFFSET; //Temperature calibration values are stored as positive bytes. We subtract 40 from them to allow for negative temperatures
|
||||
//currentStatus.coolant = cltCalibrationTable[currentStatus.cltADC] - CALIBRATION_TEMPERATURE_OFFSET; //Temperature calibration values are stored as positive bytes. We subtract 40 from them to allow for negative temperatures
|
||||
currentStatus.coolant = table2D_getValue(&cltCalibrationTable_new, currentStatus.cltADC) - CALIBRATION_TEMPERATURE_OFFSET;
|
||||
}
|
||||
|
||||
void readIAT()
|
||||
|
@ -422,7 +423,8 @@ void readIAT()
|
|||
tempReading = fastMap1023toX(analogRead(pinIAT), 511); //Get the current raw IAT value
|
||||
#endif
|
||||
currentStatus.iatADC = ADC_FILTER(tempReading, configPage4.ADCFILTER_IAT, currentStatus.iatADC);
|
||||
currentStatus.IAT = iatCalibrationTable[currentStatus.iatADC] - CALIBRATION_TEMPERATURE_OFFSET;
|
||||
//currentStatus.IAT = iatCalibrationTable[currentStatus.iatADC] - CALIBRATION_TEMPERATURE_OFFSET;
|
||||
currentStatus.IAT = table2D_getValue(&iatCalibrationTable_new, currentStatus.iatADC) - CALIBRATION_TEMPERATURE_OFFSET;
|
||||
}
|
||||
|
||||
void readBaro()
|
||||
|
@ -581,12 +583,12 @@ byte getFuelPressure()
|
|||
tempReading = analogRead(pinFuelPressure);
|
||||
|
||||
tempFuelPressure = fastMap10Bit(tempReading, configPage10.fuelPressureMin, configPage10.fuelPressureMax);
|
||||
tempFuelPressure = ADC_FILTER(tempFuelPressure, 150, currentStatus.fuelPressure); //Apply speed smoothing factor
|
||||
//Sanity checks
|
||||
if(tempFuelPressure < 0) { tempFuelPressure = 0; }
|
||||
if(tempFuelPressure > configPage10.fuelPressureMax) { tempFuelPressure = configPage10.fuelPressureMax; }
|
||||
}
|
||||
|
||||
|
||||
return (byte)tempFuelPressure;
|
||||
}
|
||||
|
||||
|
@ -603,6 +605,7 @@ byte getOilPressure()
|
|||
|
||||
|
||||
tempOilPressure = fastMap10Bit(tempReading, configPage10.oilPressureMin, configPage10.oilPressureMax);
|
||||
tempOilPressure = ADC_FILTER(tempOilPressure, 150, currentStatus.oilPressure); //Apply speed smoothing factor
|
||||
//Sanity checks
|
||||
if(tempOilPressure < 0) { tempOilPressure = 0; }
|
||||
if(tempOilPressure > configPage10.oilPressureMax) { tempOilPressure = configPage10.oilPressureMax; }
|
||||
|
|
|
@ -729,6 +729,10 @@ void loop()
|
|||
{
|
||||
switch(configPage6.engineProtectType)
|
||||
{
|
||||
case PROTECT_CUT_OFF:
|
||||
ignitionOn = true;
|
||||
fuelOn = true;
|
||||
break;
|
||||
case PROTECT_CUT_IGN:
|
||||
ignitionOn = false;
|
||||
break;
|
||||
|
@ -766,7 +770,8 @@ void loop()
|
|||
ignitionOn = false; //Finally the ignition is fully cut completely
|
||||
}
|
||||
} //Hard/Rolling cut check
|
||||
} //RPM Check
|
||||
} //RPM Check
|
||||
else { currentStatus.engineProtectStatus = 0; } //Force all engine protection flags to be off as we're below the minimum RPM
|
||||
} //Protection active check
|
||||
else { curRollingCut = 0; } //Disables the rolling hard cut
|
||||
|
||||
|
|
|
@ -667,10 +667,10 @@ void loadCalibration()
|
|||
for(int x=0; x<CALIBRATION_TABLE_SIZE; x++) //Each calibration table is 512 bytes long
|
||||
{
|
||||
int y = EEPROM_CALIBRATION_CLT + x;
|
||||
cltCalibrationTable[x] = EEPROM.read(y);
|
||||
//cltCalibrationTable[x] = EEPROM.read(y);
|
||||
|
||||
y = EEPROM_CALIBRATION_IAT + x;
|
||||
iatCalibrationTable[x] = EEPROM.read(y);
|
||||
//iatCalibrationTable[x] = EEPROM.read(y);
|
||||
|
||||
y = EEPROM_CALIBRATION_O2 + x;
|
||||
o2CalibrationTable[x] = EEPROM.read(y);
|
||||
|
@ -688,10 +688,10 @@ void writeCalibration()
|
|||
for(int x=0; x<CALIBRATION_TABLE_SIZE; x++) //Each calibration table is 512 bytes long
|
||||
{
|
||||
int y = EEPROM_CALIBRATION_CLT + x;
|
||||
if(EEPROM.read(y) != cltCalibrationTable[x]) { EEPROM.write(y, cltCalibrationTable[x]); }
|
||||
//if(EEPROM.read(y) != cltCalibrationTable[x]) { EEPROM.write(y, cltCalibrationTable[x]); }
|
||||
|
||||
y = EEPROM_CALIBRATION_IAT + x;
|
||||
if(EEPROM.read(y) != iatCalibrationTable[x]) { EEPROM.write(y, iatCalibrationTable[x]); }
|
||||
//if(EEPROM.read(y) != iatCalibrationTable[x]) { EEPROM.write(y, iatCalibrationTable[x]); }
|
||||
|
||||
y = EEPROM_CALIBRATION_O2 + x;
|
||||
if(EEPROM.read(y) != o2CalibrationTable[x]) { EEPROM.write(y, o2CalibrationTable[x]); }
|
||||
|
|
|
@ -361,6 +361,25 @@ void doUpdates()
|
|||
// there is now optioon for fixed and relative timing retard for soft limit. This sets the soft limiter to the old fixed timing mode.
|
||||
configPage2.SoftLimitMode = SOFT_LIMIT_FIXED;
|
||||
}
|
||||
|
||||
if(EEPROM.read(EEPROM_DATA_VERSION) == 14)
|
||||
{
|
||||
//202006
|
||||
|
||||
//MAJOR update to move the coolant, IAT and O2 calibrations to 2D tables
|
||||
int y;
|
||||
for(int x=0; x<(CALIBRATION_TABLE_SIZE/16); x++) //Each calibration table is 512 bytes long
|
||||
{
|
||||
y = EEPROM_CALIBRATION_CLT + (x * 16);
|
||||
cltCalibration_values[x] = EEPROM.read(y);
|
||||
cltCalibration_bins[x] = (x * 16);
|
||||
|
||||
y = EEPROM_CALIBRATION_IAT + (x * 16);
|
||||
iatCalibration_values[x] = EEPROM.read(y);
|
||||
iatCalibration_bins[x] = (x * 16);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Final check is always for 255 and 0 (Brand new arduino)
|
||||
if( (EEPROM.read(EEPROM_DATA_VERSION) == 0) || (EEPROM.read(EEPROM_DATA_VERSION) == 255) )
|
||||
|
|
Loading…
Reference in New Issue