diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index f0045ee..8c14c43 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -99,6 +99,7 @@ void DCCWaveform::setPowerMode(POWERMODE mode) { void DCCWaveform::checkPowerOverload() { + if (millis() - lastSampleTaken < sampleDelay) return; lastSampleTaken = millis(); @@ -109,11 +110,11 @@ void DCCWaveform::checkPowerOverload() { case POWERMODE::ON: // Check current lastCurrent = Hardware::getCurrentRaw(isMainTrack); - if (lastCurrent <= rawCurrentTripValue) sampleDelay = POWER_SAMPLE_ON_WAIT; + if (lastCurrent <= (ackPending?ACK_CURRENT_TRIP:rawCurrentTripValue)) sampleDelay = POWER_SAMPLE_ON_WAIT; else { setPowerMode(POWERMODE::OVERLOAD); unsigned int mA=Hardware::getCurrentMilliamps(isMainTrack,lastCurrent); - unsigned int maxmA=Hardware::getCurrentMilliamps(isMainTrack,rawCurrentTripValue); + unsigned int maxmA=Hardware::getCurrentMilliamps(isMainTrack,ackPending?ACK_CURRENT_TRIP:rawCurrentTripValue); DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d ***\n"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA); sampleDelay = POWER_SAMPLE_OVERLOAD_WAIT; } diff --git a/DCCWaveform.h b/DCCWaveform.h index 537a05b..af562b0 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -94,7 +94,8 @@ class DCCWaveform { unsigned long lastSampleTaken; unsigned int sampleDelay; int rawCurrentTripValue; - + static const int ACK_CURRENT_TRIP=1000; // During ACK processing limit can be higher + // ACK management (Prog track only) bool ackPending; bool ackDetected;