From af40812586d6f55d7b475ee4ffdd8e6438bcb004 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Fri, 18 Nov 2016 14:28:33 +1100 Subject: [PATCH] Allow for leading/trailing edge selection on missing tooth and dual wheel decoders --- globals.h | 4 +++- reference/speeduino.ini | 11 ++++++++++- speeduino.ino | 6 ++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/globals.h b/globals.h index d2e6276..c50baa7 100644 --- a/globals.h +++ b/globals.h @@ -267,8 +267,10 @@ struct config2 { byte IgInv : 1; byte oddfire : 1; byte TrigPattern : 4; + + byte TrigEdgeSec : 1; + byte unused4_6b : 7; - byte unused4_6; byte unused4_7; byte IdleAdvRPM; byte IdleAdvCLT; //The temperature below which the idle is advanced diff --git a/reference/speeduino.ini b/reference/speeduino.ini index cf6c0d4..fdcc1df 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -246,7 +246,14 @@ page = 4 IgInv = bits, U08, 5[2:2], "Going Low", "Going High" oddfire = bits, U08, 5[3:3], "No", "Yes" TrigPattern= bits, U08, 5[4:7], "Missing Tooth", "Basic Distributor", "Dual Wheel", "GM 7X", "4G63 / Miata", "GM 24X", "Jeep 2000", "Audi 135", "Honda D17", "Miata 99-05", "Mazda AU", "Non-360 Dual", "INVALID", "INVALID", "INVALID", "INVALID" - unused4-6 = scalar, U08, 6, "Deg", 0.352,-28.4, -10, 80, 0 + TrigEdgeSec= bits, U08, 6[0:0], "Leading", "Trailing" + unused4-6b = bits, U08, 6[1:1], "No", "Yes" + unused4-6c = bits, U08, 6[2:2], "No", "Yes" + unused4-6d = bits, U08, 6[3:3], "No", "Yes" + unused4-6e = bits, U08, 6[4:4], "No", "Yes" + unused4-6f = bits, U08, 6[5:5], "No", "Yes" + unused4-6g = bits, U08, 6[6:6], "No", "Yes" + unused4-6h = bits, U08, 6[7:7], "No", "Yes" unused4-7 = scalar, U08, 7, "ADC", 1, 0, 0, 255, 0 IdleAdvRPM = scalar, U08, 8, "RPM", 100, 0, 0, 1200, 0 #if CELSIUS @@ -684,6 +691,7 @@ menuDialog = main TrigAngMul = "A multiplier used by non-360 degree tooth wheels (i.e. Wheels where the tooth count doesn't divide evenly into 360. Usage: (360 * ) / tooth_count = Whole number" 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." + TrigEdgeSec = "The Trigger edge of the secondary (Cam) sensor.\nLeading.\nTrailing." TrigFilter = "Tuning of the trigger filter algorithm. The more aggressive the setting, the more noise will be removed, however this increases the chance of some true readings being filtered out (False positive). Medium is safe for most setups. Only select 'Aggressive' if no other options are working" 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" @@ -905,6 +913,7 @@ 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 + field = "Secondary trigger edge", TrigEdgeSec, { TrigPattern == 0 || TrigPattern == 2 } field = "Trigger Filter", TrigFilter dialog = sparkSettings,"Spark Settings",4 diff --git a/speeduino.ino b/speeduino.ino index 5454342..9858b57 100644 --- a/speeduino.ino +++ b/speeduino.ino @@ -328,7 +328,8 @@ void setup() 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); } - attachInterrupt(triggerInterrupt2, triggerSec_missingTooth, RISING); + if(configPage2.TrigEdgeSec == 0) { attachInterrupt(triggerInterrupt2, triggerSec_missingTooth, RISING); } + else { attachInterrupt(triggerInterrupt2, triggerSec_missingTooth, FALLING); } break; case 1: @@ -350,7 +351,8 @@ void setup() 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); } - attachInterrupt(triggerInterrupt2, triggerSec_DualWheel, RISING); + if(configPage2.TrigEdgeSec == 0) { attachInterrupt(triggerInterrupt2, triggerSec_DualWheel, RISING); } + else { attachInterrupt(triggerInterrupt2, triggerSec_DualWheel, FALLING); } break; case 3: