Updater for July firmware

This commit is contained in:
Josh Stewart 2017-07-30 23:04:37 +10:00
parent c69499497b
commit 07afb535d0
3 changed files with 21 additions and 5 deletions

View File

@ -3,7 +3,8 @@ Speeduino - Simple engine management for the Arduino Mega 2560 platform
Copyright (C) Josh Stewart Copyright (C) Josh Stewart
A full copy of the license may be found in the projects root directory A full copy of the license may be found in the projects root directory
*/ */
//integerPID boostPID(&MAPx100, &boost_pwm_target_value, &boostTargetx100, configPage3.boostKP, configPage3.boostKI, configPage3.boostKD, DIRECT); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call //Old PID method. Retained incase the new one has issues
//integerPID boostPID(&MAPx100, &boost_pwm_target_value, &boostTargetx100, configPage3.boostKP, configPage3.boostKI, configPage3.boostKD, DIRECT);
integerPIDnew boostPID(&currentStatus.MAP, &boost_pwm_target_value, &boost_cl_target_boost, configPage3.boostKP, configPage3.boostKI, configPage3.boostKD, DIRECT); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call integerPIDnew boostPID(&currentStatus.MAP, &boost_pwm_target_value, &boost_cl_target_boost, configPage3.boostKP, configPage3.boostKI, configPage3.boostKD, DIRECT); //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call
/* /*

View File

@ -242,7 +242,6 @@ void setup()
initialiseADC(); initialiseADC();
//Lookup the current MAP reading for barometric pressure //Lookup the current MAP reading for barometric pressure
//readMAP();
instanteneousMAPReading(); instanteneousMAPReading();
//barometric reading can be taken from either an external sensor if enabled, or simply by using the initial MAP value //barometric reading can be taken from either an external sensor if enabled, or simply by using the initial MAP value
if ( configPage3.useExtBaro != 0 ) if ( configPage3.useExtBaro != 0 )
@ -268,7 +267,6 @@ void setup()
if ((EEPROM.read(EEPROM_LAST_BARO) >= BARO_MIN) && (EEPROM.read(EEPROM_LAST_BARO) <= BARO_MAX)) //Make sure it's not invalid (Possible on first run etc) if ((EEPROM.read(EEPROM_LAST_BARO) >= BARO_MIN) && (EEPROM.read(EEPROM_LAST_BARO) <= BARO_MAX)) //Make sure it's not invalid (Possible on first run etc)
{ currentStatus.baro = EEPROM.read(EEPROM_LAST_BARO); } //last baro correction { currentStatus.baro = EEPROM.read(EEPROM_LAST_BARO); } //last baro correction
else { currentStatus.baro = 100; } //Final fall back position. else { currentStatus.baro = 100; } //Final fall back position.
} }
} }
@ -947,8 +945,8 @@ void loop()
if ( (timeToLastTooth < MAX_STALL_TIME) || (toothLastToothTime > currentLoopTime) ) //Check how long ago the last tooth was seen compared to now. If it was more than half a second ago then the engine is probably stopped. toothLastToothTime can be greater than currentLoopTime if a pulse occurs between getting the lastest time and doing the comparison if ( (timeToLastTooth < MAX_STALL_TIME) || (toothLastToothTime > currentLoopTime) ) //Check how long ago the last tooth was seen compared to now. If it was more than half a second ago then the engine is probably stopped. toothLastToothTime can be greater than currentLoopTime if a pulse occurs between getting the lastest time and doing the comparison
{ {
currentStatus.RPM = currentStatus.longRPM = getRPM(); //Long RPM is included here currentStatus.RPM = currentStatus.longRPM = getRPM(); //Long RPM is included here
//if(fuelPumpOn == false) { digitalWrite(pinFuelPump, HIGH); fuelPumpOn = true; } //Check if the fuel pump is on and turn it on if it isn't.
FUEL_PUMP_ON(); FUEL_PUMP_ON();
fuelPumpOn = true; //Not sure if this is needed.
} }
else else
{ {

View File

@ -8,7 +8,7 @@
void doUpdates() void doUpdates()
{ {
#define CURRENT_DATA_VERSION 4 #define CURRENT_DATA_VERSION 5
//May 2017 firmware introduced a -40 offset on the ignition table. Update that table to +40 //May 2017 firmware introduced a -40 offset on the ignition table. Update that table to +40
if(EEPROM.read(EEPROM_DATA_VERSION) == 2) if(EEPROM.read(EEPROM_DATA_VERSION) == 2)
@ -36,6 +36,23 @@ void doUpdates()
writeConfig(); writeConfig();
EEPROM.write(EEPROM_DATA_VERSION, 4); EEPROM.write(EEPROM_DATA_VERSION, 4);
} }
//July 2017 adds a cranking enrichment curve in place of the single value. This converts that single value to the curve
if(EEPROM.read(EEPROM_DATA_VERSION) == 4)
{
//Some default values for the bins (Doesn't matter too much here as the values against them will all be identical)
configPage11.crankingEnrichBins[0] = 0;
configPage11.crankingEnrichBins[1] = 40;
configPage11.crankingEnrichBins[2] = 70;
configPage11.crankingEnrichBins[3] = 100;
configPage11.crankingEnrichValues[0] = 100 + configPage1.crankingPct;
configPage11.crankingEnrichValues[1] = 100 + configPage1.crankingPct;
configPage11.crankingEnrichValues[2] = 100 + configPage1.crankingPct;
configPage11.crankingEnrichValues[3] = 100 + configPage1.crankingPct;
writeConfig();
EEPROM.write(EEPROM_DATA_VERSION, 5);
}
//Final check is always for 255 and 0 (Brand new arduino) //Final check is always for 255 and 0 (Brand new arduino)
if( (EEPROM.read(EEPROM_DATA_VERSION) == 0) || (EEPROM.read(EEPROM_DATA_VERSION) == 255) ) if( (EEPROM.read(EEPROM_DATA_VERSION) == 0) || (EEPROM.read(EEPROM_DATA_VERSION) == 255) )