Trigger based locked timing for Basic Distributor and 4G63 decoders

This commit is contained in:
Josh Stewart 2016-05-29 19:41:31 +10:00
parent 7b9ef56e07
commit 017501878e
5 changed files with 19 additions and 7 deletions

View File

@ -34,7 +34,7 @@ void initialiseAuxPWM()
vvt_pin_port = portOutputRegister(digitalPinToPort(pinVVT_1));
vvt_pin_mask = digitalPinToBitMask(pinVVT_1);
boost_pwm_max_count = 1000000L / (16 * configPage3.boostFreq * 2); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle. The x2 is there because the frequency is stored at half value (in a byte)
boost_pwm_max_count = 1000000L / (16 * configPage3.boostFreq * 2); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle. The x2 is there because the frequency is stored at half value (in a byte) to allow freqneucies up to 511Hz
vvt_pwm_max_count = 1000000L / (16 * configPage3.vvtFreq * 2); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle
//TIMSK1 |= (1 << OCIE1A); //Turn on the A compare unit (ie turn on the interrupt) //Shouldn't be needed with closed loop as its turned on below
TIMSK1 |= (1 << OCIE1B); //Turn on the B compare unit (ie turn on the interrupt)

View File

@ -288,8 +288,15 @@ void triggerPri_BasicDistributor()
}
setFilter(curGap); //Recalc the new filter value
addToothLogEntry(curGap);
if ( configPage2.ignCranklock && BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
{
endCoil1Charge();
endCoil2Charge();
endCoil3Charge();
endCoil4Charge();
}
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
@ -460,7 +467,7 @@ void triggerPri_4G63()
}
else if (!currentStatus.hasSync) { return; }
if ( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
if ( configPage2.ignCranklock && BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
{
if( toothCurrentCount == 1 ) { endCoil1Charge(); }
else if( toothCurrentCount == 3 ) { endCoil2Charge(); }

View File

@ -252,7 +252,7 @@ struct config2 {
byte sparkMode : 2; //Spark output mode (Eg Wasted spark, single channel or Wasted COP)
byte dfcoEnabled : 1; //Whether or not DFCO is turned on
byte triggerFilter : 2; //The mode of trigger filter being used (0=Off, 1=Light (Not currently used), 2=Normal, 3=Aggressive)
byte dwellUnused : 1;
byte ignCranklock : 1; //Whether or not the ignition timing during cranking is locked to a CAS pulse. Only currently valid for Basic distributor and 4G63.
byte dwellCrank; //Dwell time whilst cranking
byte dwellRun; //Dwell time whilst running

View File

@ -236,6 +236,7 @@ page = 4
sparkMode = bits, U08, 12, [2:3], "Wasted Spark", "Single Channel", "Wasted COP", "Sequential"
dfcoEnabled= bits, U08, 12, [4:4], "Off", "On"
TrigFilter = bits, U08, 12, [5:6], "Off", "Weak", "Medium", "Aggressive"
ignCranklock=bits, U08, 12, [7:7], "Off", "On"
dwellcrank = scalar, U08, 13, "ms", 0.1, 0, 0, 25, 1
dwellrun = scalar, U08, 14, "ms", 0.1, 0, 0, 8, 1
numteeth = scalar, U08, 15, "teeth", 1.0, 0.0, 0.0, 255, 0
@ -465,6 +466,7 @@ page = 8
defaultValue = mapMax, 260
defaultValue = fpPrime, 3
defaultValue = TrigFilter, 0
defaultValue = ignCranklock, 0
[Menu]
@ -606,6 +608,7 @@ page = 8
launchPin = "The ARDUINO pin that the clutch switch is connected to. This is NOT the pin on the connector, but the pin it relates to on the arduino"
ignBypassPin = "The ARDUINO pin that the ignition bypass is connected to. This is NOT the pin on the connector, but the pin it relates to on the arduino"
ignBypassEnable = "If turned on, a ground signal will be output during cranking on the specified pin. This is used to bypass the Speeduino ignition control during cranking."
ignCranklock = "On certain low resolution ignition patterns, the cranking timing can be locked to occur when a pulse is recieved."
[UserDefinedTS]
@ -732,6 +735,7 @@ page = 8
field = ""
field = "Cranking bypass", ignBypassEnable
field = "Bypass output pin", ignBypassPin { ignBypassEnable }
field = "Fix cranking timing with trigger", ignCranklock, { TrigPattern == 1 || TrigPattern == 4 }
dialog = aseSettings, "Afterstart Enrichment"
field = "Enrichment %", asePct

View File

@ -1056,7 +1056,8 @@ void loop()
//crankAngle = getCrankAngle(timePerDegree); //Refresh with the latest crank angle
//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 ( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) ) { fixedCrankingOverride = currentStatus.dwell; }
if ( configPage2.ignCranklock && BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK)) { fixedCrankingOverride = currentStatus.dwell; }
else { fixedCrankingOverride = 0; }
if(ignitionOn && !currentStatus.launchingHard && !BIT_CHECK(currentStatus.spark, BIT_SPARK_BOOSTCUT) && !BIT_CHECK(currentStatus.spark, BIT_SPARK_HRDLIM))
{
@ -1113,7 +1114,7 @@ void loop()
if(ignition3StartTime > 0) {
setIgnitionSchedule3(ign3StartFunction,
ignition3StartTime,
currentStatus.dwell,
currentStatus.dwell + fixedCrankingOverride,
ign3EndFunction
);
}
@ -1134,7 +1135,7 @@ void loop()
if(ignition4StartTime > 0) {
setIgnitionSchedule4(ign4StartFunction,
ignition4StartTime,
currentStatus.dwell,
currentStatus.dwell + fixedCrankingOverride,
ign4EndFunction
);
}