diff --git a/speeduino/decoders.h b/speeduino/decoders.h index 2823baef..b233a64d 100644 --- a/speeduino/decoders.h +++ b/speeduino/decoders.h @@ -11,6 +11,27 @@ #define READ_SEC_TRIGGER() digitalRead(pinTrigger2) #endif +#define DECODER_MISSING_TOOTH 0 +#define DECODER_BASIC_DISTRIBUTOR 1 +#define DECODER_DUAL_WHEEL 2 +#define DECODER_GM7X 3 +#define DECODER_4G63 4 +#define DECODER_24X 5 +#define DECODER_JEEP2000 6 +#define DECODER_AUDI135 7 +#define DECODER_HONDA_D17 8 +#define DECODER_MIATA_9905 9 +#define DECODER_MAZDA_AU 10 +#define DECODER_NON360 11 +#define DECODER_NISSAN_360 12 +#define DECODER_SUBARU_67 13 +#define DECODER_DAIHATSU_PLUS1 14 +#define DECODER_HARLEY 15 +#define DECODER_36_2_2_2 16 +#define DECODER_36_2_1 17 +#define DECODER_420A 18 +#define DECODER_WEBER 19 + static inline void addToothLogEntry(unsigned long, bool); void loggerPrimaryISR(); void loggerSecondaryISR(); diff --git a/speeduino/decoders.ino b/speeduino/decoders.ino index ec5261f9..5cf93be7 100644 --- a/speeduino/decoders.ino +++ b/speeduino/decoders.ino @@ -3281,6 +3281,8 @@ void triggerSetEndTeeth_Harley() /* Name: 36-2-2-2 trigger wheel wheel Desc: A crank based trigger with a nominal 36 teeth, but 6 of these removed in 3 groups of 2. 2 of these groups are located concurrently. +Note: This decoder supports both the H4 version (13-missing-16-missing-1-missing) and the H6 version of 36-2-2-2 (19-missing-10-missing-1-missing) +The decoder checks which pattern is selected in order to determine the tooth number Note: www.thefactoryfiveforum.com/attachment.php?attachmentid=34279&d=1412431418 */ void triggerSetup_ThirtySixMinus222() @@ -3321,7 +3323,9 @@ void triggerPri_ThirtySixMinus222() if(toothSystemCount == 1) { //This occurs when we're at the first tooth after the 2 lots of 2x missing tooth. - toothCurrentCount = 19; + if(configPage2.nCylinders == 4 ) { toothCurrentCount = 19; } //H4 + else if(configPage2.nCylinders == 6) { toothCurrentCount = 23; } //H6 - NOT TESTED! + toothSystemCount = 0; currentStatus.hasSync = true; } @@ -3350,9 +3354,15 @@ void triggerPri_ThirtySixMinus222() } else if(toothSystemCount == 1) { - //This occurs when a set of missing teeth had been seen, but the next one was NOT missing. - toothCurrentCount = 35; - currentStatus.hasSync = true; + //This occurs when a set of missing teeth had been seen, but the next one was NOT missing. + if(configPage2.nCylinders == 4 ) + { + //H4 + toothCurrentCount = 35; + currentStatus.hasSync = true; + } + //else if(configPage2.nCylinders == 6) { toothCurrentCount = 3; } //H6 + } //Filter can only be recalc'd for the regular teeth, not the missing one. @@ -3408,13 +3418,28 @@ int getCrankAngle_ThirtySixMinus222() void triggerSetEndTeeth_ThirtySixMinus222() { - if(currentStatus.advance < 10) { ignition1EndTooth = 36; } - else if(currentStatus.advance < 20) { ignition1EndTooth = 35; } - else if(currentStatus.advance < 30) { ignition1EndTooth = 34; } - else { ignition1EndTooth = 31; } + if(configPage2.nCylinders == 4 ) + { + if(currentStatus.advance < 10) { ignition1EndTooth = 36; } + else if(currentStatus.advance < 20) { ignition1EndTooth = 35; } + else if(currentStatus.advance < 30) { ignition1EndTooth = 34; } + else { ignition1EndTooth = 31; } - if(currentStatus.advance < 30) { ignition2EndTooth = 16; } - else { ignition2EndTooth = 13; } + if(currentStatus.advance < 30) { ignition2EndTooth = 16; } + else { ignition2EndTooth = 13; } + } + else if(configPage2.nCylinders == 6) + { + //H6 + if(currentStatus.advance < 10) { ignition1EndTooth = 4; } + else if(currentStatus.advance < 20) { ignition1EndTooth = 3; } + else if(currentStatus.advance < 30) { ignition1EndTooth = 2; } + else { ignition1EndTooth = 35; } + + if(currentStatus.advance < 30) { ignition2EndTooth = 20; } + else { ignition2EndTooth = 17; } + } + lastToothCalcAdvance = currentStatus.advance; } diff --git a/speeduino/init.ino b/speeduino/init.ino index 83cfa3c9..5b1125ba 100644 --- a/speeduino/init.ino +++ b/speeduino/init.ino @@ -2697,7 +2697,7 @@ void initialiseTriggers() //Set the trigger function based on the decoder in the config switch (configPage4.TrigPattern) { - case 0: + case DECODER_MISSING_TOOTH: //Missing tooth decoder triggerSetup_missingTooth(); triggerHandler = triggerPri_missingTooth; @@ -2723,7 +2723,7 @@ void initialiseTriggers() */ break; - case 1: + case DECODER_BASIC_DISTRIBUTOR: // Basic distributor triggerSetup_BasicDistributor(); triggerHandler = triggerPri_BasicDistributor; @@ -2755,7 +2755,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 3: + case DECODER_GM7X: triggerSetup_GM7X(); triggerHandler = triggerPri_GM7X; getRPM = getRPM_GM7X; @@ -2771,7 +2771,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt, triggerHandler, primaryTriggerEdge); break; - case 4: + case DECODER_4G63: triggerSetup_4G63(); triggerHandler = triggerPri_4G63; triggerSecondaryHandler = triggerSec_4G63; @@ -2787,7 +2787,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 5: + case DECODER_24X: triggerSetup_24X(); triggerHandler = triggerPri_24X; triggerSecondaryHandler = triggerSec_24X; @@ -2804,7 +2804,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 6: + case DECODER_JEEP2000: triggerSetup_Jeep2000(); triggerHandler = triggerPri_Jeep2000; triggerSecondaryHandler = triggerSec_Jeep2000; @@ -2821,7 +2821,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 7: + case DECODER_AUDI135: triggerSetup_Audi135(); triggerHandler = triggerPri_Audi135; triggerSecondaryHandler = triggerSec_Audi135; @@ -2838,7 +2838,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 8: + case DECODER_HONDA_D17: triggerSetup_HondaD17(); triggerHandler = triggerPri_HondaD17; triggerSecondaryHandler = triggerSec_HondaD17; @@ -2855,7 +2855,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 9: + case DECODER_MIATA_9905: triggerSetup_Miata9905(); triggerHandler = triggerPri_Miata9905; triggerSecondaryHandler = triggerSec_Miata9905; @@ -2874,7 +2874,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 10: + case DECODER_MAZDA_AU: triggerSetup_MazdaAU(); triggerHandler = triggerPri_MazdaAU; triggerSecondaryHandler = triggerSec_MazdaAU; @@ -2891,7 +2891,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 11: + case DECODER_NON360: triggerSetup_non360(); triggerHandler = triggerPri_DualWheel; //Is identical to the dual wheel decoder, so that is used. Same goes for the secondary below triggerSecondaryHandler = triggerSec_DualWheel; //Note the use of the Dual Wheel trigger function here. No point in having the same code in twice. @@ -2908,7 +2908,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 12: + case DECODER_NISSAN_360: triggerSetup_Nissan360(); triggerHandler = triggerPri_Nissan360; triggerSecondaryHandler = triggerSec_Nissan360; @@ -2925,7 +2925,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 13: + case DECODER_SUBARU_67: triggerSetup_Subaru67(); triggerHandler = triggerPri_Subaru67; triggerSecondaryHandler = triggerSec_Subaru67; @@ -2942,7 +2942,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 14: + case DECODER_DAIHATSU_PLUS1: triggerSetup_Daihatsu(); triggerHandler = triggerPri_Daihatsu; getRPM = getRPM_Daihatsu; @@ -2956,7 +2956,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt, triggerHandler, primaryTriggerEdge); break; - case 15: + case DECODER_HARLEY: triggerSetup_Harley(); triggerHandler = triggerPri_Harley; //triggerSecondaryHandler = triggerSec_Harley; @@ -2968,7 +2968,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt, triggerHandler, primaryTriggerEdge); break; - case 16: + case DECODER_36_2_2_2: //36-2-2-2 triggerSetup_ThirtySixMinus222(); triggerHandler = triggerPri_ThirtySixMinus222; @@ -2987,12 +2987,11 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 17: + case DECODER_36_2_1: //36-2-1 - //NOT YET WRITTEN break; - case 18: + case DECODER_420A: //DSM 420a triggerSetup_420a(); triggerHandler = triggerPri_420a; @@ -3010,7 +3009,7 @@ void initialiseTriggers() attachInterrupt(triggerInterrupt2, triggerSecondaryHandler, secondaryTriggerEdge); break; - case 19: + case DECODER_WEBER: //Weber-Marelli triggerSetup_DualWheel(); triggerHandler = triggerPri_Webber;