diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 519640c..f0045ee 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -277,7 +277,7 @@ void DCCWaveform::checkAck() { lastCurrent=Hardware::getCurrentRaw(false); if (lastCurrent > ackMaxCurrent) ackMaxCurrent=lastCurrent; - // An ACK is a pulse lasting between 4.5 and 8.5 mSecs (refer @haba) + // An ACK is a pulse lasting between MIN_ACK_PULSE_DURATION and MAX_ACK_PULSE_DURATION uSecs (refer @haba) if (lastCurrent>ackThreshold) { if (ackPulseStart==0) ackPulseStart=micros(); // leading edge of pulse detected @@ -290,7 +290,7 @@ void DCCWaveform::checkAck() { // detected trailing edge of pulse ackPulseDuration=micros()-ackPulseStart; - if (ackPulseDuration>1000 && ackPulseDuration<9000) { + if (ackPulseDuration>=MIN_ACK_PULSE_DURATION && ackPulseDuration<=MAX_ACK_PULSE_DURATION) { ackCheckDuration=millis()-ackCheckStart; ackDetected=true; ackPending=false; diff --git a/DCCWaveform.h b/DCCWaveform.h index 12cd96c..537a05b 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -24,7 +24,9 @@ const int POWER_SAMPLE_ON_WAIT = 100; const int POWER_SAMPLE_OFF_WAIT = 1000; const int POWER_SAMPLE_OVERLOAD_WAIT = 4000; - +const int MIN_ACK_PULSE_DURATION = 3000; +const int MAX_ACK_PULSE_DURATION = 8500; + const int PREAMBLE_BITS_MAIN = 20; const int PREAMBLE_BITS_PROG = 22;