Merge branch 'master' of https://github.com/noisymime/speeduino into testing
This commit is contained in:
commit
f64f563306
|
@ -254,9 +254,9 @@ void initialiseAll()
|
||||||
|
|
||||||
if ( (configPage2.injLayout == INJ_SEQUENTIAL) && (configPage2.strokes == FOUR_STROKE) )
|
if ( (configPage2.injLayout == INJ_SEQUENTIAL) && (configPage2.strokes == FOUR_STROKE) )
|
||||||
{
|
{
|
||||||
CRANK_ANGLE_MAX_INJ = 720;
|
CRANK_ANGLE_MAX_INJ = 720;
|
||||||
currentStatus.nSquirts = 1;
|
currentStatus.nSquirts = 1;
|
||||||
req_fuel_uS = req_fuel_uS * 2;
|
req_fuel_uS = req_fuel_uS * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel1InjEnabled = true;
|
channel1InjEnabled = true;
|
||||||
|
@ -264,8 +264,8 @@ void initialiseAll()
|
||||||
//Check if injector staging is enabled
|
//Check if injector staging is enabled
|
||||||
if(configPage10.stagingEnabled == true)
|
if(configPage10.stagingEnabled == true)
|
||||||
{
|
{
|
||||||
channel3InjEnabled = true;
|
channel3InjEnabled = true;
|
||||||
channel3InjDegrees = channel1InjDegrees;
|
channel3InjDegrees = channel1InjDegrees;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -281,18 +281,18 @@ void initialiseAll()
|
||||||
|
|
||||||
if ( (configPage2.injLayout == INJ_SEQUENTIAL) && (configPage2.strokes == FOUR_STROKE) )
|
if ( (configPage2.injLayout == INJ_SEQUENTIAL) && (configPage2.strokes == FOUR_STROKE) )
|
||||||
{
|
{
|
||||||
CRANK_ANGLE_MAX_INJ = 720;
|
CRANK_ANGLE_MAX_INJ = 720;
|
||||||
currentStatus.nSquirts = 1;
|
currentStatus.nSquirts = 1;
|
||||||
req_fuel_uS = req_fuel_uS * 2;
|
req_fuel_uS = req_fuel_uS * 2;
|
||||||
}
|
}
|
||||||
//The below are true regardless of whether this is running sequential or not
|
//The below are true regardless of whether this is running sequential or not
|
||||||
if (configPage2.engineType == EVEN_FIRE ) { channel2InjDegrees = 180; }
|
if (configPage2.engineType == EVEN_FIRE ) { channel2InjDegrees = 180; }
|
||||||
else { channel2InjDegrees = configPage2.oddfire2; }
|
else { channel2InjDegrees = configPage2.oddfire2; }
|
||||||
if (!configPage2.injTiming)
|
if (!configPage2.injTiming)
|
||||||
{
|
{
|
||||||
//For simultaneous, all squirts happen at the same time
|
//For simultaneous, all squirts happen at the same time
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 0;
|
channel2InjDegrees = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel1InjEnabled = true;
|
channel1InjEnabled = true;
|
||||||
|
@ -301,11 +301,11 @@ void initialiseAll()
|
||||||
//Check if injector staging is enabled
|
//Check if injector staging is enabled
|
||||||
if(configPage10.stagingEnabled == true)
|
if(configPage10.stagingEnabled == true)
|
||||||
{
|
{
|
||||||
channel3InjEnabled = true;
|
channel3InjEnabled = true;
|
||||||
channel4InjEnabled = true;
|
channel4InjEnabled = true;
|
||||||
|
|
||||||
channel3InjDegrees = channel1InjDegrees;
|
channel3InjDegrees = channel1InjDegrees;
|
||||||
channel4InjDegrees = channel2InjDegrees;
|
channel4InjDegrees = channel2InjDegrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -318,15 +318,15 @@ void initialiseAll()
|
||||||
//Sequential and Single channel modes both run over 720 crank degrees, but only on 4 stroke engines.
|
//Sequential and Single channel modes both run over 720 crank degrees, but only on 4 stroke engines.
|
||||||
if( ( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) || (configPage4.sparkMode == IGN_MODE_SINGLE) ) && (configPage2.strokes == FOUR_STROKE) )
|
if( ( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) || (configPage4.sparkMode == IGN_MODE_SINGLE) ) && (configPage2.strokes == FOUR_STROKE) )
|
||||||
{
|
{
|
||||||
channel2IgnDegrees = 240;
|
channel2IgnDegrees = 240;
|
||||||
channel3IgnDegrees = 480;
|
channel3IgnDegrees = 480;
|
||||||
|
|
||||||
CRANK_ANGLE_MAX_IGN = 720;
|
CRANK_ANGLE_MAX_IGN = 720;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
channel2IgnDegrees = 120;
|
channel2IgnDegrees = 120;
|
||||||
channel3IgnDegrees = 240;
|
channel3IgnDegrees = 240;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -338,33 +338,33 @@ void initialiseAll()
|
||||||
//For alternatiing injection, the squirt occurs at different times for each channel
|
//For alternatiing injection, the squirt occurs at different times for each channel
|
||||||
if( (configPage2.injLayout == INJ_SEMISEQUENTIAL) || (configPage2.injLayout == INJ_PAIRED) || (configPage2.strokes == TWO_STROKE) )
|
if( (configPage2.injLayout == INJ_SEMISEQUENTIAL) || (configPage2.injLayout == INJ_PAIRED) || (configPage2.strokes == TWO_STROKE) )
|
||||||
{
|
{
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 120;
|
channel2InjDegrees = 120;
|
||||||
channel3InjDegrees = 240;
|
channel3InjDegrees = 240;
|
||||||
|
|
||||||
//Adjust the injection angles based on the number of squirts
|
//Adjust the injection angles based on the number of squirts
|
||||||
if (currentStatus.nSquirts > 2)
|
if (currentStatus.nSquirts > 2)
|
||||||
{
|
{
|
||||||
channel2InjDegrees = (channel2InjDegrees * 2) / currentStatus.nSquirts;
|
channel2InjDegrees = (channel2InjDegrees * 2) / currentStatus.nSquirts;
|
||||||
channel3InjDegrees = (channel3InjDegrees * 2) / currentStatus.nSquirts;
|
channel3InjDegrees = (channel3InjDegrees * 2) / currentStatus.nSquirts;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!configPage2.injTiming)
|
if (!configPage2.injTiming)
|
||||||
{
|
{
|
||||||
//For simultaneous, all squirts happen at the same time
|
//For simultaneous, all squirts happen at the same time
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 0;
|
channel2InjDegrees = 0;
|
||||||
channel3InjDegrees = 0;
|
channel3InjDegrees = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (configPage2.injLayout == INJ_SEQUENTIAL)
|
else if (configPage2.injLayout == INJ_SEQUENTIAL)
|
||||||
{
|
{
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 240;
|
channel2InjDegrees = 240;
|
||||||
channel3InjDegrees = 480;
|
channel3InjDegrees = 480;
|
||||||
CRANK_ANGLE_MAX_INJ = 720;
|
CRANK_ANGLE_MAX_INJ = 720;
|
||||||
currentStatus.nSquirts = 1;
|
currentStatus.nSquirts = 1;
|
||||||
req_fuel_uS = req_fuel_uS * 2;
|
req_fuel_uS = req_fuel_uS * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel1InjEnabled = true;
|
channel1InjEnabled = true;
|
||||||
|
@ -377,70 +377,70 @@ void initialiseAll()
|
||||||
maxIgnOutputs = 2; //Default value for 4 cylinder, may be changed below
|
maxIgnOutputs = 2; //Default value for 4 cylinder, may be changed below
|
||||||
if (configPage2.engineType == EVEN_FIRE )
|
if (configPage2.engineType == EVEN_FIRE )
|
||||||
{
|
{
|
||||||
channel2IgnDegrees = 180;
|
channel2IgnDegrees = 180;
|
||||||
//Adjust the injection angles based on the number of squirts
|
//Adjust the injection angles based on the number of squirts
|
||||||
if (currentStatus.nSquirts > 2)
|
if (currentStatus.nSquirts > 2)
|
||||||
{
|
{
|
||||||
channel2InjDegrees = channel2InjDegrees / (currentStatus.nSquirts / 2);
|
channel2InjDegrees = channel2InjDegrees / (currentStatus.nSquirts / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) && (configPage2.strokes == FOUR_STROKE) )
|
if( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) && (configPage2.strokes == FOUR_STROKE) )
|
||||||
{
|
{
|
||||||
channel3IgnDegrees = 360;
|
channel3IgnDegrees = 360;
|
||||||
channel4IgnDegrees = 540;
|
channel4IgnDegrees = 540;
|
||||||
|
|
||||||
CRANK_ANGLE_MAX_IGN = 720;
|
CRANK_ANGLE_MAX_IGN = 720;
|
||||||
maxIgnOutputs = 4;
|
maxIgnOutputs = 4;
|
||||||
}
|
}
|
||||||
else if(configPage4.sparkMode == IGN_MODE_ROTARY)
|
else if(configPage4.sparkMode == IGN_MODE_ROTARY)
|
||||||
{
|
{
|
||||||
//Rotary uses the ign 3 and 4 schedules for the trailing spark. They are offset from the ign 1 and 2 channels respectively and so use the same degrees as them
|
//Rotary uses the ign 3 and 4 schedules for the trailing spark. They are offset from the ign 1 and 2 channels respectively and so use the same degrees as them
|
||||||
channel3IgnDegrees = 0;
|
channel3IgnDegrees = 0;
|
||||||
channel4IgnDegrees = 180;
|
channel4IgnDegrees = 180;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
channel2IgnDegrees = configPage2.oddfire2;
|
channel2IgnDegrees = configPage2.oddfire2;
|
||||||
channel3IgnDegrees = configPage2.oddfire3;
|
channel3IgnDegrees = configPage2.oddfire3;
|
||||||
channel4IgnDegrees = configPage2.oddfire4;
|
channel4IgnDegrees = configPage2.oddfire4;
|
||||||
maxIgnOutputs = 4;
|
maxIgnOutputs = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//For alternatiing injection, the squirt occurs at different times for each channel
|
//For alternatiing injection, the squirt occurs at different times for each channel
|
||||||
if( (configPage2.injLayout == INJ_SEMISEQUENTIAL) || (configPage2.injLayout == INJ_PAIRED) || (configPage2.strokes == TWO_STROKE) )
|
if( (configPage2.injLayout == INJ_SEMISEQUENTIAL) || (configPage2.injLayout == INJ_PAIRED) || (configPage2.strokes == TWO_STROKE) )
|
||||||
{
|
{
|
||||||
channel2InjDegrees = 180;
|
channel2InjDegrees = 180;
|
||||||
|
|
||||||
if (!configPage2.injTiming)
|
if (!configPage2.injTiming)
|
||||||
{
|
{
|
||||||
//For simultaneous, all squirts happen at the same time
|
//For simultaneous, all squirts happen at the same time
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 0;
|
channel2InjDegrees = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (configPage2.injLayout == INJ_SEQUENTIAL)
|
else if (configPage2.injLayout == INJ_SEQUENTIAL)
|
||||||
{
|
{
|
||||||
channel2InjDegrees = 180;
|
channel2InjDegrees = 180;
|
||||||
channel3InjDegrees = 360;
|
channel3InjDegrees = 360;
|
||||||
channel4InjDegrees = 540;
|
channel4InjDegrees = 540;
|
||||||
|
|
||||||
channel3InjEnabled = true;
|
channel3InjEnabled = true;
|
||||||
channel4InjEnabled = true;
|
channel4InjEnabled = true;
|
||||||
|
|
||||||
CRANK_ANGLE_MAX_INJ = 720;
|
CRANK_ANGLE_MAX_INJ = 720;
|
||||||
currentStatus.nSquirts = 1;
|
currentStatus.nSquirts = 1;
|
||||||
req_fuel_uS = req_fuel_uS * 2;
|
req_fuel_uS = req_fuel_uS * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if injector staging is enabled
|
//Check if injector staging is enabled
|
||||||
if(configPage10.stagingEnabled == true)
|
if(configPage10.stagingEnabled == true)
|
||||||
{
|
{
|
||||||
channel3InjEnabled = true;
|
channel3InjEnabled = true;
|
||||||
channel4InjEnabled = true;
|
channel4InjEnabled = true;
|
||||||
|
|
||||||
channel3InjDegrees = channel1InjDegrees;
|
channel3InjDegrees = channel1InjDegrees;
|
||||||
channel4InjDegrees = channel2InjDegrees;
|
channel4InjDegrees = channel2InjDegrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel1InjEnabled = true;
|
channel1InjEnabled = true;
|
||||||
|
@ -456,42 +456,42 @@ void initialiseAll()
|
||||||
|
|
||||||
if(configPage4.sparkMode == IGN_MODE_SEQUENTIAL)
|
if(configPage4.sparkMode == IGN_MODE_SEQUENTIAL)
|
||||||
{
|
{
|
||||||
channel2IgnDegrees = 144;
|
channel2IgnDegrees = 144;
|
||||||
channel3IgnDegrees = 288;
|
channel3IgnDegrees = 288;
|
||||||
channel4IgnDegrees = 432;
|
channel4IgnDegrees = 432;
|
||||||
channel5IgnDegrees = 576;
|
channel5IgnDegrees = 576;
|
||||||
|
|
||||||
CRANK_ANGLE_MAX_IGN = 720;
|
CRANK_ANGLE_MAX_IGN = 720;
|
||||||
}
|
}
|
||||||
|
|
||||||
//For alternatiing injection, the squirt occurs at different times for each channel
|
//For alternatiing injection, the squirt occurs at different times for each channel
|
||||||
if( (configPage2.injLayout == INJ_SEMISEQUENTIAL) || (configPage2.injLayout == INJ_PAIRED) || (configPage2.strokes == TWO_STROKE) )
|
if( (configPage2.injLayout == INJ_SEMISEQUENTIAL) || (configPage2.injLayout == INJ_PAIRED) || (configPage2.strokes == TWO_STROKE) )
|
||||||
{
|
{
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 72;
|
channel2InjDegrees = 72;
|
||||||
channel3InjDegrees = 144;
|
channel3InjDegrees = 144;
|
||||||
channel4InjDegrees = 216;
|
channel4InjDegrees = 216;
|
||||||
channel5InjDegrees = 288;
|
channel5InjDegrees = 288;
|
||||||
}
|
}
|
||||||
else if (configPage2.injLayout == INJ_SEQUENTIAL)
|
else if (configPage2.injLayout == INJ_SEQUENTIAL)
|
||||||
{
|
{
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 144;
|
channel2InjDegrees = 144;
|
||||||
channel3InjDegrees = 288;
|
channel3InjDegrees = 288;
|
||||||
channel4InjDegrees = 432;
|
channel4InjDegrees = 432;
|
||||||
channel5InjDegrees = 576;
|
channel5InjDegrees = 576;
|
||||||
|
|
||||||
CRANK_ANGLE_MAX_INJ = 720;
|
CRANK_ANGLE_MAX_INJ = 720;
|
||||||
currentStatus.nSquirts = 1;
|
currentStatus.nSquirts = 1;
|
||||||
}
|
}
|
||||||
if (!configPage2.injTiming)
|
if (!configPage2.injTiming)
|
||||||
{
|
{
|
||||||
//For simultaneous, all squirts happen at the same time
|
//For simultaneous, all squirts happen at the same time
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 0;
|
channel2InjDegrees = 0;
|
||||||
channel3InjDegrees = 0;
|
channel3InjDegrees = 0;
|
||||||
channel4InjDegrees = 0;
|
channel4InjDegrees = 0;
|
||||||
channel5InjDegrees = 0;
|
channel5InjDegrees = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel1InjEnabled = true;
|
channel1InjEnabled = true;
|
||||||
|
@ -512,36 +512,36 @@ void initialiseAll()
|
||||||
//Adjust the injection angles based on the number of squirts
|
//Adjust the injection angles based on the number of squirts
|
||||||
if (currentStatus.nSquirts > 2)
|
if (currentStatus.nSquirts > 2)
|
||||||
{
|
{
|
||||||
channel2InjDegrees = channel2InjDegrees / (currentStatus.nSquirts / 2);
|
channel2InjDegrees = channel2InjDegrees / (currentStatus.nSquirts / 2);
|
||||||
channel3InjDegrees = channel3InjDegrees / (currentStatus.nSquirts / 2);
|
channel3InjDegrees = channel3InjDegrees / (currentStatus.nSquirts / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INJ_CHANNELS >= 6
|
#if INJ_CHANNELS >= 6
|
||||||
if (configPage2.injLayout == INJ_SEQUENTIAL)
|
if (configPage2.injLayout == INJ_SEQUENTIAL)
|
||||||
{
|
{
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 120;
|
channel2InjDegrees = 120;
|
||||||
channel3InjDegrees = 240;
|
channel3InjDegrees = 240;
|
||||||
channel4InjDegrees = 360;
|
channel4InjDegrees = 360;
|
||||||
channel5InjDegrees = 480;
|
channel5InjDegrees = 480;
|
||||||
channel6InjDegrees = 600;
|
channel6InjDegrees = 600;
|
||||||
|
|
||||||
channel4InjEnabled = true;
|
channel4InjEnabled = true;
|
||||||
channel5InjEnabled = true;
|
channel5InjEnabled = true;
|
||||||
channel6InjEnabled = true;
|
channel6InjEnabled = true;
|
||||||
|
|
||||||
CRANK_ANGLE_MAX_INJ = 720;
|
CRANK_ANGLE_MAX_INJ = 720;
|
||||||
currentStatus.nSquirts = 1;
|
currentStatus.nSquirts = 1;
|
||||||
req_fuel_uS = req_fuel_uS * 2;
|
req_fuel_uS = req_fuel_uS * 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!configPage2.injTiming)
|
if (!configPage2.injTiming)
|
||||||
{
|
{
|
||||||
//For simultaneous, all squirts happen at the same time
|
//For simultaneous, all squirts happen at the same time
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 0;
|
channel2InjDegrees = 0;
|
||||||
channel3InjDegrees = 0;
|
channel3InjDegrees = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
configPage2.injLayout = 0; //This is a failsafe. We can never run semi-sequential with more than 4 cylinders
|
configPage2.injLayout = 0; //This is a failsafe. We can never run semi-sequential with more than 4 cylinders
|
||||||
|
@ -559,31 +559,31 @@ void initialiseAll()
|
||||||
//Adjust the injection angles based on the number of squirts
|
//Adjust the injection angles based on the number of squirts
|
||||||
if (currentStatus.nSquirts > 2)
|
if (currentStatus.nSquirts > 2)
|
||||||
{
|
{
|
||||||
channel2InjDegrees = channel2InjDegrees / (currentStatus.nSquirts / 2);
|
channel2InjDegrees = channel2InjDegrees / (currentStatus.nSquirts / 2);
|
||||||
channel3InjDegrees = channel3InjDegrees / (currentStatus.nSquirts / 2);
|
channel3InjDegrees = channel3InjDegrees / (currentStatus.nSquirts / 2);
|
||||||
channel4InjDegrees = channel4InjDegrees / (currentStatus.nSquirts / 2);
|
channel4InjDegrees = channel4InjDegrees / (currentStatus.nSquirts / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INJ_CHANNELS >= 8
|
#if INJ_CHANNELS >= 8
|
||||||
if (configPage2.injLayout == INJ_SEQUENTIAL)
|
if (configPage2.injLayout == INJ_SEQUENTIAL)
|
||||||
{
|
{
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 90;
|
channel2InjDegrees = 90;
|
||||||
channel3InjDegrees = 180;
|
channel3InjDegrees = 180;
|
||||||
channel4InjDegrees = 270;
|
channel4InjDegrees = 270;
|
||||||
channel5InjDegrees = 360;
|
channel5InjDegrees = 360;
|
||||||
channel6InjDegrees = 450;
|
channel6InjDegrees = 450;
|
||||||
channel7InjDegrees = 540;
|
channel7InjDegrees = 540;
|
||||||
channel8InjDegrees = 630;
|
channel8InjDegrees = 630;
|
||||||
|
|
||||||
channel5InjEnabled = true;
|
channel5InjEnabled = true;
|
||||||
channel6InjEnabled = true;
|
channel6InjEnabled = true;
|
||||||
channel7InjEnabled = true;
|
channel7InjEnabled = true;
|
||||||
channel8InjEnabled = true;
|
channel8InjEnabled = true;
|
||||||
|
|
||||||
CRANK_ANGLE_MAX_INJ = 720;
|
CRANK_ANGLE_MAX_INJ = 720;
|
||||||
currentStatus.nSquirts = 1;
|
currentStatus.nSquirts = 1;
|
||||||
req_fuel_uS = req_fuel_uS * 2;
|
req_fuel_uS = req_fuel_uS * 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -591,11 +591,11 @@ void initialiseAll()
|
||||||
|
|
||||||
if (!configPage2.injTiming)
|
if (!configPage2.injTiming)
|
||||||
{
|
{
|
||||||
//For simultaneous, all squirts happen at the same time
|
//For simultaneous, all squirts happen at the same time
|
||||||
channel1InjDegrees = 0;
|
channel1InjDegrees = 0;
|
||||||
channel2InjDegrees = 0;
|
channel2InjDegrees = 0;
|
||||||
channel3InjDegrees = 0;
|
channel3InjDegrees = 0;
|
||||||
channel4InjDegrees = 0;
|
channel4InjDegrees = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
configPage2.injLayout = 0; //This is a failsafe. We can never run semi-sequential with more than 4 cylinders
|
configPage2.injLayout = 0; //This is a failsafe. We can never run semi-sequential with more than 4 cylinders
|
||||||
|
@ -651,29 +651,29 @@ void initialiseAll()
|
||||||
//This is not a valid mode for >4 cylinders
|
//This is not a valid mode for >4 cylinders
|
||||||
if( configPage2.nCylinders <= 4 )
|
if( configPage2.nCylinders <= 4 )
|
||||||
{
|
{
|
||||||
ign1StartFunction = beginCoil1and3Charge;
|
ign1StartFunction = beginCoil1and3Charge;
|
||||||
ign1EndFunction = endCoil1and3Charge;
|
ign1EndFunction = endCoil1and3Charge;
|
||||||
ign2StartFunction = beginCoil2and4Charge;
|
ign2StartFunction = beginCoil2and4Charge;
|
||||||
ign2EndFunction = endCoil2and4Charge;
|
ign2EndFunction = endCoil2and4Charge;
|
||||||
|
|
||||||
ign3StartFunction = nullCallback;
|
ign3StartFunction = nullCallback;
|
||||||
ign3EndFunction = nullCallback;
|
ign3EndFunction = nullCallback;
|
||||||
ign4StartFunction = nullCallback;
|
ign4StartFunction = nullCallback;
|
||||||
ign4EndFunction = nullCallback;
|
ign4EndFunction = nullCallback;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//If the person has inadvertantly selected this when running more than 4 cylinders, just use standard Wasted spark mode
|
//If the person has inadvertantly selected this when running more than 4 cylinders, just use standard Wasted spark mode
|
||||||
ign1StartFunction = beginCoil1Charge;
|
ign1StartFunction = beginCoil1Charge;
|
||||||
ign1EndFunction = endCoil1Charge;
|
ign1EndFunction = endCoil1Charge;
|
||||||
ign2StartFunction = beginCoil2Charge;
|
ign2StartFunction = beginCoil2Charge;
|
||||||
ign2EndFunction = endCoil2Charge;
|
ign2EndFunction = endCoil2Charge;
|
||||||
ign3StartFunction = beginCoil3Charge;
|
ign3StartFunction = beginCoil3Charge;
|
||||||
ign3EndFunction = endCoil3Charge;
|
ign3EndFunction = endCoil3Charge;
|
||||||
ign4StartFunction = beginCoil4Charge;
|
ign4StartFunction = beginCoil4Charge;
|
||||||
ign4EndFunction = endCoil4Charge;
|
ign4EndFunction = endCoil4Charge;
|
||||||
ign5StartFunction = beginCoil5Charge;
|
ign5StartFunction = beginCoil5Charge;
|
||||||
ign5EndFunction = endCoil5Charge;
|
ign5EndFunction = endCoil5Charge;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -699,15 +699,15 @@ void initialiseAll()
|
||||||
case IGN_MODE_ROTARY:
|
case IGN_MODE_ROTARY:
|
||||||
if(configPage10.rotaryType == ROTARY_IGN_FC)
|
if(configPage10.rotaryType == ROTARY_IGN_FC)
|
||||||
{
|
{
|
||||||
ign1StartFunction = beginCoil1Charge;
|
ign1StartFunction = beginCoil1Charge;
|
||||||
ign1EndFunction = endCoil1Charge;
|
ign1EndFunction = endCoil1Charge;
|
||||||
ign2StartFunction = beginCoil1Charge;
|
ign2StartFunction = beginCoil1Charge;
|
||||||
ign2EndFunction = endCoil1Charge;
|
ign2EndFunction = endCoil1Charge;
|
||||||
|
|
||||||
ign3StartFunction = beginTrailingCoilCharge;
|
ign3StartFunction = beginTrailingCoilCharge;
|
||||||
ign3EndFunction = endTrailingCoilCharge1;
|
ign3EndFunction = endTrailingCoilCharge1;
|
||||||
ign4StartFunction = beginTrailingCoilCharge;
|
ign4StartFunction = beginTrailingCoilCharge;
|
||||||
ign4EndFunction = endTrailingCoilCharge2;
|
ign4EndFunction = endTrailingCoilCharge2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -732,8 +732,8 @@ void initialiseAll()
|
||||||
//First check that the priming time is not 0
|
//First check that the priming time is not 0
|
||||||
if(configPage2.fpPrime > 0)
|
if(configPage2.fpPrime > 0)
|
||||||
{
|
{
|
||||||
FUEL_PUMP_ON();
|
FUEL_PUMP_ON();
|
||||||
currentStatus.fuelPumpOn = true;
|
currentStatus.fuelPumpOn = true;
|
||||||
}
|
}
|
||||||
else { fpPrimed = true; } //If the user has set 0 for the pump priming, immediately mark the priming as being completed
|
else { fpPrimed = true; } //If the user has set 0 for the pump priming, immediately mark the priming as being completed
|
||||||
|
|
||||||
|
@ -741,10 +741,10 @@ void initialiseAll()
|
||||||
//Perform the priming pulses. Set these to run at an arbitrary time in the future (100us). The prime pulse value is in ms*10, so need to multiple by 100 to get to uS
|
//Perform the priming pulses. Set these to run at an arbitrary time in the future (100us). The prime pulse value is in ms*10, so need to multiple by 100 to get to uS
|
||||||
if(configPage2.primePulse > 0)
|
if(configPage2.primePulse > 0)
|
||||||
{
|
{
|
||||||
setFuelSchedule1(100, (unsigned long)(configPage2.primePulse * 100));
|
setFuelSchedule1(100, (unsigned long)(configPage2.primePulse * 100));
|
||||||
setFuelSchedule2(100, (unsigned long)(configPage2.primePulse * 100));
|
setFuelSchedule2(100, (unsigned long)(configPage2.primePulse * 100));
|
||||||
setFuelSchedule3(100, (unsigned long)(configPage2.primePulse * 100));
|
setFuelSchedule3(100, (unsigned long)(configPage2.primePulse * 100));
|
||||||
setFuelSchedule4(100, (unsigned long)(configPage2.primePulse * 100));
|
setFuelSchedule4(100, (unsigned long)(configPage2.primePulse * 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1243,7 +1243,6 @@ void setPinMapping(byte boardID)
|
||||||
pinSpareLOut3 = 28; //low current output spare3
|
pinSpareLOut3 = 28; //low current output spare3
|
||||||
pinSpareLOut4 = 29; //low current output spare4
|
pinSpareLOut4 = 29; //low current output spare4
|
||||||
pinFan = 24; //Pin for the fan output
|
pinFan = 24; //Pin for the fan output
|
||||||
//pinFan2 = 25; //Pin for the 2nd fan output
|
|
||||||
pinResetControl = 46; //Reset control output PLACEHOLDER value for now
|
pinResetControl = 46; //Reset control output PLACEHOLDER value for now
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -1253,14 +1252,16 @@ void setPinMapping(byte boardID)
|
||||||
//Pin mappings as per the teensy rev A shield
|
//Pin mappings as per the teensy rev A shield
|
||||||
pinInjector1 = 2; //Output pin injector 1 is on
|
pinInjector1 = 2; //Output pin injector 1 is on
|
||||||
pinInjector2 = 10; //Output pin injector 2 is on
|
pinInjector2 = 10; //Output pin injector 2 is on
|
||||||
pinInjector3 = 6; //Output pin injector 3 is on - NOT USED
|
pinInjector3 = 6; //Output pin injector 3 is on
|
||||||
pinInjector4 = 9; //Output pin injector 4 is on - NOT USED
|
pinInjector4 = 9; //Output pin injector 4 is on
|
||||||
//pinInjector5 = 13; //Placeholder only - NOT USED
|
//Placeholder only - NOT USED:
|
||||||
|
//pinInjector5 = 13;
|
||||||
pinCoil1 = 29; //Pin for coil 1
|
pinCoil1 = 29; //Pin for coil 1
|
||||||
pinCoil2 = 30; //Pin for coil 2
|
pinCoil2 = 30; //Pin for coil 2
|
||||||
pinCoil3 = 31; //Pin for coil 3 - ONLY WITH DB2
|
pinCoil3 = 31; //Pin for coil 3 - ONLY WITH DB2
|
||||||
pinCoil4 = 32; //Pin for coil 4 - ONLY WITH DB2
|
pinCoil4 = 32; //Pin for coil 4 - ONLY WITH DB2
|
||||||
//pinCoil5 = 46; //Placeholder only - NOT USED
|
//Placeholder only - NOT USED:
|
||||||
|
//pinCoil5 = 46;
|
||||||
pinTrigger = 23; //The CAS pin
|
pinTrigger = 23; //The CAS pin
|
||||||
pinTrigger2 = 36; //The Cam Sensor pin
|
pinTrigger2 = 36; //The Cam Sensor pin
|
||||||
pinTPS = 16; //TPS input pin
|
pinTPS = 16; //TPS input pin
|
||||||
|
@ -1270,25 +1271,15 @@ void setPinMapping(byte boardID)
|
||||||
pinO2 = A22; //O2 sensor pin
|
pinO2 = A22; //O2 sensor pin
|
||||||
pinO2_2 = A21; //O2 sensor pin (second sensor)
|
pinO2_2 = A21; //O2 sensor pin (second sensor)
|
||||||
pinBat = 18; //Battery reference voltage pin
|
pinBat = 18; //Battery reference voltage pin
|
||||||
//pinBaro = A6; //Baro sensor pin - ONLY WITH DB
|
|
||||||
//pinSpareTemp1 = A7; //spare Analog input 1 - ONLY WITH DB
|
|
||||||
//pinDisplayReset = 48; // OLED reset pin - NOT USED
|
|
||||||
pinTachOut = 20; //Tacho output pin
|
pinTachOut = 20; //Tacho output pin
|
||||||
pinIdle1 = 5; //Single wire idle control
|
pinIdle1 = 5; //Single wire idle control
|
||||||
//pinIdle2 = 47; //2 wire idle control - NOT USED
|
|
||||||
pinBoost = 11; //Boost control
|
pinBoost = 11; //Boost control
|
||||||
//pinVVT_1 = 6; //Default VVT output
|
|
||||||
pinFuelPump = 38; //Fuel pump output
|
pinFuelPump = 38; //Fuel pump output
|
||||||
pinStepperDir = 34; //Direction pin for DRV8825 driver
|
pinStepperDir = 34; //Direction pin for DRV8825 driver
|
||||||
pinStepperStep = 35; //Step pin for DRV8825 driver
|
pinStepperStep = 35; //Step pin for DRV8825 driver
|
||||||
pinStepperEnable = 33; //Enable pin for DRV8825 driver
|
pinStepperEnable = 33; //Enable pin for DRV8825 driver
|
||||||
pinLaunch = 26; //Can be overwritten below
|
pinLaunch = 26; //Can be overwritten below
|
||||||
//pinFlex = 20; // Flex sensor (Must be external interrupt enabled) - ONLY WITH DB
|
|
||||||
pinFan = 37; //Pin for the fan output - ONLY WITH DB
|
pinFan = 37; //Pin for the fan output - ONLY WITH DB
|
||||||
//pinSpareLOut1 = 32; //low current output spare1 - ONLY WITH DB
|
|
||||||
//pinSpareLOut2 = 34; //low current output spare2 - ONLY WITH DB
|
|
||||||
//pinSpareLOut3 = 36; //low current output spare3 - ONLY WITH DB
|
|
||||||
//pinResetControl = 26; //Reset control output
|
|
||||||
pinSpareHOut1 = 8; // high current output spare1
|
pinSpareHOut1 = 8; // high current output spare1
|
||||||
pinSpareHOut2 = 7; // high current output spare2
|
pinSpareHOut2 = 7; // high current output spare2
|
||||||
pinSpareLOut1 = 21; //low current output spare1
|
pinSpareLOut1 = 21; //low current output spare1
|
||||||
|
@ -1300,12 +1291,10 @@ void setPinMapping(byte boardID)
|
||||||
pinInjector2 = 10; //Output pin injector 2 is on
|
pinInjector2 = 10; //Output pin injector 2 is on
|
||||||
pinInjector3 = 6; //Output pin injector 3 is on - NOT USED
|
pinInjector3 = 6; //Output pin injector 3 is on - NOT USED
|
||||||
pinInjector4 = 9; //Output pin injector 4 is on - NOT USED
|
pinInjector4 = 9; //Output pin injector 4 is on - NOT USED
|
||||||
//pinInjector5 = 13; //Placeholder only - NOT USED
|
|
||||||
pinCoil1 = 29; //Pin for coil 1
|
pinCoil1 = 29; //Pin for coil 1
|
||||||
pinCoil2 = 30; //Pin for coil 2
|
pinCoil2 = 30; //Pin for coil 2
|
||||||
pinCoil3 = 31; //Pin for coil 3 - ONLY WITH DB2
|
pinCoil3 = 31; //Pin for coil 3 - ONLY WITH DB2
|
||||||
pinCoil4 = 32; //Pin for coil 4 - ONLY WITH DB2
|
pinCoil4 = 32; //Pin for coil 4 - ONLY WITH DB2
|
||||||
//pinCoil5 = 46; //Placeholder only - NOT USED
|
|
||||||
pinTrigger = 23; //The CAS pin
|
pinTrigger = 23; //The CAS pin
|
||||||
pinTrigger2 = 36; //The Cam Sensor pin
|
pinTrigger2 = 36; //The Cam Sensor pin
|
||||||
pinTPS = 16; //TPS input pin
|
pinTPS = 16; //TPS input pin
|
||||||
|
@ -1315,25 +1304,15 @@ void setPinMapping(byte boardID)
|
||||||
pinO2 = A22; //O2 sensor pin
|
pinO2 = A22; //O2 sensor pin
|
||||||
pinO2_2 = A21; //O2 sensor pin (second sensor)
|
pinO2_2 = A21; //O2 sensor pin (second sensor)
|
||||||
pinBat = 18; //Battery reference voltage pin
|
pinBat = 18; //Battery reference voltage pin
|
||||||
//pinBaro = A6; //Baro sensor pin - ONLY WITH DB
|
|
||||||
//pinSpareTemp1 = A7; //spare Analog input 1 - ONLY WITH DB
|
|
||||||
//pinDisplayReset = 48; // OLED reset pin - NOT USED
|
|
||||||
pinTachOut = 20; //Tacho output pin
|
pinTachOut = 20; //Tacho output pin
|
||||||
pinIdle1 = 5; //Single wire idle control
|
pinIdle1 = 5; //Single wire idle control
|
||||||
//pinIdle2 = 47; //2 wire idle control - NOT USED
|
|
||||||
pinBoost = 11; //Boost control
|
pinBoost = 11; //Boost control
|
||||||
//pinVVT_1 = 6; //Default VVT output
|
|
||||||
pinFuelPump = 38; //Fuel pump output
|
pinFuelPump = 38; //Fuel pump output
|
||||||
pinStepperDir = 34; //Direction pin for DRV8825 driver
|
pinStepperDir = 34; //Direction pin for DRV8825 driver
|
||||||
pinStepperStep = 35; //Step pin for DRV8825 driver
|
pinStepperStep = 35; //Step pin for DRV8825 driver
|
||||||
pinStepperEnable = 33; //Enable pin for DRV8825 driver
|
pinStepperEnable = 33; //Enable pin for DRV8825 driver
|
||||||
pinLaunch = 26; //Can be overwritten below
|
pinLaunch = 26; //Can be overwritten below
|
||||||
//pinFlex = 20; // Flex sensor (Must be external interrupt enabled) - ONLY WITH DB
|
|
||||||
pinFan = 37; //Pin for the fan output - ONLY WITH DB
|
pinFan = 37; //Pin for the fan output - ONLY WITH DB
|
||||||
//pinSpareLOut1 = 32; //low current output spare1 - ONLY WITH DB
|
|
||||||
//pinSpareLOut2 = 34; //low current output spare2 - ONLY WITH DB
|
|
||||||
//pinSpareLOut3 = 36; //low current output spare3 - ONLY WITH DB
|
|
||||||
//pinResetControl = 26; //Reset control output
|
|
||||||
pinSpareHOut1 = 8; // high current output spare1
|
pinSpareHOut1 = 8; // high current output spare1
|
||||||
pinSpareHOut2 = 7; // high current output spare2
|
pinSpareHOut2 = 7; // high current output spare2
|
||||||
pinSpareLOut1 = 21; //low current output spare1
|
pinSpareLOut1 = 21; //low current output spare1
|
||||||
|
@ -1602,7 +1581,7 @@ void initialiseTriggers()
|
||||||
attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge);
|
attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(configPage4.TrigEdge == 0) { attachInterrupt(triggerInterrupt, triggerHandler, RISING); } // Attach the crank trigger wheel interrupt (Hall sensor drags to ground when triggering)
|
if(configPage4.TrigEdge == 0) { attachInterrupt(triggerInterrupt, triggerHandler, RISING); }
|
||||||
else { attachInterrupt(triggerInterrupt, triggerHandler, FALLING); }
|
else { attachInterrupt(triggerInterrupt, triggerHandler, FALLING); }
|
||||||
if(configPage4.TrigEdgeSec == 0) { attachInterrupt(triggerInterrupt2, triggerSec_missingTooth, RISING); }
|
if(configPage4.TrigEdgeSec == 0) { attachInterrupt(triggerInterrupt2, triggerSec_missingTooth, RISING); }
|
||||||
else { attachInterrupt(triggerInterrupt2, triggerSec_missingTooth, FALLING); }
|
else { attachInterrupt(triggerInterrupt2, triggerSec_missingTooth, FALLING); }
|
||||||
|
|
|
@ -30,7 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include "corrections.h"
|
#include "corrections.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
//#include "display.h" //All display code is currently disabled
|
|
||||||
#include "decoders.h"
|
#include "decoders.h"
|
||||||
#include "idle.h"
|
#include "idle.h"
|
||||||
#include "auxiliaries.h"
|
#include "auxiliaries.h"
|
||||||
|
@ -134,12 +133,6 @@ void loop()
|
||||||
boostDisable();
|
boostDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Uncomment the following for testing
|
|
||||||
/*
|
|
||||||
currentStatus.hasSync = true;
|
|
||||||
currentStatus.RPM = 500;
|
|
||||||
*/
|
|
||||||
|
|
||||||
//***Perform sensor reads***
|
//***Perform sensor reads***
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
readMAP();
|
readMAP();
|
||||||
|
@ -199,20 +192,17 @@ void loop()
|
||||||
//And check whether the tooth log buffer is ready
|
//And check whether the tooth log buffer is ready
|
||||||
if(toothHistoryIndex > TOOTH_LOG_SIZE) { BIT_SET(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY); }
|
if(toothHistoryIndex > TOOTH_LOG_SIZE) { BIT_SET(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY); }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(BIT_CHECK(LOOP_TIMER, BIT_TIMER_30HZ)) //30 hertz
|
if(BIT_CHECK(LOOP_TIMER, BIT_TIMER_30HZ)) //30 hertz
|
||||||
{
|
{
|
||||||
//Nothing here currently
|
|
||||||
BIT_CLEAR(TIMER_mask, BIT_TIMER_30HZ);
|
BIT_CLEAR(TIMER_mask, BIT_TIMER_30HZ);
|
||||||
//Most boost tends to run at about 30Hz, so placing it here ensures a new target time is fetched frequently enough
|
//Most boost tends to run at about 30Hz, so placing it here ensures a new target time is fetched frequently enough
|
||||||
//currentStatus.RPM = 3000;
|
|
||||||
boostControl();
|
boostControl();
|
||||||
}
|
}
|
||||||
//The IAT and CLT readings can be done less frequently (4 times per second)
|
|
||||||
if (BIT_CHECK(LOOP_TIMER, BIT_TIMER_4HZ))
|
if (BIT_CHECK(LOOP_TIMER, BIT_TIMER_4HZ))
|
||||||
{
|
{
|
||||||
BIT_CLEAR(TIMER_mask, BIT_TIMER_4HZ);
|
BIT_CLEAR(TIMER_mask, BIT_TIMER_4HZ);
|
||||||
|
//The IAT and CLT readings can be done less frequently (4 times per second)
|
||||||
readCLT();
|
readCLT();
|
||||||
readIAT();
|
readIAT();
|
||||||
readO2();
|
readO2();
|
||||||
|
@ -290,24 +280,28 @@ void loop()
|
||||||
|
|
||||||
if( (configPage6.iacAlgorithm == IAC_ALGORITHM_STEP_OL) || (configPage6.iacAlgorithm == IAC_ALGORITHM_STEP_CL) ) { idleControl(); } //Run idlecontrol every loop for stepper idle.
|
if( (configPage6.iacAlgorithm == IAC_ALGORITHM_STEP_OL) || (configPage6.iacAlgorithm == IAC_ALGORITHM_STEP_CL) ) { idleControl(); } //Run idlecontrol every loop for stepper idle.
|
||||||
|
|
||||||
|
//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();
|
||||||
|
|
||||||
//Always check for sync
|
//Always check for sync
|
||||||
//Main loop runs within this clause
|
//Main loop runs within this clause
|
||||||
if (currentStatus.hasSync && (currentStatus.RPM > 0))
|
if (currentStatus.hasSync && (currentStatus.RPM > 0))
|
||||||
{
|
{
|
||||||
if(currentStatus.startRevolutions >= configPage4.StgCycles) { ignitionOn = true; fuelOn = true; } //Enable the fuel and ignition, assuming staging revolutions are complete
|
if(currentStatus.startRevolutions >= configPage4.StgCycles) { ignitionOn = true; fuelOn = true; } //Enable the fuel and ignition, assuming staging revolutions are complete
|
||||||
//If it is, check is we're running or cranking
|
//Check whether running or cranking
|
||||||
if(currentStatus.RPM > currentStatus.crankRPM) //Crank RPM in the config is stored as a x10. currentStatus.crankRPM is set in timers.ino and represents the true value
|
if(currentStatus.RPM > currentStatus.crankRPM) //Crank RPM in the config is stored as a x10. currentStatus.crankRPM is set in timers.ino and represents the true value
|
||||||
{
|
{
|
||||||
BIT_SET(currentStatus.engine, BIT_ENGINE_RUN); //Sets the engine running bit
|
BIT_SET(currentStatus.engine, BIT_ENGINE_RUN); //Sets the engine running bit
|
||||||
//Only need to do anything if we're transitioning from cranking to running
|
//Only need to do anything if we're transitioning from cranking to running
|
||||||
if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
|
if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
|
||||||
{
|
{
|
||||||
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_CRANK); //clears the engine cranking bit
|
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_CRANK);
|
||||||
if(configPage4.ignBypassEnabled > 0) { digitalWrite(pinIgnBypass, HIGH); }
|
if(configPage4.ignBypassEnabled > 0) { digitalWrite(pinIgnBypass, HIGH); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ //Sets the engine cranking bit, clears the engine running bit
|
{
|
||||||
|
//Sets the engine cranking bit, clears the engine running bit
|
||||||
BIT_SET(currentStatus.engine, BIT_ENGINE_CRANK);
|
BIT_SET(currentStatus.engine, BIT_ENGINE_CRANK);
|
||||||
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_RUN);
|
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_RUN);
|
||||||
currentStatus.runSecs = 0; //We're cranking (hopefully), so reset the engine run time to prompt ASE.
|
currentStatus.runSecs = 0; //We're cranking (hopefully), so reset the engine run time to prompt ASE.
|
||||||
|
@ -320,7 +314,6 @@ void loop()
|
||||||
//Calculate an injector pulsewidth from the VE
|
//Calculate an injector pulsewidth from the VE
|
||||||
currentStatus.corrections = correctionsFuel();
|
currentStatus.corrections = correctionsFuel();
|
||||||
|
|
||||||
currentStatus.VE = getVE();
|
|
||||||
currentStatus.advance = getAdvance();
|
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);
|
||||||
|
|
||||||
|
@ -369,7 +362,7 @@ void loop()
|
||||||
int ignition8StartAngle = 0;
|
int ignition8StartAngle = 0;
|
||||||
#endif
|
#endif
|
||||||
//These are used for comparisons on channels above 1 where the starting angle (for injectors or ignition) can be less than a single loop time
|
//These are used for comparisons on channels above 1 where the starting angle (for injectors or ignition) can be less than a single loop time
|
||||||
//(Don't ask why this is needed, it will break your head)
|
//(Don't ask why this is needed, it's just there)
|
||||||
int tempCrankAngle;
|
int tempCrankAngle;
|
||||||
int tempStartAngle;
|
int tempStartAngle;
|
||||||
|
|
||||||
|
@ -414,7 +407,6 @@ void loop()
|
||||||
else { currentStatus.PW3 = 0; } //If tempPW1 < pwLImit it means that the entire fuel load can be handled by the primaries. Simply set the secondaries to 0
|
else { currentStatus.PW3 = 0; } //If tempPW1 < pwLImit it means that the entire fuel load can be handled by the primaries. Simply set the secondaries to 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//currentStatus.PW3 = 2000;
|
|
||||||
//Set the 2nd channel of each stage with the same pulseWidth
|
//Set the 2nd channel of each stage with the same pulseWidth
|
||||||
currentStatus.PW2 = currentStatus.PW1;
|
currentStatus.PW2 = currentStatus.PW1;
|
||||||
currentStatus.PW4 = currentStatus.PW3;
|
currentStatus.PW4 = currentStatus.PW3;
|
||||||
|
@ -460,12 +452,6 @@ void loop()
|
||||||
break;
|
break;
|
||||||
//2 cylinders
|
//2 cylinders
|
||||||
case 2:
|
case 2:
|
||||||
/*
|
|
||||||
injector2StartAngle = (configPage2.inj2Ang + channel2InjDegrees);
|
|
||||||
if(injector2StartAngle < PWdivTimerPerDegree) { injector2StartAngle += CRANK_ANGLE_MAX_INJ; }
|
|
||||||
injector2StartAngle -= PWdivTimerPerDegree;
|
|
||||||
if(injector2StartAngle > CRANK_ANGLE_MAX_INJ) { injector2StartAngle -= CRANK_ANGLE_MAX_INJ; }
|
|
||||||
*/
|
|
||||||
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
||||||
if( (configPage10.stagingEnabled == true) && (currentStatus.PW3 > 0) )
|
if( (configPage10.stagingEnabled == true) && (currentStatus.PW3 > 0) )
|
||||||
{
|
{
|
||||||
|
@ -479,44 +465,16 @@ void loop()
|
||||||
break;
|
break;
|
||||||
//3 cylinders
|
//3 cylinders
|
||||||
case 3:
|
case 3:
|
||||||
/*
|
|
||||||
injector2StartAngle = (configPage2.inj2Ang + channel2InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector2StartAngle > CRANK_ANGLE_MAX_INJ) {injector2StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
if(injector2StartAngle < 0) {injector2StartAngle += CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
/*
|
|
||||||
injector3StartAngle = (configPage2.inj3Ang + channel3InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector3StartAngle > CRANK_ANGLE_MAX_INJ) {injector3StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
if(injector3StartAngle < 0) {injector3StartAngle += CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
//4 cylinders
|
//4 cylinders
|
||||||
case 4:
|
case 4:
|
||||||
/*
|
|
||||||
injector2StartAngle = (configPage2.inj2Ang + channel2InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector2StartAngle > CRANK_ANGLE_MAX_INJ) {injector2StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
if(injector2StartAngle < 0) {injector2StartAngle += CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
if(configPage2.injLayout == INJ_SEQUENTIAL)
|
if(configPage2.injLayout == INJ_SEQUENTIAL)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
injector3StartAngle = (configPage2.inj3Ang + channel3InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector3StartAngle > CRANK_ANGLE_MAX_INJ) {injector3StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
if(injector3StartAngle < 0) {injector3StartAngle += CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
/*
|
|
||||||
injector4StartAngle = (configPage2.inj4Ang + channel4InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector4StartAngle > CRANK_ANGLE_MAX_INJ) {injector4StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
if(injector4StartAngle < 0) {injector4StartAngle += CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector4StartAngle = calculateInjector4StartAngle(PWdivTimerPerDegree);
|
injector4StartAngle = calculateInjector4StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
if(configPage6.fuelTrimEnabled > 0)
|
if(configPage6.fuelTrimEnabled > 0)
|
||||||
|
@ -544,42 +502,14 @@ void loop()
|
||||||
break;
|
break;
|
||||||
//5 cylinders
|
//5 cylinders
|
||||||
case 5:
|
case 5:
|
||||||
/*
|
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree); //Note the shared timing with INJ2
|
||||||
injector2StartAngle = (configPage2.inj2Ang + channel2InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector2StartAngle > CRANK_ANGLE_MAX_INJ) {injector2StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
|
||||||
|
|
||||||
/*
|
|
||||||
injector3StartAngle = (configPage2.inj3Ang + channel3InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector3StartAngle > CRANK_ANGLE_MAX_INJ) {injector3StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
/*
|
|
||||||
injector4StartAngle = (configPage2.inj4Ang + channel4InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector4StartAngle > CRANK_ANGLE_MAX_INJ) {injector4StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector4StartAngle = calculateInjector4StartAngle(PWdivTimerPerDegree);
|
injector4StartAngle = calculateInjector4StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
/*
|
|
||||||
injector5StartAngle = (configPage2.inj1Ang + channel5InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector5StartAngle > CRANK_ANGLE_MAX_INJ) {injector5StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector5StartAngle = calculateInjector5StartAngle(PWdivTimerPerDegree);
|
injector5StartAngle = calculateInjector5StartAngle(PWdivTimerPerDegree);
|
||||||
break;
|
break;
|
||||||
//6 cylinders
|
//6 cylinders
|
||||||
case 6:
|
case 6:
|
||||||
/*
|
|
||||||
injector2StartAngle = (configPage2.inj2Ang + channel2InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector2StartAngle > CRANK_ANGLE_MAX_INJ) {injector2StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
/*
|
|
||||||
injector3StartAngle = (configPage2.inj3Ang + channel3InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector3StartAngle > CRANK_ANGLE_MAX_INJ) {injector3StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
||||||
#if INJ_CHANNELS >= 6
|
#if INJ_CHANNELS >= 6
|
||||||
if(configPage2.injLayout == INJ_SEQUENTIAL)
|
if(configPage2.injLayout == INJ_SEQUENTIAL)
|
||||||
|
@ -595,22 +525,8 @@ void loop()
|
||||||
break;
|
break;
|
||||||
//8 cylinders
|
//8 cylinders
|
||||||
case 8:
|
case 8:
|
||||||
/*
|
|
||||||
injector2StartAngle = (configPage2.inj2Ang + channel2InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector2StartAngle > CRANK_ANGLE_MAX_INJ) {injector2StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
injector2StartAngle = calculateInjector2StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
/*
|
|
||||||
injector3StartAngle = (configPage2.inj3Ang + channel3InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector3StartAngle > CRANK_ANGLE_MAX_INJ) {injector3StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
injector3StartAngle = calculateInjector3StartAngle(PWdivTimerPerDegree);
|
||||||
|
|
||||||
/*
|
|
||||||
injector4StartAngle = (configPage2.inj4Ang + channel4InjDegrees - ( PWdivTimerPerDegree ));
|
|
||||||
if(injector4StartAngle > CRANK_ANGLE_MAX_INJ) {injector4StartAngle -= CRANK_ANGLE_MAX_INJ;}
|
|
||||||
*/
|
|
||||||
injector4StartAngle = calculateInjector4StartAngle(PWdivTimerPerDegree);
|
injector4StartAngle = calculateInjector4StartAngle(PWdivTimerPerDegree);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -771,7 +687,7 @@ void loop()
|
||||||
|
|
||||||
//Determine the current crank angle
|
//Determine the current crank angle
|
||||||
int crankAngle = getCrankAngle();
|
int crankAngle = getCrankAngle();
|
||||||
if (crankAngle > CRANK_ANGLE_MAX_INJ ) { crankAngle -= CRANK_ANGLE_MAX_INJ; }
|
while(crankAngle > CRANK_ANGLE_MAX_INJ ) { crankAngle = crankAngle - CRANK_ANGLE_MAX_INJ; } //Continue reducing the crank angle by the max injection amount until it's below the required limit. This will usually only run (at most) once, but in cases where there is sequential ignition and more than 2 squirts per cycle, it may run up to 4 times.
|
||||||
|
|
||||||
if(Serial && false)
|
if(Serial && false)
|
||||||
{
|
{
|
||||||
|
@ -952,7 +868,7 @@ void loop()
|
||||||
}
|
}
|
||||||
//***********************************************************************************************
|
//***********************************************************************************************
|
||||||
//| BEGIN IGNITION SCHEDULES
|
//| BEGIN IGNITION SCHEDULES
|
||||||
//Likewise for the ignition
|
//Same as above, except for ignition
|
||||||
|
|
||||||
//fixedCrankingOverride is used to extend the dwell during cranking so that the decoder can trigger the spark upon seeing a certain tooth. Currently only available on the basic distributor and 4g63 decoders.
|
//fixedCrankingOverride is used to extend the dwell during cranking so that the decoder can trigger the spark upon seeing a certain tooth. Currently only available on the basic distributor and 4g63 decoders.
|
||||||
if ( configPage4.ignCranklock && BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) && (decoderHasFixedCrankingTiming == true) )
|
if ( configPage4.ignCranklock && BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) && (decoderHasFixedCrankingTiming == true) )
|
||||||
|
@ -1009,13 +925,6 @@ void loop()
|
||||||
#if IGN_CHANNELS >= 1
|
#if IGN_CHANNELS >= 1
|
||||||
if ( (ignition1StartAngle > crankAngle) && (curRollingCut != 1) )
|
if ( (ignition1StartAngle > crankAngle) && (curRollingCut != 1) )
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
long some_time = ((unsigned long)(ignition1StartAngle - crankAngle) * (unsigned long)timePerDegree);
|
|
||||||
long newRPM = (long)(some_time * currentStatus.rpmDOT) / 1000000L;
|
|
||||||
newRPM = currentStatus.RPM + (newRPM/2);
|
|
||||||
unsigned long timePerDegree_1 = ldiv( 166666L, newRPM).quot;
|
|
||||||
unsigned long timeout = (unsigned long)(ignition1StartAngle - crankAngle) * 282UL;
|
|
||||||
*/
|
|
||||||
if(ignitionSchedule1.Status != RUNNING)
|
if(ignitionSchedule1.Status != RUNNING)
|
||||||
{
|
{
|
||||||
setIgnitionSchedule1(ign1StartFunction,
|
setIgnitionSchedule1(ign1StartFunction,
|
||||||
|
@ -1055,6 +964,7 @@ void loop()
|
||||||
if( tempCrankAngle < 0) { tempCrankAngle += CRANK_ANGLE_MAX_IGN; }
|
if( tempCrankAngle < 0) { tempCrankAngle += CRANK_ANGLE_MAX_IGN; }
|
||||||
tempStartAngle = ignition2StartAngle - channel2IgnDegrees;
|
tempStartAngle = ignition2StartAngle - channel2IgnDegrees;
|
||||||
if ( tempStartAngle < 0) { tempStartAngle += CRANK_ANGLE_MAX_IGN; }
|
if ( tempStartAngle < 0) { tempStartAngle += CRANK_ANGLE_MAX_IGN; }
|
||||||
|
//if (tempStartAngle > tempCrankAngle)
|
||||||
{
|
{
|
||||||
unsigned long ignition2StartTime = 0;
|
unsigned long ignition2StartTime = 0;
|
||||||
if(tempStartAngle > tempCrankAngle) { ignition2StartTime = angleToTime((tempStartAngle - tempCrankAngle), CRANKMATH_METHOD_INTERVAL_REV); }
|
if(tempStartAngle > tempCrankAngle) { ignition2StartTime = angleToTime((tempStartAngle - tempCrankAngle), CRANKMATH_METHOD_INTERVAL_REV); }
|
||||||
|
|
Loading…
Reference in New Issue