Continued work on spark output modes

This commit is contained in:
Josh Stewart 2015-10-29 06:13:13 +11:00
parent 54bb6e9835
commit 8975698cdf
3 changed files with 81 additions and 1 deletions

View File

@ -219,7 +219,8 @@ struct config2 {
byte dwellCont : 1; //Fixed duty dwell control
byte useDwellLim : 1; //Whether the dwell limiter is off or on
byte dwellUnused : 6;
byte sparkMode : 2; //Spark output mode (Eg Wasted spark, single channel or Wasted COP)
byte dwellUnused : 4;
byte dwellCrank; //Dwell time whilst cranking
byte dwellRun; //Dwell time whilst running

View File

@ -217,6 +217,7 @@ page = 4
;running dwell variable railed to 8 - who needs more than 8ms?
dwellcont = bits, U08, 12, [0:0], "INVALID", "Dwell control"
useDwellLim= bits, U08, 12, [1:1], "Off", "On"
sparkMode = bits, U08, 12, [2:3], "Wasted Spark", "Single Channel", "Wasted COP", "INVALID"
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
@ -409,9 +410,11 @@ page = 8
requiresPowerCycle = boostFreq
requiresPowerCycle = vvtFreq
requiresPowerCycle = idleFreq
requiresPowerCycle = sparkMode
defaultValue = pinLayout, 1
defaultValue = TrigPattern, 0
defaultValue = sparkMode, 0
defaultValue = inj1Ang, 355
defaultValue = inj2Ang, 355
defaultValue = inj3Ang, 355
@ -538,6 +541,8 @@ page = 8
StgCycles = "The number of revolutions that will be skipped during cranking before the injectors and coils are fired."
TrigEdge = "The Trigger edge of the primary sensor.\nLeading.\nTrailing."
sparkMode = "Wasted Spark: Ignition outputs are on the channels <= half the number of cylinders. Eg 4 cylinder outputs on IGN1 and IGN2.\nSingle Channel: All ignition pulses are output on IGN1.\nWasted COP: Ignition pulses are output on all ignition channels up to the number of cylinders. Eg 4 cylinder outputs on all ignition channels. No valid for >4 cylinders"
iacStepTime = "Time between each stepper motor step.\nIncrease this if the motor appears to behave intermittently."
iacStepHome = "On startup the stepper motor moves this many steps to return to its home position. Set this value to a few more than the actual number to ensure the motor has returned to its full position."
iacStepHyster = "The minimum number of steps to move in any one go."
@ -685,6 +690,7 @@ page = 8
field = "Trigger edge", TrigEdge
dialog = sparkSettings,"Spark Settings",4
field = "Spark output mode", sparkMode
field = "Cranking advance Angle", CrankAng
;field = "Hold Ignition", IgHold
field = "Spark Outputs triggers", IgInv

View File

@ -107,6 +107,17 @@ int channel1InjDegrees; //The number of crank degrees until cylinder 1 is at TDC
int channel2InjDegrees; //The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC
int channel3InjDegrees; //The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC
int channel4InjDegrees; //The number of crank degrees until cylinder 4 (and 5/6/7/8) is at TDC
//These are the functions the get called to begin and end the ignition coil charging. They are required for the various spark output modes
void (*ign1StartFunction)();
void (*ign1EndFunction)();
void (*ign2StartFunction)();
void (*ign2EndFunction)();
void (*ign3StartFunction)();
void (*ign3EndFunction)();
void (*ign4StartFunction)();
void (*ign4EndFunction)();
int timePerDegree;
byte degreesPerLoop; //The number of crank degrees that pass for each mainloop of the program
@ -445,6 +456,62 @@ void setup()
break;
}
switch(configPage2.sparkMode)
{
case 0:
//Wasted Spark (Normal mode)
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
ign3StartFunction = beginCoil3Charge;
ign3EndFunction = endCoil3Charge;
ign4StartFunction = beginCoil4Charge;
ign4EndFunction = endCoil4Charge;
break;
case 1:
//Single channel mode. All ignition pulses are on channel 1
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil1Charge;
ign2EndFunction = endCoil1Charge;
ign3StartFunction = beginCoil1Charge;
ign3EndFunction = endCoil1Charge;
ign4StartFunction = beginCoil1Charge;
ign4EndFunction = endCoil1Charge;
break;
case 2:
//Wasted COP mode. Ignition channels 1&3 and 2&4 are paired together
//This is not a valid mode for >4 cylinders
if( configPage1.nCylinders <= 4 )
{
ign1StartFunction = beginCoil1and3Charge;
ign1StartFunction = endCoil1and3Charge;
ign2StartFunction = beginCoil2and4Charge;
ign2StartFunction = endCoil2and4Charge;
}
else
{
//If the person has inadvertantly selected this when running more than 4 cylinders, just use standard Wasted spark mode
ign1StartFunction = beginCoil1Charge;
ign1EndFunction = endCoil1Charge;
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
ign3StartFunction = beginCoil3Charge;
ign3EndFunction = endCoil3Charge;
ign4StartFunction = beginCoil4Charge;
ign4EndFunction = endCoil4Charge;
}
break;
default:
ign2StartFunction = beginCoil2Charge;
ign2EndFunction = endCoil2Charge;
break;
}
//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
setFuelSchedule1(openInjector1and4, 100, (unsigned long)(configPage1.primePulse * 100), closeInjector1and4);
setFuelSchedule2(openInjector2and3, 100, (unsigned long)(configPage1.primePulse * 100), closeInjector2and3);
@ -954,5 +1021,11 @@ void openInjector1and4() { digitalWrite(pinInjector1, HIGH); digitalWrite(pinInj
void closeInjector1and4() { digitalWrite(pinInjector1, LOW); digitalWrite(pinInjector4, LOW);BIT_CLEAR(currentStatus.squirt, 0); }
void openInjector2and3() { digitalWrite(pinInjector2, HIGH); digitalWrite(pinInjector3, HIGH); BIT_SET(currentStatus.squirt, 1); }
void closeInjector2and3() { digitalWrite(pinInjector2, LOW); digitalWrite(pinInjector3, LOW); BIT_CLEAR(currentStatus.squirt, 1); }
//As above but for ignition (Wasted COP mode)
void beginCoil1and3Charge() { digitalWrite(pinCoil1, coilHIGH); digitalWrite(pinCoil3, coilHIGH); BIT_SET(currentStatus.spark, 0); BIT_SET(currentStatus.spark, 2); digitalWrite(pinTachOut, LOW); }
void endCoil1and3Charge() { digitalWrite(pinCoil1, coilLOW); digitalWrite(pinCoil3, coilLOW); BIT_CLEAR(currentStatus.spark, 0); BIT_CLEAR(currentStatus.spark, 2); }
void beginCoil2and4Charge() { digitalWrite(pinCoil2, coilHIGH); digitalWrite(pinCoil4, coilHIGH); BIT_SET(currentStatus.spark, 1); BIT_SET(currentStatus.spark, 3); digitalWrite(pinTachOut, LOW); }
void endCoil2and4Charge() { digitalWrite(pinCoil2, coilLOW); digitalWrite(pinCoil4, coilLOW); BIT_CLEAR(currentStatus.spark, 1); BIT_CLEAR(currentStatus.spark, 3); }