Initial work on processing the 2nd fuel table

This commit is contained in:
Josh Stewart 2019-05-02 11:52:05 +10:00
parent 3fcabb487f
commit b12fec4a72
3 changed files with 60 additions and 2 deletions

View File

@ -2025,7 +2025,7 @@ void triggerSetEndTeeth_Miata9905()
if(configPage4.sparkMode == IGN_MODE_SEQUENTIAL)
{
if(currentStatus.advance > 10)
if(currentStatus.advance >= 10)
{
ignition1EndTooth = 8;
ignition2EndTooth = 2;

View File

@ -14,6 +14,7 @@
uint16_t PW(int REQ_FUEL, byte VE, long MAP, int corrections, int injOpen);
byte getVE();
byte getVE2();
byte getAdvance();
uint16_t calculateInjector2StartAngle(unsigned int);

View File

@ -103,6 +103,7 @@ void loop()
currentStatus.RPM = 0;
currentStatus.PW1 = 0;
currentStatus.VE = 0;
currentStatus.VE2 = 0;
toothLastToothTime = 0;
toothLastSecToothTime = 0;
//toothLastMinusOneToothTime = 0;
@ -280,9 +281,34 @@ void loop()
if( (configPage6.iacAlgorithm == IAC_ALGORITHM_STEP_OL) || (configPage6.iacAlgorithm == IAC_ALGORITHM_STEP_CL) ) { idleControl(); } //Run idlecontrol every loop for stepper idle.
byte totalVE = 0;
//VE calculation was moved outside the sync/RPM check so that the fuel load value will be accurately shown when RPM=0
currentStatus.VE = getVE();
//If the secondary fuel table is in use, also get the VE value from there
if(configPage10.fuel2Mode > 0)
{
currentStatus.VE2 = getVE2();
if(configPage10.fuel2Mode == FUEL2_MODE_MULTIPLY)
{
//Fuel 2 table is treated as a % value. Table 1 and 2 are multiplied together and divded by 100
totalVE = ((uint16_t)currentStatus.VE * (uint16_t)currentStatus.VE2) / 100;
}
else if(configPage10.fuel2Mode == FUEL2_MODE_ADD)
{
//Fuel tables are added together, but a check is made to make sure this won't overflow the 8-bit totalVE value
uint16_t combinedVE = (uint16_t)currentStatus.VE + (uint16_t)currentStatus.VE2;
if(combinedVE <= 255) { totalVE = combinedVE; }
else { totalVE = 255; }
}
else if(configPage10.fuel2Mode == FUEL2_MODE_SWITCH)
{
}
}
else { totalVE = currentStatus.VE; }
//Always check for sync
//Main loop runs within this clause
if (currentStatus.hasSync && (currentStatus.RPM > 0))
@ -315,7 +341,8 @@ void loop()
currentStatus.corrections = correctionsFuel();
currentStatus.advance = getAdvance();
currentStatus.PW1 = PW(req_fuel_uS, currentStatus.VE, currentStatus.MAP, currentStatus.corrections, inj_opentime_uS);
//currentStatus.PW1 = PW(req_fuel_uS, currentStatus.VE, currentStatus.MAP, currentStatus.corrections, inj_opentime_uS);
currentStatus.PW1 = PW(req_fuel_uS, totalVE, currentStatus.MAP, currentStatus.corrections, inj_opentime_uS);
//Manual adder for nitrous. These are not in correctionsFuel() because they are direct adders to the ms value, not % based
if(currentStatus.nitrous_status == NITROUS_STAGE1)
@ -1170,6 +1197,36 @@ byte getVE()
return tempVE;
}
/**
* @brief Looks up and returns the VE value from the secondary fuel table
*
* This performs largely the same operations as getVE() however the lookup is of the secondary fuel table and uses the secondary load source
* @return byte
*/
byte getVE2()
{
byte tempVE = 100;
if( configPage10.fuel2Algorithm == LOAD_SOURCE_MAP)
{
//Speed Density
currentStatus.fuelLoad2 = currentStatus.MAP;
}
else if (configPage10.fuel2Algorithm == LOAD_SOURCE_TPS)
{
//Alpha-N
currentStatus.fuelLoad2 = currentStatus.TPS;
}
else if (configPage10.fuel2Algorithm == LOAD_SOURCE_IMAPEMAP)
{
//IMAP / EMAP
currentStatus.fuelLoad2 = (currentStatus.MAP * 100) / currentStatus.EMAP;
}
else { currentStatus.fuelLoad2 = currentStatus.MAP; } //Fallback position
tempVE = get3DTableValue(&fuelTable2, currentStatus.fuelLoad2, currentStatus.RPM); //Perform lookup into fuel map for RPM vs MAP value
return tempVE;
}
/**
* @brief Performs a lookup of the ignition advance table. The values used to look this up will be RPM and whatever load source the user has configured
*