Additional modular decoder work

This commit is contained in:
Josh Stewart 2015-05-18 22:46:22 +10:00
parent a6eed4a18f
commit 13c61026cb
4 changed files with 60 additions and 26 deletions

View File

@ -9,6 +9,7 @@ Each decoder must have the following 4 functions (Where xxxx is the decoder name
* getCrankAngle_xxxx - Returns the current crank angle, as calculated b the decoder
And each decoder must utlise at least the following variables:
toothLastToothTime - The time (In uS) that the last primary tooth was 'seen'
*
*/
@ -58,3 +59,23 @@ void triggerPri_missingTooth()
}
void triggerSec_missingTooth(){ return; } //This function currently is not used
int getRPM_missingTooth()
{
}
int getCrankAngle_missingTooth()
{
}
/*
Name: Missing tooth wheel
Desc: A multi-tooth wheel with one of more 'missing' teeth. The first tooth after the missing one is considered number 1 and isthe basis for the trigger angle
Note: This does not currently support dual wheel (ie missing tooth + single tooth on cam)
*/
void triggerPri_DualWheel()
{
return;
}

View File

@ -169,10 +169,11 @@ struct config2 {
byte CrankAng;
byte IgHold;
byte Trig_plus : 2;
byte TrigCrank : 1;
byte TrigEdge : 1;
byte TrigSpeed : 1;
byte IgInv : 1;
byte oddfire : 4;
byte oddfire : 1;
byte TrigPattern : 4;
byte IdleAdv;
byte IdleAdvTPS;

View File

@ -173,10 +173,11 @@ page = 2
FixAng = scalar, U08, 82, "Deg", 1, 0, 0, 80, 0
CrankAng = scalar, U08, 83, "Deg", 1, -28.4, -10, 80, 0
IgHold = scalar, U08, 84, "", 1, 0, 0, 100, 0
Trig_plus = bits, U08, 85[0:1], "0", "+22.5", "INVALID", "+45"
TrigCrank = bits, U08, 85[2:2], "Trigger Return", "Time Based"
IgInv = bits, U08, 85[3:3], "No", "Yes"
oddfire = bits, U08, 85[4:4], "No", "Yes"
TrigEdge = bits, U08, 85[0:0], "Leading", "Trailing"
TrigSpeed = bits, U08, 85[1:1], "Crank Speed", "Cam Speed"
IgInv = bits, U08, 85[2:2], "No", "Yes"
oddfire = bits, U08, 85[3:3], "No", "Yes"
TrigPattern= bits, U08, 85[4:7], "Missing Tooth", "Dual Wheel", "HEI", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
IdleAdv = scalar, U08, 86, "Deg", 0.352,-28.4, -10, 80, 0
IdleAdvTPS = scalar, U08, 87, "ADC", 1, 0, 0, 255, 0
IdleAdvRPM = scalar, U08, 88, "RPM", 100, 0, 0, 1200, 0
@ -270,6 +271,7 @@ page = 3
requiresPowerCycle = IgInv
defaultValue = pinLayout, 1
defaultValue = TrigPattern, 0
[Menu]
@ -455,27 +457,22 @@ page = 3
dialog = triggerSettings,"Trigger Settings",3
topicHelp = Shelp3
field = "Wheel decoder base teeth", numteeth
field = "Missing teeth", onetwo
field = "Trigger Angle ", TrigAng
field = "This number represents the angle ATDC when the 1st"
field = "tooth after the gap passes the sensor."
field = "Trigger Pattern", TrigPattern
field = "Primary base teeth", numteeth
field = "Primary trigger speed", TrigSpeed
field = "Missing teeth", onetwo, { TrigPattern == 0 }
field = "Secondary teeth", onetwo, { TrigPattern == 1 }
field = "Trigger Angle ", TrigAng
field = "This number represents the angle ATDC when "
field = "tooth #1 passes the primary sensor."
field = ""
field = "Skip Revolutions", StgCycles
field = "Note: This is the number of revolutions that will be skipped during"
field = "cranking before the injectors and coils are fired"
field = "Trigger edge", TrigEdge
dialog = sparkSettings,"Spark Settings",3
topicHelp = Shelp3
field = "Wheel decoder base teeth", numteeth
field = "Missing teeth", onetwo
field = "Trigger Angle"
field = "Trigger Angle ", TrigAng
field = "Note: This number will be rounded to the nearest 4 degrees"
field = "This number represents the angle ATDC when the 1st"
field = "tooth after the gap passes the sensor."
field = ""
;field = "Cranking Timing", TrigCrank
field = "Cranking advance Angle", CrankAng
;field = "Hold Ignition", IgHold
field = "Spark Output Inverted (see F1)", IgInv

View File

@ -142,9 +142,6 @@ void setup()
triggerActualTeeth = configPage2.triggerTeeth - configPage2.triggerMissingTeeth; //The number of physical teeth on the wheel. Doing this here saves us a calculation each time in the interrupt
inj_opentime_uS = configPage1.injOpen * 100; //Injector open time. Comes through as ms*10 (Eg 15.5ms = 155).
//Set the trigger function based on the decoder in the config
trigger = triggerPri_missingTooth;
//Begin the main crank trigger interrupt pin setup
//The interrupt numbering is a bit odd - See here for reference: http://arduino.cc/en/Reference/AttachInterrupt
//These assignments are based on the Arduino Mega AND VARY BETWEEN BOARDS. Please confirm the board you are using and update acordingly.
@ -174,7 +171,25 @@ void setup()
}
pinMode(pinTrigger, INPUT);
//digitalWrite(pinTrigger, HIGH);
attachInterrupt(triggerInterrupt, trigger, FALLING); // Attach the crank trigger wheel interrupt (Hall sensor drags to ground when triggering)
if(configPage2.TrigEdge == 0)
{ attachInterrupt(triggerInterrupt, trigger, RISING); } // Attach the crank trigger wheel interrupt (Hall sensor drags to ground when triggering)
else { attachInterrupt(triggerInterrupt, trigger, FALLING); }
//Set the trigger function based on the decoder in the config
switch (configPage2.TrigPattern)
{
case 0:
trigger = triggerPri_missingTooth;
break;
case 1:
trigger = triggerPri_DualWheel;
break;
case 2:
trigger = triggerPri_missingTooth;
break;
}
//End crank triger interrupt attachment
req_fuel_uS = req_fuel_uS / engineSquirtsPerCycle; //The req_fuel calculation above gives the total required fuel (At VE 100%) in the full cycle. If we're doing more than 1 squirt per cycle then we need to split the amount accordingly. (Note that in a non-sequential 4-stroke setup you cannot have less than 2 squirts as you cannot determine the stroke to make the single squirt on)