DRZ400 Trigger Decoder (#625)
* DRZ400 Create the DRZ400 decoder based on duel wheel. Works by creating a filter on the secondary filter so it only detects one of the two teeth enabling single tooth decoder to work * fix missing commas to speeduino.ini
This commit is contained in:
parent
89e49d2c00
commit
d8474462d8
|
@ -146,6 +146,7 @@
|
|||
#define trigger_420a = 18
|
||||
#define trigger_Webber = 19
|
||||
#define trigger_FordST170 = 20
|
||||
#define trigger_DRZ400 = 21
|
||||
|
||||
[Constants]
|
||||
|
||||
|
@ -451,7 +452,7 @@ page = 4
|
|||
TrigEdge = bits, U08, 5,[0:0], "RISING", "FALLING"
|
||||
TrigSpeed = bits, U08, 5,[1:1], "Crank Speed", "Cam Speed"
|
||||
IgInv = bits, U08, 5,[2:2], "Going Low", "Going High"
|
||||
TrigPattern= bits, U08, 5,[3:7], "Missing Tooth", "Basic Distributor", "Dual Wheel", "GM 7X", "4G63 / Miata / 3000GT", "GM 24X", "Jeep 2000", "Audi 135", "Honda D17", "Miata 99-05", "Mazda AU", "Non-360 Dual", "Nissan 360", "Subaru 6/7", "Daihatsu +1", "Harley EVO", "36-2-2-2", "36-2-1", "DSM 420a", "Weber-Marelli", "Ford ST170", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
TrigPattern= bits, U08, 5,[3:7], "Missing Tooth", "Basic Distributor", "Dual Wheel", "GM 7X", "4G63 / Miata / 3000GT", "GM 24X", "Jeep 2000", "Audi 135", "Honda D17", "Miata 99-05", "Mazda AU", "Non-360 Dual", "Nissan 360", "Subaru 6/7", "Daihatsu +1", "Harley EVO", "36-2-2-2", "36-2-1", "DSM 420a", "Weber-Marelli", "Ford ST170", "DRZ400", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
TrigEdgeSec= bits, U08, 6,[0:0], "RISING", "FALLING"
|
||||
fuelPumpPin= bits , U08, 6,[1:6], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "INVALID", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID"
|
||||
useResync = bits, U08, 6,[7:7], "No", "Yes"
|
||||
|
@ -2522,7 +2523,7 @@ menuDialog = main
|
|||
dialog = triggerSettings,"Trigger Settings",4
|
||||
topicHelp = "https://wiki.speeduino.com/en/decoders"
|
||||
field = "Trigger Pattern", TrigPattern
|
||||
field = "Primary base teeth", numTeeth, { TrigPattern == 0 || TrigPattern == 2 || TrigPattern == 11 || TrigPattern == 18 || TrigPattern == 19 }
|
||||
field = "Primary base teeth", numTeeth, { TrigPattern == 0 || TrigPattern == 2 || TrigPattern == 11 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 21 }
|
||||
field = "Primary trigger speed", TrigSpeed, { TrigPattern == 0 }
|
||||
field = "Missing teeth", missingTeeth, { TrigPattern == 0 }
|
||||
field = "Trigger angle multiplier", TrigAngMul, { TrigPattern == 11 }
|
||||
|
@ -2534,11 +2535,11 @@ menuDialog = main
|
|||
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 { TrigPattern != 4 } ;4G63 uses both edges
|
||||
field = "Secondary trigger edge", TrigEdgeSec, { (TrigPattern == 0 && TrigSpeed == 0 && trigPatternSec != 2) || TrigPattern == 2 || TrigPattern == 9 || TrigPattern == 12 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 20 } ;Missing tooth, dual wheel and Miata 9905, weber-marelli, ST170
|
||||
field = "Missing Tooth Secondary type", trigPatternSec, { (TrigPattern == 0&& TrigSpeed == 0) }
|
||||
field = "Level for 1st phase", PollLevelPol, { (TrigPattern == 0 && TrigSpeed == 0 && trigPatternSec == 2) }
|
||||
field = "Secondary trigger edge", TrigEdgeSec, { (TrigPattern == 0 && TrigSpeed == 0 && trigPatternSec != 2) || TrigPattern == 2 || TrigPattern == 9 || TrigPattern == 12 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 20 || TrigPattern == 21 } ;Missing tooth, dual wheel and Miata 9905, weber-marelli, ST170, DRZ400
|
||||
field = "Missing Tooth Secondary type", trigPatternSec, { (TrigPattern == 0&& TrigSpeed == 0) }
|
||||
field = "Level for 1st phase", PollLevelPol, { (TrigPattern == 0 && TrigSpeed == 0 && trigPatternSec == 2) }
|
||||
field = "Trigger Filter", TrigFilter, { TrigPattern != 13 }
|
||||
field = "Re-sync every cycle", useResync, { TrigPattern == 2 || TrigPattern == 4 || TrigPattern == 7 || TrigPattern == 12 || TrigPattern == 9 || TrigPattern == 13 || TrigPattern == 18 || TrigPattern == 19 } ;Dual wheel, 4G63, Audi 135, Nissan 360, Miata 99-05, weber-marelli
|
||||
field = "Re-sync every cycle", useResync, { TrigPattern == 2 || TrigPattern == 4 || TrigPattern == 7 || TrigPattern == 12 || TrigPattern == 9 || TrigPattern == 13 || TrigPattern == 18 || TrigPattern == 19 || TrigPattern == 21 } ;Dual wheel, 4G63, Audi 135, Nissan 360, Miata 99-05, weber-marelli. DRZ400
|
||||
|
||||
dialog = lockSparkSettings, "Locked timing"
|
||||
field = "Enabled Fixed/Locked timing", fixAngEnable
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#define DECODER_420A 18
|
||||
#define DECODER_WEBER 19
|
||||
#define DECODER_ST170 20
|
||||
#define DECODER_DRZ400 21
|
||||
|
||||
//This isn't to to filter out wrong pulses on triggers, but just to smooth out the cam angle reading for better closed loop VVT control.
|
||||
#define ANGLE_FILTER(input, alpha, prior) (((long)input * (256 - alpha) + ((long)prior * alpha))) >> 8
|
||||
|
@ -184,6 +185,9 @@ uint16_t getRPM_FordST170();
|
|||
int getCrankAngle_FordST170();
|
||||
void triggerSetEndTeeth_FordST170();
|
||||
|
||||
void triggerSetup_DRZ400();
|
||||
void triggerSec_DRZ400();
|
||||
|
||||
|
||||
extern void (*triggerHandler)(); //Pointer for the trigger function (Gets pointed to the relevant decoder)
|
||||
extern void (*triggerSecondaryHandler)(); //Pointer for the secondary trigger function (Gets pointed to the relevant decoder)
|
||||
|
|
|
@ -4129,3 +4129,42 @@ void triggerSetEndTeeth_FordST170()
|
|||
}
|
||||
/** @} */
|
||||
|
||||
|
||||
void triggerSetup_DRZ400()
|
||||
{
|
||||
triggerToothAngle = 360 / configPage4.triggerTeeth; //The number of degrees that passes from tooth to tooth
|
||||
if(configPage4.TrigSpeed == 1) { triggerToothAngle = 720 / configPage4.triggerTeeth; } //Account for cam speed
|
||||
toothCurrentCount = 255; //Default value
|
||||
triggerFilterTime = (1000000 / (MAX_RPM / 60 * configPage4.triggerTeeth)); //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise
|
||||
triggerSecFilterTime = (1000000 / (MAX_RPM / 60 * 2)); //Same as above, but fixed at 2 teeth on the secondary input
|
||||
secondDerivEnabled = false;
|
||||
decoderIsSequential = true;
|
||||
triggerToothAngleIsCorrect = true; //This is always true for this pattern
|
||||
MAX_STALL_TIME = (3333UL * triggerToothAngle); //Minimum 50rpm. (3333uS is the time per degree at 50rpm)
|
||||
}
|
||||
|
||||
void triggerSec_DRZ400()
|
||||
{
|
||||
curTime2 = micros();
|
||||
curGap2 = curTime2 - toothLastSecToothTime;
|
||||
if ( curGap2 >= triggerSecFilterTime )
|
||||
{
|
||||
toothLastSecToothTime = curTime2;
|
||||
|
||||
if(currentStatus.hasSync == false)
|
||||
{
|
||||
toothLastToothTime = micros();
|
||||
toothLastMinusOneToothTime = micros() - (6000000 / configPage4.triggerTeeth); //Fixes RPM at 10rpm until a full revolution has taken place
|
||||
toothCurrentCount = configPage4.triggerTeeth;
|
||||
currentStatus.syncLossCounter++;
|
||||
currentStatus.hasSync = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// have rotation, set tooth to six so next tooth is 1 & duel wheel rotation code kicks in
|
||||
toothCurrentCount = 6;
|
||||
}
|
||||
}
|
||||
|
||||
triggerSecFilterTime = (toothOneTime - toothOneMinusOneTime) >> 1; //Set filter at 50% of the current crank speed.
|
||||
}
|
||||
|
|
|
@ -3215,6 +3215,27 @@ void initialiseTriggers()
|
|||
|
||||
break;
|
||||
|
||||
case DECODER_DRZ400:
|
||||
triggerSetup_DRZ400();
|
||||
triggerHandler = triggerPri_DualWheel;
|
||||
triggerSecondaryHandler = triggerSec_DRZ400;
|
||||
decoderHasSecondary = true;
|
||||
getRPM = getRPM_DualWheel;
|
||||
getCrankAngle = getCrankAngle_DualWheel;
|
||||
triggerSetEndTeeth = triggerSetEndTeeth_DualWheel;
|
||||
|
||||
if(configPage4.TrigEdge == 0) { primaryTriggerEdge = RISING; } // Attach the crank trigger wheel interrupt (Hall sensor drags to ground when triggering)
|
||||
else { primaryTriggerEdge = FALLING; }
|
||||
if(configPage4.TrigEdgeSec == 0) { secondaryTriggerEdge = RISING; }
|
||||
else { secondaryTriggerEdge = FALLING; }
|
||||
|
||||
attachInterrupt(triggerInterrupt, triggerHandler, primaryTriggerEdge);
|
||||
attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
triggerHandler = triggerPri_missingTooth;
|
||||
getRPM = getRPM_missingTooth;
|
||||
|
|
Loading…
Reference in New Issue