Fix issue when switching to sequential fuel post PR #478

This commit is contained in:
Josh Stewart 2022-04-28 10:57:36 +10:00
parent 2467960bbd
commit 7c94329bf3
5 changed files with 198 additions and 190 deletions

View File

@ -4,5 +4,7 @@
void initialiseAll(); void initialiseAll();
void initialiseTriggers(); void initialiseTriggers();
void setPinMapping(byte); void setPinMapping(byte);
void changeHalfToFullSync(void);
void changeFullToHalfSync(void);
#endif #endif

View File

@ -3297,3 +3297,196 @@ void initialiseTriggers()
break; break;
} }
} }
/** Change injectors or/and ignition angles to 720deg.
* Roll back req_fuel size and set number of outputs equal to cylinder count.
* */
void changeHalfToFullSync(void)
{
//Need to do another check for injLayout as this function can be called from ignition
if( (configPage2.injLayout == INJ_SEQUENTIAL) && (CRANK_ANGLE_MAX_INJ != 720) )
{
CRANK_ANGLE_MAX_INJ = 720;
maxIgnOutputs = configPage2.nCylinders;
req_fuel_uS *= 2;
inj1StartFunction = openInjector1;
inj1EndFunction = closeInjector1;
inj2StartFunction = openInjector2;
inj2EndFunction = closeInjector2;
inj3StartFunction = openInjector3;
inj3EndFunction = closeInjector3;
inj4StartFunction = openInjector4;
inj4EndFunction = closeInjector4;
inj5StartFunction = openInjector5;
inj5EndFunction = closeInjector5;
inj6StartFunction = openInjector6;
inj6EndFunction = closeInjector6;
inj7StartFunction = openInjector7;
inj7EndFunction = closeInjector7;
inj8StartFunction = openInjector8;
inj8EndFunction = closeInjector8;
switch (configPage2.nCylinders)
{
case 4:
channel3InjEnabled = true;
channel4InjEnabled = true;
break;
case 6:
channel4InjEnabled = true;
channel5InjEnabled = true;
channel6InjEnabled = true;
break;
case 8:
channel5InjEnabled = true;
channel6InjEnabled = true;
channel7InjEnabled = true;
channel8InjEnabled = true;
break;
default:
break; //No actions required for other cylinder counts
}
}
//Need to do another check for sparkMode as this function can be called from injection
if( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) && (CRANK_ANGLE_MAX_IGN != 720) )
{
CRANK_ANGLE_MAX_IGN = 720;
maxIgnOutputs = configPage2.nCylinders;
switch (configPage2.nCylinders)
{
case 4:
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
break;
case 6:
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
ign3StartFunction = beginCoil3Charge;
ign3EndFunction = endCoil3Charge;
break;
case 8:
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
ign3StartFunction = beginCoil3Charge;
ign3EndFunction = endCoil3Charge;
ign4StartFunction = beginCoil4Charge;
ign4EndFunction = endCoil4Charge;
break;
default:
break; //No actions required for other cylinder counts
}
}
}
/** Change injectors or/and ignition angles to 360deg.
* In semi sequentiol mode req_fuel size is half.
* Set number of outputs equal to half cylinder count.
* */
void changeFullToHalfSync(void)
{
if(configPage2.injLayout == INJ_SEQUENTIAL)
{
CRANK_ANGLE_MAX_INJ = 360;
maxIgnOutputs = configPage2.nCylinders / 2;
req_fuel_uS /= 2;
switch (configPage2.nCylinders)
{
case 4:
if(configPage4.inj4cylPairing == INJ_PAIR_13_24)
{
inj1StartFunction = openInjector1and3;
inj1EndFunction = closeInjector1and3;
inj2StartFunction = openInjector2and4;
inj2EndFunction = closeInjector2and4;
}
else
{
inj1StartFunction = openInjector1and4;
inj1EndFunction = closeInjector1and4;
inj2StartFunction = openInjector2and3;
inj2EndFunction = closeInjector2and3;
}
channel3InjEnabled = false;
channel4InjEnabled = false;
break;
case 6:
inj1StartFunction = openInjector1and4;
inj1EndFunction = closeInjector1and4;
inj2StartFunction = openInjector2and5;
inj2EndFunction = closeInjector2and5;
inj3StartFunction = openInjector3and6;
inj3EndFunction = closeInjector3and6;
channel4InjEnabled = false;
channel5InjEnabled = false;
channel6InjEnabled = false;
break;
case 8:
inj1StartFunction = openInjector1and5;
inj1EndFunction = closeInjector1and5;
inj2StartFunction = openInjector2and6;
inj2EndFunction = closeInjector2and6;
inj3StartFunction = openInjector3and7;
inj3EndFunction = closeInjector3and7;
inj4StartFunction = openInjector4and8;
inj4EndFunction = closeInjector4and8;
channel5InjEnabled = false;
channel6InjEnabled = false;
channel7InjEnabled = false;
channel8InjEnabled = false;
break;
}
}
if(configPage4.sparkMode == IGN_MODE_SEQUENTIAL)
{
CRANK_ANGLE_MAX_IGN = 360;
maxIgnOutputs = configPage2.nCylinders / 2;
switch (configPage2.nCylinders)
{
case 4:
ign1StartFunction = beginCoil1and3Charge;
ign1EndFunction = endCoil1and3Charge;
ign2StartFunction = beginCoil2and4Charge;
ign2EndFunction = endCoil2and4Charge;
break;
case 6:
ign1StartFunction = beginCoil1and4Charge;
ign1EndFunction = endCoil1and4Charge;
ign2StartFunction = beginCoil2and5Charge;
ign2EndFunction = endCoil2and5Charge;
ign3StartFunction = beginCoil3and6Charge;
ign3EndFunction = endCoil3and6Charge;
break;
case 8:
ign1StartFunction = beginCoil1and5Charge;
ign1EndFunction = endCoil1and5Charge;
ign2StartFunction = beginCoil2and6Charge;
ign2EndFunction = endCoil2and6Charge;
ign3StartFunction = beginCoil3and7Charge;
ign3EndFunction = endCoil3and7Charge;
ign4StartFunction = beginCoil4and8Charge;
ign4EndFunction = endCoil4and8Charge;
break;
}
}
}

View File

@ -586,9 +586,10 @@ void doUpdates()
if(readEEPROMVersion() == 19) if(readEEPROMVersion() == 19)
{ {
//202204 //202204
//Option added to select injector pairing on 4 cylinder engines
if( configPage4.inj4cylPairing > INJ_PAIR_14_23 ) { configPage4.inj4cylPairing = 0; } //Check valid value if( configPage4.inj4cylPairing > INJ_PAIR_14_23 ) { configPage4.inj4cylPairing = 0; } //Check valid value
//Half/Full sequential mode if( configPage2.nCylinders == 4 ) { configPage4.inj4cylPairing = INJ_PAIR_14_23; } //Force setting to use the default mode from previous FW versions. This is to prevent issues on any setups that have been wired accordingly
if( (configPage2.injLayout == INJ_SEQUENTIAL) && (configPage2.nCylinders == 4) ) { configPage4.inj4cylPairing = INJ_PAIR_13_24; } //Most of inline 4 uses 1-3-4-2 firing order
configPage9.hardRevMode = 1; //Set hard rev limiter to Fixed mode configPage9.hardRevMode = 1; //Set hard rev limiter to Fixed mode

View File

@ -33,8 +33,6 @@ extern uint8_t currentRuleStatus;
void setResetControlPinState(); void setResetControlPinState();
byte pinTranslate(byte); byte pinTranslate(byte);
byte pinTranslateAnalog(byte); byte pinTranslateAnalog(byte);
void changeHalfToFullSync(void);
void changeFullToHalfSync(void);
void initialiseProgrammableIO(); void initialiseProgrammableIO();
void checkProgrammableIO(); void checkProgrammableIO();
int16_t ProgrammableIOGetData(uint16_t index); int16_t ProgrammableIOGetData(uint16_t index);

View File

@ -117,192 +117,6 @@ void setResetControlPinState()
} }
} }
/** Change injectors or/and ignition angles to 720deg.
* Roll back req_fuel size and set number of outputs equal to cylinder count.
* */
void changeHalfToFullSync(void)
{
//Need to do another check for injLayout as this function can be called from ignition
if( (configPage2.injLayout == INJ_SEQUENTIAL) && (CRANK_ANGLE_MAX_INJ != 720) )
{
CRANK_ANGLE_MAX_INJ = 720;
maxIgnOutputs = configPage2.nCylinders;
req_fuel_uS *= 2;
switch (configPage2.nCylinders)
{
case 4:
inj1StartFunction = openInjector1;
inj1EndFunction = closeInjector1;
inj2StartFunction = openInjector2;
inj2EndFunction = closeInjector2;
channel3InjEnabled = true;
channel4InjEnabled = true;
break;
case 6:
inj1StartFunction = openInjector1;
inj1EndFunction = closeInjector1;
inj2StartFunction = openInjector2;
inj2EndFunction = closeInjector2;
inj3StartFunction = openInjector3;
inj3EndFunction = closeInjector3;
channel4InjEnabled = true;
channel5InjEnabled = true;
channel6InjEnabled = true;
break;
case 8:
inj1StartFunction = openInjector1;
inj1EndFunction = closeInjector1;
inj2StartFunction = openInjector2;
inj2EndFunction = closeInjector2;
inj3StartFunction = openInjector3;
inj3EndFunction = closeInjector3;
inj4StartFunction = openInjector4;
inj4EndFunction = closeInjector4;
channel5InjEnabled = true;
channel6InjEnabled = true;
channel7InjEnabled = true;
channel8InjEnabled = true;
break;
}
}
//Need to do another check for sparkMode as this function can be called from injection
if( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) && (CRANK_ANGLE_MAX_IGN != 720) )
{
CRANK_ANGLE_MAX_IGN = 720;
maxIgnOutputs = configPage2.nCylinders;
switch (configPage2.nCylinders)
{
case 4:
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
break;
case 6:
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
ign3StartFunction = beginCoil3Charge;
ign3EndFunction = endCoil3Charge;
break;
case 8:
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
ign3StartFunction = beginCoil3Charge;
ign3EndFunction = endCoil3Charge;
ign4StartFunction = beginCoil4Charge;
ign4EndFunction = endCoil4Charge;
break;
}
}
}
/** Change injectors or/and ignition angles to 360deg.
* In semi sequentiol mode req_fuel size is half.
* Set number of outputs equal to half cylinder count.
* */
void changeFullToHalfSync(void)
{
if(configPage2.injLayout == INJ_SEQUENTIAL)
{
CRANK_ANGLE_MAX_INJ = 360;
maxIgnOutputs = configPage2.nCylinders / 2;
req_fuel_uS /= 2;
switch (configPage2.nCylinders)
{
case 4:
if(configPage4.inj4cylPairing == INJ_PAIR_13_24)
{
inj1StartFunction = openInjector1and3;
inj1EndFunction = closeInjector1and3;
inj2StartFunction = openInjector2and4;
inj2EndFunction = closeInjector2and4;
}
else
{
inj1StartFunction = openInjector1and4;
inj1EndFunction = closeInjector1and4;
inj2StartFunction = openInjector2and3;
inj2EndFunction = closeInjector2and3;
}
channel3InjEnabled = false;
channel4InjEnabled = false;
break;
case 6:
inj1StartFunction = openInjector1and4;
inj1EndFunction = closeInjector1and4;
inj2StartFunction = openInjector2and5;
inj2EndFunction = closeInjector2and5;
inj3StartFunction = openInjector3and6;
inj3EndFunction = closeInjector3and6;
channel4InjEnabled = false;
channel5InjEnabled = false;
channel6InjEnabled = false;
break;
case 8:
inj1StartFunction = openInjector1and5;
inj1EndFunction = closeInjector1and5;
inj2StartFunction = openInjector2and6;
inj2EndFunction = closeInjector2and6;
inj3StartFunction = openInjector3and7;
inj3EndFunction = closeInjector3and7;
inj4StartFunction = openInjector4and8;
inj4EndFunction = closeInjector4and8;
channel5InjEnabled = false;
channel6InjEnabled = false;
channel7InjEnabled = false;
channel8InjEnabled = false;
break;
}
}
if(configPage4.sparkMode == IGN_MODE_SEQUENTIAL)
{
CRANK_ANGLE_MAX_IGN = 360;
maxIgnOutputs = configPage2.nCylinders / 2;
switch (configPage2.nCylinders)
{
case 4:
ign1StartFunction = beginCoil1and3Charge;
ign1EndFunction = endCoil1and3Charge;
ign2StartFunction = beginCoil2and4Charge;
ign2EndFunction = endCoil2and4Charge;
break;
case 6:
ign1StartFunction = beginCoil1and4Charge;
ign1EndFunction = endCoil1and4Charge;
ign2StartFunction = beginCoil2and5Charge;
ign2EndFunction = endCoil2and5Charge;
ign3StartFunction = beginCoil3and6Charge;
ign3EndFunction = endCoil3and6Charge;
break;
case 8:
ign1StartFunction = beginCoil1and5Charge;
ign1EndFunction = endCoil1and5Charge;
ign2StartFunction = beginCoil2and6Charge;
ign2EndFunction = endCoil2and6Charge;
ign3StartFunction = beginCoil3and7Charge;
ign3EndFunction = endCoil3and7Charge;
ign4StartFunction = beginCoil4and8Charge;
ign4EndFunction = endCoil4and8Charge;
break;
}
}
}
//********************************************************************************************************************************************************************************* //*********************************************************************************************************************************************************************************
void initialiseProgrammableIO() void initialiseProgrammableIO()
{ {