diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index 355e2e9..267e562 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202305201256Z" +#define GITHUB_SHA "devel-202305202114Z" diff --git a/MotorDriver.cpp b/MotorDriver.cpp index b8068f3..603549e 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -214,14 +214,12 @@ int MotorDriver::getCurrentRaw(bool fromISR) { // if (fromISR == false) DIAG(F("%c: %d"), trackLetter, current); current = current-senseOffset; // adjust with offset if (current<0) current=0-current; - if ((faultPin != UNUSED_PIN) && powerMode==POWERMODE::ON) { - if (invertFault && isLOW(fastFaultPin)) - return (current == 0 ? -1 : -current); - if (!invertFault && !isLOW(fastFaultPin)) + // current >= 0 here, we use negative current as fault pin flag + if ((faultPin != UNUSED_PIN) && powerPin) { + if (invertFault ? isHIGH(fastFaultPin) : isLOW(fastFaultPin)) return (current == 0 ? -1 : -current); } return current; - } #ifdef ANALOG_READ_INTERRUPT diff --git a/MotorDrivers.h b/MotorDrivers.h index 8d1c34d..a40c4f1 100644 --- a/MotorDrivers.h +++ b/MotorDrivers.h @@ -73,8 +73,8 @@ // EX 8874 based shield connected to a 3V3 system with 12-bit (4096) ADC #define EX8874_SHIELD F("EX8874"), \ - new MotorDriver( 3, 12, UNUSED_PIN, 9, A0, 1.27, 5000, -A4), \ - new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 1.27, 5000, -A5) + new MotorDriver( 3, 12, UNUSED_PIN, 9, A0, 1.27, 5000, A4), \ + new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 1.27, 5000, A5) #elif defined(ARDUINO_ARCH_ESP32) @@ -90,8 +90,8 @@ // EX 8874 based shield connected to a 3.3V system (like ESP32) and 12bit (4096) ADC // numbers are GPIO numbers. comments are UNO form factor shield pin numbers #define EX8874_SHIELD F("EX8874"),\ - new MotorDriver(25/* 3*/, 19/*12*/, UNUSED_PIN, 13/*9*/, 35/*A2*/, 1.27, 5000, -36 /*-A4*/), \ - new MotorDriver(23/*11*/, 18/*13*/, UNUSED_PIN, 12/*8*/, 34/*A3*/, 1.27, 5000, -39 /*-A5*/) + new MotorDriver(25/* 3*/, 19/*12*/, UNUSED_PIN, 13/*9*/, 35/*A2*/, 1.27, 5000, 36 /*A4*/), \ + new MotorDriver(23/*11*/, 18/*13*/, UNUSED_PIN, 12/*8*/, 34/*A3*/, 1.27, 5000, 39 /*A5*/) #else // STANDARD shield on any Arduino Uno or Mega compatible with the original specification. @@ -104,8 +104,8 @@ // EX 8874 based shield connected to a 5V system (like Arduino) and 10bit (1024) ADC #define EX8874_SHIELD F("EX8874"), \ - new MotorDriver( 3, 12, UNUSED_PIN, 9, A0, 5.08, 5000, -A4), \ - new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 5.08, 5000, -A5) + new MotorDriver( 3, 12, UNUSED_PIN, 9, A0, 5.08, 5000, A4), \ + new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 5.08, 5000, A5) #endif diff --git a/version.h b/version.h index fc4ee3c..9ddacd2 100644 --- a/version.h +++ b/version.h @@ -4,7 +4,8 @@ #include "StringFormatter.h" -#define VERSION "4.2.52" +#define VERSION "4.2.53" +// 4.2.53 - Fix: Fault pin handling made more straight forward // 4.2.52 - Experimental support for sabertooth motor controller on ESP32 // 4.2.51 - Add DISABLE_PROG to disable programming to save RAM/Flash // 4.2.50 - Fixes: estop all, turnout eeprom, cab ID check