1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-01-11 13:21:01 +01:00

Change PROG current detect during ACK

This commit is contained in:
Asbelos 2020-07-11 09:06:34 +01:00
parent e27c176fdf
commit 333410c368
2 changed files with 5 additions and 3 deletions

View File

@ -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;
}

View File

@ -94,6 +94,7 @@ 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;