From 26b345f5218dbf0ff7ff9abd7ce322be22a57395 Mon Sep 17 00:00:00 2001 From: DccPlusPlus Date: Sun, 20 Dec 2015 12:40:18 -0500 Subject: [PATCH] Fixed bug in short-circuit detection for MEGA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The short-circuit code polled the track current every 10 “milliseconds.” But Arduino millis() is based on TIMER-0 settings which are changed in DCC++ Base Station. The actual polling was closer to every 1 millisecond. When Base Station for the Mega for updated to utilize TIMER-3 instead of TIMER-0, the millis() function now really did count milliseconds, and 10 milliseconds between each track-current sampling was too long. Changed the code so that for the Mega, the current sampling time is defined as 1 (instead of 10), representing an actual 1 millisecond as desired. --- DCCpp_Uno/CurrentMonitor.cpp | 2 +- DCCpp_Uno/CurrentMonitor.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/DCCpp_Uno/CurrentMonitor.cpp b/DCCpp_Uno/CurrentMonitor.cpp index db57bae..98ec0e7 100644 --- a/DCCpp_Uno/CurrentMonitor.cpp +++ b/DCCpp_Uno/CurrentMonitor.cpp @@ -22,7 +22,7 @@ CurrentMonitor::CurrentMonitor(int pin, char *msg){ boolean CurrentMonitor::checkTime(){ if(millis()-sampleTime