From 3d7a9500cfba08cc27f4211bbbeecb1b822612ac Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 3 Jul 2020 00:19:59 +0200 Subject: [PATCH 1/9] First test on Uno --- CVReader.ino | 13 +++++++++---- Config.h | 5 ++--- DCCEXParser.cpp | 4 ++++ Hardware.cpp | 6 +++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CVReader.ino b/CVReader.ino index 9ba6724..9b2edd8 100644 --- a/CVReader.ino +++ b/CVReader.ino @@ -22,10 +22,10 @@ void myFilter(Print & stream, byte & opcode, byte & paramCount, int p[]) { DCC::setFn(p[0],p[1],p[2]==1); opcode=0; // tell parser to ignore this command break; - case '#': // Diagnose parser <#....> - DIAG(F("# paramCount=%d\n"),paramCount); + case '$': // Diagnose parser <$....> + DIAG(F("$ paramCount=%d\n"),paramCount); for (int i=0;i + StringFormatter::send(stream,F("<# %d>"), MAX_LOCOS); + return; default: //anything else will drop out to break; diff --git a/Hardware.cpp b/Hardware.cpp index e9eb218..04bf3d5 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -40,14 +40,14 @@ void Hardware::setSignal(bool isMainTrack, bool high) { } int Hardware::getCurrentMilliamps(bool isMainTrack) { - int pin = isMainTrack ? MAIN_SENSE_PIN : PROG_SENSE_PIN; + byte pin = isMainTrack ? MAIN_SENSE_PIN : PROG_SENSE_PIN; float factor = isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR; - + // IMPORTANT: This function can be called in Interrupt() time within the 56uS timer // The default analogRead takes ~100uS which is catastrphic // so analogReadFast is used here. (-2uS) int rawCurrent = analogReadFast(pin); - + return (int)(rawCurrent * factor); } From 0c9b2d962bcfa30fd6f1f9497ec0615c521f8eeb Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 3 Jul 2020 16:03:10 +0200 Subject: [PATCH 2/9] Correct place for checkAck() so ack pulse lenth is correct --- DCCWaveform.cpp | 14 +++++--------- DCCWaveform.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index f9e45b5..c696575 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -135,8 +135,9 @@ bool DCCWaveform::interrupt1() { state = 0; break; } + // ACK check is prog track only + if (ackPending) checkAck(); return false; - } @@ -185,11 +186,6 @@ void DCCWaveform::interrupt2() { } } } - - // ACK check is prog track only and will only be checked if bits_sent=4 ... - // This means only once per 9-bit-byte AND never at the same cycle as the - // relatively expensive packet change code just above. - if (ackPending && bits_sent==4) checkAck(); } @@ -265,13 +261,13 @@ void DCCWaveform::checkAck() { // detected trailing edge of pulse ackPulseDuration=micros()-ackPulseStart; - - if (ackPulseDuration>1000 && ackPulseDuration<9000) { + + if (ackPulseDuration>3000 && ackPulseDuration<8500) { ackCheckDuration=millis()-ackCheckStart; ackDetected=true; ackPending=false; transmitRepeats=0; // shortcut remaining repeat packets return; // we have a genuine ACK result - } + } ackPulseStart=0; // We have detected a too-short or too-long pulse so ignore and wait for next leading edge } diff --git a/DCCWaveform.h b/DCCWaveform.h index 5c6cd15..fff524d 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -2,7 +2,7 @@ #define DCCWaveform_h -const int POWER_SAMPLE_MAX = 300; +const int POWER_SAMPLE_MAX = 1000; // XXX only until correct short detection on prog rail is implemented const int POWER_SAMPLE_ON_WAIT = 100; const int POWER_SAMPLE_OFF_WAIT = 1000; const int POWER_SAMPLE_OVERLOAD_WAIT = 4000; From cecbc62e730bae7a9a6da47dc3d9dd62cde9caf5 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 4 Jul 2020 21:32:21 +0200 Subject: [PATCH 3/9] Sense factor corr --- Config.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Config.h b/Config.h index d690ad7..6e517f3 100644 --- a/Config.h +++ b/Config.h @@ -8,10 +8,9 @@ const byte MAIN_SIGNAL_PIN = 12; const byte MAIN_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins const byte MAIN_SENSE_PIN = A0; const byte MAIN_BRAKE_PIN = 9; -const float MAIN_SENSE_FACTOR=1.717; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps const int MAIN_MAX_MILLIAMPS=2000; -const float MAIN_SENSE_FACTOR=2.99; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps +const float MAIN_SENSE_FACTOR=1.717; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps const byte PROG_POWER_PIN = 11; const byte PROG_SIGNAL_PIN = 13; From ac3c8661a621a882abf070ebf559d4fff8a0f008 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 4 Jul 2020 21:40:08 +0200 Subject: [PATCH 4/9] more merge --- DCCWaveform.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 0613eee..9c81d61 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -211,11 +211,7 @@ void DCCWaveform::interrupt2() { if (sentResetsSincePacket<250) sentResetsSincePacket++; } } -<<<<<<< HEAD - } -======= } ->>>>>>> master } @@ -292,13 +288,8 @@ void DCCWaveform::checkAck() { // detected trailing edge of pulse ackPulseDuration=micros()-ackPulseStart; -<<<<<<< HEAD - - if (ackPulseDuration>3000 && ackPulseDuration<8500) { -======= if (ackPulseDuration>=MIN_ACK_PULSE_DURATION && ackPulseDuration<=MAX_ACK_PULSE_DURATION) { ->>>>>>> master ackCheckDuration=millis()-ackCheckStart; ackDetected=true; ackPending=false; From e244de7835928a4f9a61ceb821af3a9292d05467 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 4 Jul 2020 21:44:36 +0200 Subject: [PATCH 5/9] more merge --- DCCWaveform.cpp | 3 ++- Hardware.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 9c81d61..f0045ee 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -164,6 +164,7 @@ bool DCCWaveform::interrupt1() { if (ackPending) checkAck(); return false; + } @@ -295,6 +296,6 @@ void DCCWaveform::checkAck() { ackPending=false; transmitRepeats=0; // shortcut remaining repeat packets return; // we have a genuine ACK result - } + } ackPulseStart=0; // We have detected a too-short or too-long pulse so ignore and wait for next leading edge } diff --git a/Hardware.cpp b/Hardware.cpp index 336baeb..dc5b323 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -65,6 +65,10 @@ int Hardware::getCurrentRaw(bool isMainTrack) { } +unsigned int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) { + return (int)(raw * (isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR)); +} + void Hardware::setCallback(int duration, void (*isr)()) { Timer1.initialize(duration); // We don't want the timer to set pins because these often clash with motor shields etc. From 9d9c6edc2fab9e600492db7cda8f48c98568e9ca Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 10 Jul 2020 01:03:47 +0200 Subject: [PATCH 6/9] Pololu on Mega seems OK --- Config.h | 18 +++++++++++------- DCCWaveform.cpp | 1 + Hardware.cpp | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Config.h b/Config.h index aaf1d9e..597eff4 100644 --- a/Config.h +++ b/Config.h @@ -3,19 +3,23 @@ // This hardware configuration would normally be setup using a bunch of #ifdefs. -const byte MAIN_POWER_PIN = 3; -const byte MAIN_SIGNAL_PIN = 12; +const byte MAIN_POWER_PIN = 4; +const byte MAIN_SIGNAL_PIN = 7; const byte MAIN_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins const byte MAIN_SENSE_PIN = A0; const byte MAIN_BRAKE_PIN = 9; -const float MAIN_SENSE_FACTOR=1.717; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps -const byte PROG_POWER_PIN = 11; -const byte PROG_SIGNAL_PIN = 13; +const int MAIN_MAX_MILLIAMPS=2000; +const float MAIN_SENSE_FACTOR=18; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps + +const byte PROG_POWER_PIN = 2; +const byte PROG_SIGNAL_PIN = 8; const byte PROG_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins const byte PROG_SENSE_PIN = A1; -const byte PROG_BRAKE_PIN = 8; -const float PROG_SENSE_FACTOR=1.717; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps +const byte PROG_BRAKE_PIN = 10; + +const int PROG_MAX_MILLIAMPS=250; +const float PROG_SENSE_FACTOR=18; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps // Allocations with memory implications..! // Base system takes approx 900 bytes + 8 per loco. Turnouts, Sensors etc are dynamically created diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index c696575..e162555 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -73,6 +73,7 @@ POWERMODE DCCWaveform::getPowerMode() { void DCCWaveform::setPowerMode(POWERMODE mode) { powerMode = mode; Hardware::setPower(isMainTrack, mode == POWERMODE::ON); + Hardware::setBrake(isMainTrack, mode == POWERMODE::OFF); if (mode == POWERMODE::ON) delay(200); } diff --git a/Hardware.cpp b/Hardware.cpp index 04bf3d5..6bd189d 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -15,11 +15,13 @@ void Hardware::init() { pinMode(MAIN_POWER_PIN, OUTPUT); + pinMode(MAIN_BRAKE_PIN, OUTPUT); pinMode(MAIN_SIGNAL_PIN, OUTPUT); if (MAIN_SIGNAL_PIN_ALT) pinMode(MAIN_SIGNAL_PIN_ALT, OUTPUT); pinMode(MAIN_SENSE_PIN, INPUT); pinMode(PROG_POWER_PIN, OUTPUT); + pinMode(PROG_BRAKE_PIN, OUTPUT); pinMode(PROG_SIGNAL_PIN, OUTPUT); if (PROG_SIGNAL_PIN_ALT) pinMode(PROG_SIGNAL_PIN_ALT, OUTPUT); pinMode(PROG_SENSE_PIN, INPUT); From 0583fac41670611540a99abf2d10ae1440e966e1 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 12 Jul 2020 01:36:56 +0200 Subject: [PATCH 7/9] Expotential overcurrent handling #1 --- Config.h | 8 ++++++-- DCCEXParser.cpp | 4 ++-- DCCWaveform.cpp | 22 ++++++++++++++++------ DCCWaveform.h | 4 +++- Hardware.cpp | 14 +++++++++++--- StringFormatter.cpp | 1 + 6 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Config.h b/Config.h index 597eff4..199ae3c 100644 --- a/Config.h +++ b/Config.h @@ -3,20 +3,24 @@ // This hardware configuration would normally be setup using a bunch of #ifdefs. +const byte UNUSED_PIN = 255; + const byte MAIN_POWER_PIN = 4; const byte MAIN_SIGNAL_PIN = 7; -const byte MAIN_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins +const byte MAIN_SIGNAL_PIN_ALT = UNUSED_PIN; // for hardware that flipflops signal pins const byte MAIN_SENSE_PIN = A0; const byte MAIN_BRAKE_PIN = 9; +const byte MAIN_FAULT_PIN = 12; const int MAIN_MAX_MILLIAMPS=2000; const float MAIN_SENSE_FACTOR=18; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps const byte PROG_POWER_PIN = 2; const byte PROG_SIGNAL_PIN = 8; -const byte PROG_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins +const byte PROG_SIGNAL_PIN_ALT = UNUSED_PIN; // for hardware that flipflops signal pins const byte PROG_SENSE_PIN = A1; const byte PROG_BRAKE_PIN = 10; +const byte PROG_FAULT_PIN = UNUSED_PIN; const int PROG_MAX_MILLIAMPS=250; const float PROG_SENSE_FACTOR=18; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index f96cec8..584de3f 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -114,9 +114,9 @@ void DCCEXParser::parse(Print & stream, const byte *com, bool banAsync) { asyncBanned=banAsync; (void) EEPROM; // tell compiler not to warn thi is unused int p[MAX_PARAMS]; - byte params=splitValues(p, com); - if (com[0]=='<') com++; + while (com[0]=='<' || com[0]==' ') com++; // strip off any number of < or spaces + byte params=splitValues(p, com); byte opcode=com[0]; if (filterCallback) filterCallback(stream,opcode,params,p); diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index e162555..6d4a8d2 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -72,8 +72,9 @@ POWERMODE DCCWaveform::getPowerMode() { void DCCWaveform::setPowerMode(POWERMODE mode) { powerMode = mode; - Hardware::setPower(isMainTrack, mode == POWERMODE::ON); - Hardware::setBrake(isMainTrack, mode == POWERMODE::OFF); + bool ison = (mode == POWERMODE::ON); + Hardware::setPower(isMainTrack, ison); + Hardware::setBrake(isMainTrack, !ison); if (mode == POWERMODE::ON) delay(200); } @@ -89,11 +90,20 @@ void DCCWaveform::checkPowerOverload() { case POWERMODE::ON: // Check current lastCurrent = Hardware::getCurrentMilliamps(isMainTrack); - if (lastCurrent < POWER_SAMPLE_MAX) sampleDelay = POWER_SAMPLE_ON_WAIT; - else { + if (lastCurrent < POWER_SAMPLE_MAX) { + sampleDelay = POWER_SAMPLE_ON_WAIT; + if(power_good_counter<100) { + power_good_counter++; + } else { + if (power_sample_overload_wait>POWER_SAMPLE_OVERLOAD_WAIT) + power_sample_overload_wait=POWER_SAMPLE_OVERLOAD_WAIT; + } + } else { setPowerMode(POWERMODE::OVERLOAD); - DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d ***\n"), isMainTrack ? F("MAIN") : F("PROG"), lastCurrent, POWER_SAMPLE_MAX); - sampleDelay = POWER_SAMPLE_OVERLOAD_WAIT; + DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d offtime=%l ***\n"), isMainTrack ? F("MAIN") : F("PROG"), lastCurrent, POWER_SAMPLE_MAX, power_sample_overload_wait); + power_good_counter=0; + sampleDelay = power_sample_overload_wait; + power_sample_overload_wait *= 4; } break; case POWERMODE::OVERLOAD: diff --git a/DCCWaveform.h b/DCCWaveform.h index fff524d..0cfb3c8 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -5,7 +5,7 @@ const int POWER_SAMPLE_MAX = 1000; // XXX only until correct short detection on prog rail is implemented const int POWER_SAMPLE_ON_WAIT = 100; const int POWER_SAMPLE_OFF_WAIT = 1000; -const int POWER_SAMPLE_OVERLOAD_WAIT = 4000; +const int POWER_SAMPLE_OVERLOAD_WAIT = 20; // ACK current analogRead values (vary depending on motor shield and cpu voltage) @@ -78,6 +78,8 @@ class DCCWaveform { POWERMODE powerMode; unsigned long lastSampleTaken; unsigned int sampleDelay; + unsigned long power_sample_overload_wait = POWER_SAMPLE_OVERLOAD_WAIT; + unsigned int power_good_counter = 0; // ACK management (Prog track only) bool ackPending; diff --git a/Hardware.cpp b/Hardware.cpp index 6bd189d..df33262 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -17,14 +17,16 @@ void Hardware::init() { pinMode(MAIN_POWER_PIN, OUTPUT); pinMode(MAIN_BRAKE_PIN, OUTPUT); pinMode(MAIN_SIGNAL_PIN, OUTPUT); - if (MAIN_SIGNAL_PIN_ALT) pinMode(MAIN_SIGNAL_PIN_ALT, OUTPUT); + if (MAIN_SIGNAL_PIN_ALT != UNUSED_PIN) pinMode(MAIN_SIGNAL_PIN_ALT, OUTPUT); pinMode(MAIN_SENSE_PIN, INPUT); + if (MAIN_FAULT_PIN != UNUSED_PIN) pinMode(MAIN_FAULT_PIN, INPUT); pinMode(PROG_POWER_PIN, OUTPUT); pinMode(PROG_BRAKE_PIN, OUTPUT); pinMode(PROG_SIGNAL_PIN, OUTPUT); - if (PROG_SIGNAL_PIN_ALT) pinMode(PROG_SIGNAL_PIN_ALT, OUTPUT); + if (PROG_SIGNAL_PIN_ALT != UNUSED_PIN) pinMode(PROG_SIGNAL_PIN_ALT, OUTPUT); pinMode(PROG_SENSE_PIN, INPUT); + if (PROG_FAULT_PIN != UNUSED_PIN) pinMode(PROG_FAULT_PIN, INPUT); } void Hardware::setPower(bool isMainTrack, bool on) { @@ -38,13 +40,19 @@ void Hardware::setSignal(bool isMainTrack, bool high) { byte pin = isMainTrack ? MAIN_SIGNAL_PIN : PROG_SIGNAL_PIN; byte pin2 = isMainTrack ? MAIN_SIGNAL_PIN_ALT : PROG_SIGNAL_PIN_ALT; WritePin(pin, high ? HIGH : LOW); - if (pin2) WritePin(pin2, high ? LOW : HIGH); + if (pin2 != UNUSED_PIN) WritePin(pin2, high ? LOW : HIGH); } int Hardware::getCurrentMilliamps(bool isMainTrack) { byte pin = isMainTrack ? MAIN_SENSE_PIN : PROG_SENSE_PIN; float factor = isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR; + // tooo much crap for a interrupt routine. Will see how that goes. + byte faultpin = isMainTrack ? MAIN_FAULT_PIN : PROG_FAULT_PIN; + byte signalpin = isMainTrack ? MAIN_SIGNAL_PIN : PROG_SIGNAL_PIN; + + if (faultpin != UNUSED_PIN && digitalRead(faultpin) == LOW && digitalRead(signalpin) == HIGH) + return 6666; // IMPORTANT: This function can be called in Interrupt() time within the 56uS timer // The default analogRead takes ~100uS which is catastrphic // so analogReadFast is used here. (-2uS) diff --git a/StringFormatter.cpp b/StringFormatter.cpp index cab55b5..4fc1330 100644 --- a/StringFormatter.cpp +++ b/StringFormatter.cpp @@ -31,6 +31,7 @@ void StringFormatter::send2(Print & stream,const __FlashStringHelper* format, va case 's': stream.print(va_arg(args, char*)); break; case 'S': stream.print((const __FlashStringHelper*)va_arg(args, char*)); break; case 'd': stream.print(va_arg(args, int), DEC); break; + case 'l': stream.print(va_arg(args, long), DEC); break; case 'b': stream.print(va_arg(args, int), BIN); break; case 'o': stream.print(va_arg(args, int), OCT); break; case 'x': stream.print(va_arg(args, int), HEX); break; From 22d4fcf3b8562efa1009c69173ab1bde5997d859 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 12 Jul 2020 16:03:22 +0200 Subject: [PATCH 8/9] more ifdefs --- CVReader.ino | 8 +++++++- Config.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CVReader.ino b/CVReader.ino index 57f69cd..6ae7f53 100644 --- a/CVReader.ino +++ b/CVReader.ino @@ -71,8 +71,14 @@ DCCEXParser serialParser; // Try monitoring the memory #include "freeMemory.h" -//int minMemory=32767; +// TODO: this should be automated instead of ifdef +#if defined(ARDUINO_AVR_MEGA2560) +int minMemory=32767; +#elif defined(ARDUINO_AVR_UNO) int minMemory=2048; +#else +#error CANNOT COMPILE - Unkown board, can not determine amount of RAM available. +#endif void setup() { diff --git a/Config.h b/Config.h index 6e517f3..3018210 100644 --- a/Config.h +++ b/Config.h @@ -1,6 +1,9 @@ #ifndef Config_h #define Config_h +// Define this if you have a WiFi board on Serial1 +// #define WIFI + // This hardware configuration would normally be setup using a bunch of #ifdefs. const byte MAIN_POWER_PIN = 3; From 0d0f591d2970b4f29f7c07d7c2c14c10fd2bc47b Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 12 Jul 2020 16:38:06 +0200 Subject: [PATCH 9/9] revert Config.h to standard --- Config.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Config.h b/Config.h index f0eb70d..e827f06 100644 --- a/Config.h +++ b/Config.h @@ -8,25 +8,25 @@ const byte UNUSED_PIN = 255; -const byte MAIN_POWER_PIN = 4; -const byte MAIN_SIGNAL_PIN = 7; +const byte MAIN_POWER_PIN = 3; +const byte MAIN_SIGNAL_PIN = 12; const byte MAIN_SIGNAL_PIN_ALT = UNUSED_PIN; // for hardware that flipflops signal pins const byte MAIN_SENSE_PIN = A0; const byte MAIN_BRAKE_PIN = 9; -const byte MAIN_FAULT_PIN = 12; +const byte MAIN_FAULT_PIN = UNUSED_PIN; const int MAIN_MAX_MILLIAMPS=2000; -const float MAIN_SENSE_FACTOR=18; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps +const float MAIN_SENSE_FACTOR=2.99; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps -const byte PROG_POWER_PIN = 2; -const byte PROG_SIGNAL_PIN = 8; +const byte PROG_POWER_PIN = 11; +const byte PROG_SIGNAL_PIN = 13; const byte PROG_SIGNAL_PIN_ALT = UNUSED_PIN; // for hardware that flipflops signal pins const byte PROG_SENSE_PIN = A1; -const byte PROG_BRAKE_PIN = 10; +const byte PROG_BRAKE_PIN = 8; const byte PROG_FAULT_PIN = UNUSED_PIN; const int PROG_MAX_MILLIAMPS=250; -const float PROG_SENSE_FACTOR=18; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps +const float PROG_SENSE_FACTOR=2.99; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps // Allocations with memory implications..! // Base system takes approx 900 bytes + 8 per loco. Turnouts, Sensors etc are dynamically created