diff --git a/DCC.cpp b/DCC.cpp index ebf51de..29fa9d7 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -207,6 +207,9 @@ void DCC::writeCVBitMain(int cab, int cv, byte bNum, bool bValue) { void DCC::setProgTrackSyncMain(bool on) { DCCWaveform::progTrackSyncMain=on; } +void DCC::setProgTrackBoost(bool on) { + DCCWaveform::progTrackBoosted=on; +} __FlashStringHelper* DCC::getMotorShieldName() { return shieldName; diff --git a/DCC.h b/DCC.h index 1e1058b..0e8fcc6 100644 --- a/DCC.h +++ b/DCC.h @@ -76,6 +76,7 @@ public: static void setAccessory(int aAdd, byte aNum, bool activate); static bool writeTextPacket(byte *b, int nBytes); static void setProgTrackSyncMain(bool on); // when true, prog track becomes driveable + static void setProgTrackBoost(bool on); // when true, special prog track current limit does not apply // ACKable progtrack calls bitresults callback 0,0 or -1, cv returns value or -1 static void readCV(int cv, ACK_CALLBACK callback, bool blocking = false); diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 82cd9d9..b52a968 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -45,6 +45,7 @@ const int HASH_KEYWORD_ACK = 3113; const int HASH_KEYWORD_ON = 2657; const int HASH_KEYWORD_DCC = 6436; const int HASH_KEYWORD_SLOW = -17209; +const int HASH_KEYWORD_PROGBOOST = -6353; int DCCEXParser::stashP[MAX_PARAMS]; bool DCCEXParser::stashBusy; @@ -598,6 +599,11 @@ bool DCCEXParser::parseD(Print *stream, int params, int p[]) case HASH_KEYWORD_DCC: DCCWaveform::setDiagnosticSlowWave(params >= 1 && p[1] == HASH_KEYWORD_SLOW); return true; + + case HASH_KEYWORD_PROGBOOST: + DCC::setProgTrackBoost(true); + return true; + default: // invalid/unknown break; } diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index dc4b503..a70ab16 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -30,6 +30,7 @@ DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false); bool DCCWaveform::progTrackSyncMain=false; +bool DCCWaveform::progTrackBoosted=false; VirtualTimer * DCCWaveform::interruptTimer=NULL; void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver, byte timerNumber) { @@ -128,7 +129,7 @@ void DCCWaveform::checkPowerOverload() { if (millis() - lastSampleTaken < sampleDelay) return; lastSampleTaken = millis(); int tripValue= motorDriver->rawCurrentTripValue; - if (!isMainTrack && !ackPending && !progTrackSyncMain) + if (!isMainTrack && !ackPending && !progTrackSyncMain && !progTrackBoosted) tripValue=progTripValue; switch (powerMode) { @@ -151,7 +152,10 @@ void DCCWaveform::checkPowerOverload() { DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d offtime=%l ***\n"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA, power_sample_overload_wait); power_good_counter=0; sampleDelay = power_sample_overload_wait; - power_sample_overload_wait *= 2; + if (power_sample_overload_wait >= 10000) + power_sample_overload_wait = 10000; + else + power_sample_overload_wait *= 2; } break; case POWERMODE::OVERLOAD: diff --git a/DCCWaveform.h b/DCCWaveform.h index 5af7144..d607420 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -22,14 +22,16 @@ #include "MotorDriver.h" #include "ArduinoTimers.h" +// Wait times for power management. Unit: milliseconds const int POWER_SAMPLE_ON_WAIT = 100; const int POWER_SAMPLE_OFF_WAIT = 1000; const int POWER_SAMPLE_OVERLOAD_WAIT = 20; +// Ack time thresholds. Unit: microseconds const int MIN_ACK_PULSE_DURATION = 2000; const int MAX_ACK_PULSE_DURATION = 8500; - +// Number of preamble bits. const int PREAMBLE_BITS_MAIN = 16; const int PREAMBLE_BITS_PROG = 22; @@ -67,6 +69,7 @@ class DCCWaveform { void setAckPending(); //prog track only byte getAck(); //prog track only 0=NACK, 1=ACK 2=keep waiting static bool progTrackSyncMain; // true when prog track is a siding switched to main + static bool progTrackBoosted; // true when prog track is not current limited inline void doAutoPowerOff() { if (autoPowerOff) { setPowerMode(POWERMODE::OFF);