mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-11 21:31:02 +01:00
Change PROG current detect during ACK
This commit is contained in:
parent
e27c176fdf
commit
333410c368
@ -99,6 +99,7 @@ void DCCWaveform::setPowerMode(POWERMODE mode) {
|
|||||||
|
|
||||||
|
|
||||||
void DCCWaveform::checkPowerOverload() {
|
void DCCWaveform::checkPowerOverload() {
|
||||||
|
|
||||||
if (millis() - lastSampleTaken < sampleDelay) return;
|
if (millis() - lastSampleTaken < sampleDelay) return;
|
||||||
lastSampleTaken = millis();
|
lastSampleTaken = millis();
|
||||||
|
|
||||||
@ -109,11 +110,11 @@ void DCCWaveform::checkPowerOverload() {
|
|||||||
case POWERMODE::ON:
|
case POWERMODE::ON:
|
||||||
// Check current
|
// Check current
|
||||||
lastCurrent = Hardware::getCurrentRaw(isMainTrack);
|
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 {
|
else {
|
||||||
setPowerMode(POWERMODE::OVERLOAD);
|
setPowerMode(POWERMODE::OVERLOAD);
|
||||||
unsigned int mA=Hardware::getCurrentMilliamps(isMainTrack,lastCurrent);
|
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);
|
DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d ***\n"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA);
|
||||||
sampleDelay = POWER_SAMPLE_OVERLOAD_WAIT;
|
sampleDelay = POWER_SAMPLE_OVERLOAD_WAIT;
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ class DCCWaveform {
|
|||||||
unsigned long lastSampleTaken;
|
unsigned long lastSampleTaken;
|
||||||
unsigned int sampleDelay;
|
unsigned int sampleDelay;
|
||||||
int rawCurrentTripValue;
|
int rawCurrentTripValue;
|
||||||
|
static const int ACK_CURRENT_TRIP=1000; // During ACK processing limit can be higher
|
||||||
|
|
||||||
// ACK management (Prog track only)
|
// ACK management (Prog track only)
|
||||||
bool ackPending;
|
bool ackPending;
|
||||||
|
Loading…
Reference in New Issue
Block a user