1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-26 17:46:14 +01:00

ACK pulse durations

Refer @haba
This commit is contained in:
Asbelos 2020-07-03 17:57:24 +01:00
parent dc33acf7d4
commit a2636b1296
2 changed files with 5 additions and 3 deletions

View File

@ -277,7 +277,7 @@ void DCCWaveform::checkAck() {
lastCurrent=Hardware::getCurrentRaw(false); lastCurrent=Hardware::getCurrentRaw(false);
if (lastCurrent > ackMaxCurrent) ackMaxCurrent=lastCurrent; 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 (lastCurrent>ackThreshold) {
if (ackPulseStart==0) ackPulseStart=micros(); // leading edge of pulse detected if (ackPulseStart==0) ackPulseStart=micros(); // leading edge of pulse detected
@ -290,7 +290,7 @@ void DCCWaveform::checkAck() {
// detected trailing edge of pulse // detected trailing edge of pulse
ackPulseDuration=micros()-ackPulseStart; ackPulseDuration=micros()-ackPulseStart;
if (ackPulseDuration>1000 && ackPulseDuration<9000) { if (ackPulseDuration>=MIN_ACK_PULSE_DURATION && ackPulseDuration<=MAX_ACK_PULSE_DURATION) {
ackCheckDuration=millis()-ackCheckStart; ackCheckDuration=millis()-ackCheckStart;
ackDetected=true; ackDetected=true;
ackPending=false; ackPending=false;

View File

@ -24,7 +24,9 @@ const int POWER_SAMPLE_ON_WAIT = 100;
const int POWER_SAMPLE_OFF_WAIT = 1000; const int POWER_SAMPLE_OFF_WAIT = 1000;
const int POWER_SAMPLE_OVERLOAD_WAIT = 4000; 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_MAIN = 20;
const int PREAMBLE_BITS_PROG = 22; const int PREAMBLE_BITS_PROG = 22;