Added cranking enrich range (#335)
* First commit Increases cranking enrichment range from 0..255% to 0..1275%, accuracy is reduced to 5% steps but this should be enough. Max allowable gammae increased from 511% to 1500%, overflow in PW-function prevented. * Last one missed the second overflow prevention (less bitshift) * Version needs to be increased in order to avoid performing value update routine on every startup * Less bitshift is required only on iCorrections
This commit is contained in:
parent
9ea5f44e93
commit
b942f090cf
|
@ -896,7 +896,7 @@ page = 10
|
|||
#else
|
||||
crankingEnrichBins = array, U08, 0, [4], "F", 1.8, -22.23, -40, 215, 0
|
||||
#endif
|
||||
crankingEnrichValues= array, U08, 4, [4], "%", 1.0, 0.0, 0, 255, 0 ; Values for the cranking enrichment curve
|
||||
crankingEnrichValues= array, U08, 4, [4], "%", 5.0, 0.0, 0, 1275, 0 ; Values for the cranking enrichment curve
|
||||
|
||||
rotaryType = bits , U08, 8, [0:1], "FC", "FD", "RX8", "INVALID"
|
||||
stagingEnabled = bits , U08, 8, [2:2], "Off","On"
|
||||
|
@ -3030,7 +3030,7 @@ cmdtestspk450dc = "E\x03\x0C"
|
|||
curve = cranking_enrich_curve, "Cranking Enrichment Curve"
|
||||
columnLabel = "Coolant", "Fuel Modifier"
|
||||
xAxis = -40, 110, 9
|
||||
yAxis = 0, 200, 6
|
||||
yAxis = 0, 400, 6
|
||||
xBins = crankingEnrichBins, coolant
|
||||
yBins = crankingEnrichValues
|
||||
;gauge = cltGau25
|
||||
|
|
|
@ -9,7 +9,7 @@ void initialiseCorrections();
|
|||
|
||||
uint16_t correctionsFuel();
|
||||
byte correctionWUE(); //Warmup enrichment
|
||||
byte correctionCranking(); //Cranking enrichment
|
||||
uint16_t correctionCranking(); //Cranking enrichment
|
||||
byte correctionASE(); //After Start Enrichment
|
||||
uint16_t correctionAccel(); //Acceleration Enrichment
|
||||
byte correctionFloodClear(); //Check for flood clear on cranking
|
||||
|
|
|
@ -48,7 +48,7 @@ uint16_t correctionsFuel()
|
|||
#define MAX_CORRECTIONS 3 //The maximum number of corrections allowed before the sum is reprocessed
|
||||
uint32_t sumCorrections = 100;
|
||||
byte activeCorrections = 0;
|
||||
byte result; //temporary variable to store the result of each corrections function
|
||||
uint16_t result; //temporary variable to store the result of each corrections function
|
||||
|
||||
//The values returned by each of the correction functions are multipled together and then divided back to give a single 0-255 value.
|
||||
currentStatus.wueCorrection = correctionWUE();
|
||||
|
@ -104,7 +104,7 @@ uint16_t correctionsFuel()
|
|||
|
||||
sumCorrections = sumCorrections / powint(100,activeCorrections);
|
||||
|
||||
if(sumCorrections > 511) { sumCorrections = 511; } //This is the maximum allowable increase as higher than this can potentially cause overflow in the PW() function (Can be fixed, but 511 is probably enough)
|
||||
if(sumCorrections > 1500) { sumCorrections = 1500; } //This is the maximum allowable increase during cranking
|
||||
return (uint16_t)sumCorrections;
|
||||
}
|
||||
|
||||
|
@ -176,13 +176,14 @@ byte correctionWUE()
|
|||
Cranking Enrichment
|
||||
Additional fuel % to be added when the engine is cranking
|
||||
*/
|
||||
byte correctionCranking()
|
||||
uint16_t correctionCranking()
|
||||
{
|
||||
byte crankingValue = 100;
|
||||
uint16_t crankingValue = 100;
|
||||
//if ( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) ) { crankingValue = 100 + configPage2.crankingPct; }
|
||||
if ( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
|
||||
{
|
||||
crankingValue = table2D_getValue(&crankingEnrichTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET);
|
||||
crankingValue = (uint16_t) crankingValue * 5; //multiplied by 5 to get range from 0% to 1275%
|
||||
}
|
||||
return crankingValue;
|
||||
}
|
||||
|
|
|
@ -1140,6 +1140,12 @@ uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
|
|||
uint16_t iAFR = 147;
|
||||
|
||||
//100% float free version, does sacrifice a little bit of accuracy, but not much.
|
||||
|
||||
//If corrections are huge, use less bitshift to avoid overflow. Sacrifices a bit more accuracy (basically only during very cold temp cranking)
|
||||
byte bitShift = 7;
|
||||
if (corrections > 511 ) { bitShift = 6; }
|
||||
if (corrections > 1023) { bitShift = 5; }
|
||||
|
||||
iVE = ((unsigned int)VE << 7) / 100;
|
||||
if ( configPage2.multiplyMAP == true ) {
|
||||
iMAP = ((unsigned int)MAP << 7) / currentStatus.baro; //Include multiply MAP (vs baro) if enabled
|
||||
|
@ -1147,7 +1153,7 @@ uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
|
|||
if ( (configPage2.includeAFR == true) && (configPage6.egoType == 2) && (currentStatus.runSecs > configPage6.ego_sdelay) ) {
|
||||
iAFR = ((unsigned int)currentStatus.O2 << 7) / currentStatus.afrTarget; //Include AFR (vs target) if enabled
|
||||
}
|
||||
iCorrections = (corrections << 7) / 100;
|
||||
iCorrections = (corrections << bitShift) / 100;
|
||||
|
||||
|
||||
unsigned long intermediate = ((uint32_t)REQ_FUEL * (uint32_t)iVE) >> 7; //Need to use an intermediate value to avoid overflowing the long
|
||||
|
@ -1158,7 +1164,7 @@ uint16_t PW(int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
|
|||
//EGO type must be set to wideband and the AFR warmup time must've elapsed for this to be used
|
||||
intermediate = (intermediate * (unsigned long)iAFR) >> 7;
|
||||
}
|
||||
intermediate = (intermediate * (unsigned long)iCorrections) >> 7;
|
||||
intermediate = (intermediate * (unsigned long)iCorrections) >> bitShift;
|
||||
if (intermediate != 0)
|
||||
{
|
||||
//If intermeditate is not 0, we need to add the opening time (0 typically indicates that one of the full fuel cuts is active)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
void doUpdates()
|
||||
{
|
||||
#define CURRENT_DATA_VERSION 13
|
||||
#define CURRENT_DATA_VERSION 14
|
||||
|
||||
//May 2017 firmware introduced a -40 offset on the ignition table. Update that table to +40
|
||||
if(EEPROM.read(EEPROM_DATA_VERSION) == 2)
|
||||
|
@ -299,6 +299,19 @@ void doUpdates()
|
|||
EEPROM.write(EEPROM_DATA_VERSION, 13);
|
||||
}
|
||||
|
||||
if(EEPROM.read(EEPROM_DATA_VERSION) == 13)
|
||||
{
|
||||
//202003-dev
|
||||
//Cranking enrichment range 0..1275% instead of older 0.255, so need to divide old values by 5
|
||||
configPage10.crankingEnrichValues[0] = configPage10.crankingEnrichValues[0] / 5;
|
||||
configPage10.crankingEnrichValues[1] = configPage10.crankingEnrichValues[1] / 5;
|
||||
configPage10.crankingEnrichValues[2] = configPage10.crankingEnrichValues[2] / 5;
|
||||
configPage10.crankingEnrichValues[3] = configPage10.crankingEnrichValues[3] / 5;
|
||||
|
||||
writeAllConfig();
|
||||
EEPROM.write(EEPROM_DATA_VERSION, 14);
|
||||
}
|
||||
|
||||
//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