From 431208d191e15d7cc6e2b6ce8c937cd07fa1017c Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Wed, 27 Apr 2022 10:32:21 -0500 Subject: [PATCH 1/3] ACK defaults now 50-2000-20000 --- DCCWaveform.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DCCWaveform.h b/DCCWaveform.h index 14f2f11..3838b8e 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -157,7 +157,7 @@ class DCCWaveform { volatile bool ackPending; volatile bool ackDetected; int ackThreshold; - int ackLimitmA = 60; + int ackLimitmA = 50; int ackMaxCurrent; unsigned long ackCheckStart; // millis unsigned int ackCheckDuration; // millis @@ -165,8 +165,8 @@ class DCCWaveform { unsigned int ackPulseDuration; // micros unsigned long ackPulseStart; // micros - unsigned int minAckPulseDuration = 4000; // micros - unsigned int maxAckPulseDuration = 8500; // micros + unsigned int minAckPulseDuration = 2000; // micros + unsigned int maxAckPulseDuration = 20000; // micros volatile static uint8_t numAckGaps; volatile static uint8_t numAckSamples; From ad975927888cc12ce3181453c6ffb257bc254d16 Mon Sep 17 00:00:00 2001 From: Ash-4 <81280775+Ash-4@users.noreply.github.com> Date: Wed, 27 Apr 2022 10:38:00 -0500 Subject: [PATCH 2/3] Update version.h --- version.h | 1 + 1 file changed, 1 insertion(+) diff --git a/version.h b/version.h index 8ca3ea4..352ba8e 100644 --- a/version.h +++ b/version.h @@ -6,6 +6,7 @@ #define VERSION "4.0.2" // 4.0.2 EXRAIL additions: +// ACK defaults set to 50mA LIMIT, 2000uS MIN, 20000uS MAX // myFilter automatic detection (no need to call setFilter) // FIX negative route ids in WIthrottle problem. // IFRED(signal_id), IFAMBER(signal_id), IFGREEN(signal_id) From afd94f0645eb4dc71175ef6360a9d5fb5cc5fce7 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Fri, 29 Apr 2022 11:56:17 +0100 Subject: [PATCH 3/3] Improved SIGNALs startup and diagnostics --- EXRAIL2.cpp | 17 +++++++---------- IO_PCA9685.cpp | 6 +++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 6e7e005..599411e 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -169,14 +169,10 @@ int16_t LookList::find(int16_t value) { // Second pass startup, define any turnouts or servos, set signals red // add sequences onRoutines to the lookups - for (int sigpos=0;;sigpos+=3) { - VPIN redpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos); - if (redpin==0) break; // end of signal list - VPIN amberpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+1); - VPIN greenpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+2); - IODevice::write(redpin,true); - if (amberpin) IODevice::write(amberpin,false); - IODevice::write(greenpin,false); + for (int sigpos=0;;sigpos+=4) { + VPIN sigid=GETFLASHW(RMFT2::SignalDefinitions+sigpos); + if (sigid==0) break; // end of signal list + doSignal(sigid & (~ SERVO_SIGNAL_FLAG) & (~ACTIVE_HIGH_SIGNAL_FLAG), SIGNAL_RED); } for (progCounter=0;; SKIPOP){ @@ -993,7 +989,7 @@ int16_t RMFT2::getSignalSlot(VPIN id) { } } /* static */ void RMFT2::doSignal(VPIN id,char rag) { - //if (diag) DIAG(F(" dosignal %d %x"),id,rag); + if (diag) DIAG(F(" doSignal %d %x"),id,rag); int16_t sigslot=getSignalSlot(id); if (sigslot<0) return; @@ -1006,12 +1002,13 @@ int16_t RMFT2::getSignalSlot(VPIN id) { VPIN redpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+1); VPIN amberpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+2); VPIN greenpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+3); - //if (diag) DIAG(F("signal %d %d %d"),redpin,amberpin,greenpin); + if (diag) DIAG(F("signal %d %d %d %d"),sigid,redpin,amberpin,greenpin); if (sigid & SERVO_SIGNAL_FLAG) { // A servo signal, the pin numbers are actually servo positions // Note, setting a signal to a zero position has no effect. int16_t servopos= rag==SIGNAL_RED? redpin: (rag==SIGNAL_GREEN? greenpin : amberpin); + if (diag) DIAG(F("sigA %d %d"),id,servopos); if (servopos!=0) IODevice::writeAnalogue(id,servopos,PCA9685::Bounce); return; } diff --git a/IO_PCA9685.cpp b/IO_PCA9685.cpp index 009ff63..8270509 100644 --- a/IO_PCA9685.cpp +++ b/IO_PCA9685.cpp @@ -139,11 +139,11 @@ void PCA9685::_write(VPIN vpin, int value) { // 4 (Bounce) Servo 'bounces' at extremes. // void PCA9685::_writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) { - if (_deviceState == DEVSTATE_FAILED) return; #ifdef DIAG_IO - DIAG(F("PCA9685 WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d"), - vpin, value, profile, duration); + DIAG(F("PCA9685 WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d %S"), + vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F("")); #endif + if (_deviceState == DEVSTATE_FAILED) return; int pin = vpin - _firstVpin; if (value > 4095) value = 4095; else if (value < 0) value = 0;