From a98657fef29cea872b130b4054fb3f5117cd6f0c Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Wed, 13 Oct 2021 20:04:27 +0200 Subject: [PATCH] trigger overload first after second sample --- DCCWaveform.cpp | 8 ++++++-- DCCWaveform.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index df88e5d..cb3ef5d 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -156,10 +156,14 @@ void DCCWaveform::checkPowerOverload(bool ackManagerActive) { else if (power_sample_overload_wait>POWER_SAMPLE_OVERLOAD_WAIT) power_sample_overload_wait=POWER_SAMPLE_OVERLOAD_WAIT; } else { - setPowerMode(POWERMODE::OVERLOAD); unsigned int mA=motorDriver->raw2mA(lastCurrent); unsigned int maxmA=motorDriver->raw2mA(tripValue); - power_good_counter=0; + if (power_good_counter > 0) { + power_good_counter = 0; + DIAG(F("*** %S TRACK POWER WARNING current=%d max=%d ***"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA); + break; + } + setPowerMode(POWERMODE::OVERLOAD); sampleDelay = power_sample_overload_wait; DIAG(F("*** %S TRACK POWER OVERLOAD current=%d max=%d offtime=%d ***"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA, sampleDelay); if (power_sample_overload_wait >= 10000) diff --git a/DCCWaveform.h b/DCCWaveform.h index 29d6a29..242959d 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -23,7 +23,7 @@ #include "MotorDriver.h" // Wait times for power management. Unit: milliseconds -const int POWER_SAMPLE_ON_WAIT = 100; +const int POWER_SAMPLE_ON_WAIT = 50; const int POWER_SAMPLE_OFF_WAIT = 1000; const int POWER_SAMPLE_OVERLOAD_WAIT = 20;