From 1f03d9759ddfa15e99d137052b69394ecb8baf25 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 27 Sep 2020 13:12:02 +0200 Subject: [PATCH] cap overcurrent off time to 10sec --- DCCWaveform.cpp | 5 ++++- DCCWaveform.h | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index c67dcd6..a70ab16 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -152,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 d0f6d6e..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;