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

Ack current setable by debug statement D ACK LIMIT n

This commit is contained in:
Harald Barth 2020-10-08 23:39:04 +02:00
parent 3f06fb08df
commit 1c2df3fe22
4 changed files with 26 additions and 10 deletions

View File

@ -47,6 +47,7 @@ const int HASH_KEYWORD_DCC = 6436;
const int HASH_KEYWORD_SLOW = -17209; const int HASH_KEYWORD_SLOW = -17209;
const int HASH_KEYWORD_PROGBOOST = -6353; const int HASH_KEYWORD_PROGBOOST = -6353;
const int HASH_KEYWORD_EEPROM = -7168; const int HASH_KEYWORD_EEPROM = -7168;
const int HASH_KEYWORD_LIMIT = 27413;
int DCCEXParser::stashP[MAX_PARAMS]; int DCCEXParser::stashP[MAX_PARAMS];
bool DCCEXParser::stashBusy; bool DCCEXParser::stashBusy;
@ -586,6 +587,10 @@ bool DCCEXParser::parseD(Print *stream, int params, int p[])
break; break;
case HASH_KEYWORD_ACK: // <D ACK ON/OFF> case HASH_KEYWORD_ACK: // <D ACK ON/OFF>
if (params >= 2 && p[1] == HASH_KEYWORD_LIMIT) {
DCCWaveform::progTrack.setAckLimit(p[2]);
StringFormatter::send(stream, F("\nAck limit=%dmA\n"), p[2]);
} else
Diag::ACK = onOff; Diag::ACK = onOff;
return true; return true;

View File

@ -128,7 +128,7 @@ void DCCWaveform::checkPowerOverload() {
if (millis() - lastSampleTaken < sampleDelay) return; if (millis() - lastSampleTaken < sampleDelay) return;
lastSampleTaken = millis(); lastSampleTaken = millis();
int tripValue= motorDriver->rawCurrentTripValue; int tripValue= motorDriver->getRawCurrentTripValue();
if (!isMainTrack && !ackPending && !progTrackSyncMain && !progTrackBoosted) if (!isMainTrack && !ackPending && !progTrackSyncMain && !progTrackBoosted)
tripValue=progTripValue; tripValue=progTripValue;
@ -293,8 +293,11 @@ int DCCWaveform::getLastCurrent() {
void DCCWaveform::setAckBaseline() { void DCCWaveform::setAckBaseline() {
if (isMainTrack) return; if (isMainTrack) return;
ackThreshold=motorDriver->getCurrentRaw() + (int)(65 / motorDriver->senseFactor); int baseline = motorDriver->getCurrentRaw();
if (Diag::ACK) DIAG(F("\nACK-BASELINE %d/%dmA"),ackThreshold,motorDriver->raw2mA(ackThreshold)); ackThreshold= baseline + motorDriver->mA2raw(ackLimitmA);
if (Diag::ACK) DIAG(F("\nACK baseline=%d/%dmA threshold=%d/%dmA"),
baseline,motorDriver->raw2mA(baseline),
ackThreshold,motorDriver->raw2mA(ackThreshold));
} }
void DCCWaveform::setAckPending() { void DCCWaveform::setAckPending() {

View File

@ -76,6 +76,9 @@ class DCCWaveform {
autoPowerOff=false; autoPowerOff=false;
} }
}; };
inline void setAckLimit(int mA) {
ackLimitmA = mA;
}
private: private:
static VirtualTimer * interruptTimer; static VirtualTimer * interruptTimer;
@ -118,6 +121,7 @@ class DCCWaveform {
bool ackPending; bool ackPending;
bool ackDetected; bool ackDetected;
int ackThreshold; int ackThreshold;
int ackLimitmA = 60;
int ackMaxCurrent; int ackMaxCurrent;
unsigned long ackCheckStart; // millis unsigned long ackCheckStart; // millis
unsigned int ackCheckDuration; // millis unsigned int ackCheckDuration; // millis

View File

@ -29,7 +29,11 @@ class MotorDriver {
virtual int getCurrentRaw(); virtual int getCurrentRaw();
virtual unsigned int raw2mA( int raw); virtual unsigned int raw2mA( int raw);
virtual int mA2raw( unsigned int mA); virtual int mA2raw( unsigned int mA);
inline int getRawCurrentTripValue() {
return rawCurrentTripValue;
}
private:
byte powerPin, signalPin, signalPin2, brakePin,currentPin,faultPin; byte powerPin, signalPin, signalPin2, brakePin,currentPin,faultPin;
float senseFactor; float senseFactor;
unsigned int tripMilliamps; unsigned int tripMilliamps;