From 13e3b1f37b5404e393812b292c43376c18c4bc71 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Mon, 21 Aug 2017 11:52:12 +1000 Subject: [PATCH] Starting improvements on the 4g63 pattern --- speeduino/decoders.ino | 17 +++++++++++++---- speeduino/speeduino.ino | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/speeduino/decoders.ino b/speeduino/decoders.ino index 92c1fa6e..0b13a98c 100644 --- a/speeduino/decoders.ino +++ b/speeduino/decoders.ino @@ -708,7 +708,7 @@ void triggerPri_4G63() if (currentStatus.hasSync == true) { - if ( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) && configPage2.ignCranklock) + if ( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) && configPage2.ignCranklock && (currentStatus.startRevolutions >= configPage2.StgCycles)) { if( toothCurrentCount == 1 ) { endCoil1Charge(); } else if( toothCurrentCount == 3 ) { endCoil2Charge(); } @@ -784,7 +784,7 @@ void triggerSec_4G63() curTime2 = micros(); curGap2 = curTime2 - toothLastSecToothTime; - if ( (curGap2 >= triggerSecFilterTime) || (currentStatus.startRevolutions == 0) ) + if ( (curGap2 >= triggerSecFilterTime) )//|| (currentStatus.startRevolutions == 0) ) { toothLastSecToothTime = curTime2; @@ -797,6 +797,7 @@ void triggerSec_4G63() if(BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) || (currentStatus.hasSync == false) ) { + triggerFilterTime = 1500; //If this is removed, can have trouble getting sync again after the engine is turned off (but ECU not reset). if(READ_PRI_TRIGGER() == true)// && (crankState == digitalRead(pinTrigger))) { @@ -810,7 +811,15 @@ void triggerSec_4G63() triggerSecFilterTime_duration = (micros() - secondaryLastToothTime1) >> 1; if(READ_PRI_TRIGGER() == true)// && (crankState == digitalRead(pinTrigger))) { - toothCurrentCount = 4; //If the crank trigger is currently HIGH, it means we're on tooth #1 + if( (currentStatus.RPM < currentStatus.crankRPM) && (currentStatus.hasSync == true) ) + { + + //Whilst we're cranking and have sync, we need to watch for noise pulses. + if(toothCurrentCount != 4) { currentStatus.hasSync = false; } // This should never be true, except when there's noise + else { toothCurrentCount = 4; } + } + else { toothCurrentCount = 4; } //If the crank trigger is currently HIGH, it means we're on tooth #1 + } } // Use resync } //Trigger filter @@ -838,7 +847,7 @@ uint16_t getRPM_4G63() toothTime = toothTime * 36; tempRPM = ((unsigned long)tempToothAngle * 6000000UL) / toothTime; revolutionTime = (10UL * toothTime) / tempToothAngle; - MAX_STALL_TIME = revolutionTime << 3; + //MAX_STALL_TIME = revolutionTime << 3; } } else diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index fcc41cfa..15c0ac38 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -695,6 +695,7 @@ void loop() currentStatus.PW1 = 0; currentStatus.VE = 0; toothLastToothTime = 0; + toothLastSecToothTime = 0; //toothLastMinusOneToothTime = 0; currentStatus.hasSync = false; currentStatus.runSecs = 0; //Reset the counter for number of seconds running.