From 7ef0ae966b17cf822e218c8547dc8656ce16adf0 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Sun, 1 Jan 2017 19:56:04 +1100 Subject: [PATCH] Better filter options for 4g63 --- decoders.h | 2 +- decoders.ino | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/decoders.h b/decoders.h index 10798924..cfd23198 100644 --- a/decoders.h +++ b/decoders.h @@ -45,7 +45,7 @@ volatile unsigned long secondaryLastToothTime = 0; //The time (micros()) that th volatile int triggerActualTeeth; volatile unsigned long triggerFilterTime; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering) unsigned int triggerSecFilterTime; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering) for the secondary input -int triggerToothAngle; //The number of crank degrees that elapse per tooth +volatile int triggerToothAngle; //The number of crank degrees that elapse per tooth unsigned long revolutionTime; //The time in uS that one revolution would take at current speed (The time tooth 1 was last seen, minus the time it was seen prior to that) bool secondDerivEnabled; //The use of the 2nd derivative calculation is limited to certain decoders. This is set to either true or false in each decoders setup routine bool decoderIsSequential; //Whether or not the decoder supports sequential operation diff --git a/decoders.ino b/decoders.ino index 811e3004..d6d2cea6 100644 --- a/decoders.ino +++ b/decoders.ino @@ -535,8 +535,25 @@ void triggerPri_4G63() } //Whilst this is an uneven tooth pattern, if the specific angle between the last 2 teeth is specified, 1st deriv prediction can be used - if(toothCurrentCount == 1 || toothCurrentCount == 3) { triggerToothAngle = 70; triggerFilterTime = curGap; } //Trigger filter is set to whatever time it took to do 70 degrees (Next trigger is 110 degrees away) - else { triggerToothAngle = 110; triggerFilterTime = (curGap * 3) >> 3; } //Trigger filter is set to (110*3)/8=41.25=41 degrees (Next trigger is 70 degrees away). + if(configPage2.triggerFilter == 1 || currentStatus.RPM < 1800) + { + //Lite filter + if(toothCurrentCount == 1 || toothCurrentCount == 3) { triggerToothAngle = 70; triggerFilterTime = curGap; } //Trigger filter is set to whatever time it took to do 70 degrees (Next trigger is 110 degrees away) + else { triggerToothAngle = 110; triggerFilterTime = (curGap * 3) >> 3; } //Trigger filter is set to (110*3)/8=41.25=41 degrees (Next trigger is 70 degrees away). + } + else if(configPage2.triggerFilter == 2) + { + //Medium filter level + if(toothCurrentCount == 1 || toothCurrentCount == 3) { triggerToothAngle = 70; triggerFilterTime = (curGap * 5) >> 2 ; } //87.5 degrees with a target of 110 + else { triggerToothAngle = 110; triggerFilterTime = (curGap >> 1); } //55 degrees with a target of 70 + } + else if (configPage2.triggerFilter == 3) + { + //Aggressive filter level + if(toothCurrentCount == 1 || toothCurrentCount == 3) { triggerToothAngle = 70; triggerFilterTime = (curGap * 11) >> 3 ; } //96.26 degrees with a target of 110 + else { triggerToothAngle = 110; triggerFilterTime = (curGap * 9) >> 5; } //61.87 degrees with a target of 70 + } + else { triggerFilterTime = 0; } //trigger filter is turned off. } void triggerSec_4G63()