From cc2b95da8d1b46b6b2367a98508490a1986d0d9f Mon Sep 17 00:00:00 2001 From: Pasi Kemppainen <48950874+pazi88@users.noreply.github.com> Date: Wed, 29 Jul 2020 04:07:43 +0300 Subject: [PATCH] Add "Half sync" indicator (#370) * Half sync indicator for 3 different trigger patterns. Added half sync indicator which shows that there is only primary trigger present for missing tooth, dual wheel and miata 9905 trigger patterns * missing tooth required some adjusting * forgot to remove stm32 pin mapping. I have it in other PR * Leave only for missing tooth Co-authored-by: Pasi Kemppainen Co-authored-by: Josh Stewart --- reference/speeduino.ini | 5 +++-- speeduino/decoders.ino | 5 ++++- speeduino/globals.h | 2 +- speeduino/init.ino | 3 ++- speeduino/speeduino.ino | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 5efc1df2..0234cbe5 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -3964,7 +3964,8 @@ cmdVSSratio6 = "E\x99\x06" indicator = { softlimitOn }, "Soft Limit OFF","Soft Limiter", white, black, red, black indicator = { hardLimitOn }, "Hard Limit OFF","Hard Limiter", white, black, red, black indicator = { boostCutOut }, "Ign Cut OFF", "Ign Cut (Boost)", white, black, red, black - indicator = { sync }, "No Sync", "Sync", white, black, green, black + indicator = { sync }, "No Sync", "Full Sync", white, black, green, black + indicator = { halfSync }, "No or Full Sync", "Half Sync", white, black, yellow, black indicator = { resetLockOn }, "Reset Lock OFF","Reset Lock ON", red, black, green, black indicator = { bootloaderCaps > 0 }, "Std. Boot", "Custom Boot", white, black, white, black indicator = { nitrousOn }, "Nitrous Off", "Nitrous On", white, black, red, black @@ -4078,7 +4079,7 @@ cmdVSSratio6 = "E\x99\x06" nitrousOn = bits, U08, 83, [1:1] fuel2Active = bits, U08, 83, [2:2] vssRefresh = bits, U08, 83, [3:3] - unused81_4 = bits, U08, 83, [4:4] + halfSync = bits, U08, 83, [4:4] nSquirts = bits, U08, 83, [5:7] engineProtectStatus = scalar, U08, 84, "bits", 1.000, 0.000 engineProtectRPM = bits, U08, 84, [0:0] diff --git a/speeduino/decoders.ino b/speeduino/decoders.ino index 5cae71a4..b856df24 100644 --- a/speeduino/decoders.ino +++ b/speeduino/decoders.ino @@ -389,6 +389,7 @@ void triggerPri_missingTooth() { //This occurs when we're at tooth #1, but haven't seen all the other teeth. This indicates a signal issue so we flag lost sync so this will attempt to resync on the next revolution. currentStatus.hasSync = false; + BIT_CLEAR(currentStatus.status3, BIT_STATUS3_HALFSYNC); //No sync at all, so also clear HalfSync bit. currentStatus.syncLossCounter++; } //This is to handle a special case on startup where sync can be obtained and the system immediately thinks the revs have jumped: @@ -414,10 +415,12 @@ void triggerPri_missingTooth() if( (secondaryToothCount > 0) || (configPage4.TrigSpeed == CAM_SPEED) ) { currentStatus.hasSync = true; + BIT_CLEAR(currentStatus.status3, BIT_STATUS3_HALFSYNC); //the engine is fully synced so clear the Half Sync bit if(configPage4.trigPatternSec == SEC_TRIGGER_SINGLE) { secondaryToothCount = 0; } //Reset the secondary tooth counter to prevent it overflowing } + else if(currentStatus.hasSync != true) { BIT_SET(currentStatus.status3, BIT_STATUS3_HALFSYNC); } //If there is primary trigger but no secondary we only have half sync. } - else { currentStatus.hasSync = true; } //If nothing is using sequential, we have sync + else { currentStatus.hasSync = true; BIT_CLEAR(currentStatus.status3, BIT_STATUS3_HALFSYNC); } //If nothing is using sequential, we have sync and also clear half sync bit triggerFilterTime = 0; //This is used to prevent a condition where serious intermitent signals (Eg someone furiously plugging the sensor wire in and out) can leave the filter in an unrecoverable state toothLastMinusOneToothTime = toothLastToothTime; diff --git a/speeduino/globals.h b/speeduino/globals.h index d3e14674..a9b0930f 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -169,7 +169,7 @@ #define BIT_STATUS3_NITROUS 1 #define BIT_STATUS3_FUEL2_ACTIVE 2 #define BIT_STATUS3_VSS_REFRESH 3 -#define BIT_STATUS3_UNUSED4 4 +#define BIT_STATUS3_HALFSYNC 4 //shows if there is only sync from primary trigger, but not from secondary. #define BIT_STATUS3_NSQUIRTS1 5 #define BIT_STATUS3_NSQUIRTS2 6 #define BIT_STATUS3_NSQUIRTS3 7 diff --git a/speeduino/init.ino b/speeduino/init.ino index b4b155e9..f480c640 100644 --- a/speeduino/init.ino +++ b/speeduino/init.ino @@ -325,6 +325,7 @@ void initialiseAll() //These assignments are based on the Arduino Mega AND VARY BETWEEN BOARDS. Please confirm the board you are using and update acordingly. currentStatus.RPM = 0; currentStatus.hasSync = false; + BIT_CLEAR(currentStatus.status3, BIT_STATUS3_HALFSYNC); currentStatus.runSecs = 0; currentStatus.secl = 0; currentStatus.startRevolutions = 0; @@ -1745,7 +1746,7 @@ void setPinMapping(byte boardID) #endif break; - case 31: + case 31: //Pin mappings for the BMW PnP PCBs by pazi88. This is an AVR only module. At least for now pinInjector1 = 8; //Output pin injector 1 pinInjector2 = 9; //Output pin injector 2 diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index 9c50bbe5..6530f62e 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -168,6 +168,7 @@ void loop() toothLastSecToothTime = 0; //toothLastMinusOneToothTime = 0; currentStatus.hasSync = false; + BIT_CLEAR(currentStatus.status3, BIT_STATUS3_HALFSYNC); currentStatus.runSecs = 0; //Reset the counter for number of seconds running. currentStatus.startRevolutions = 0; toothSystemCount = 0;