From f0c1ea958cc9c22cc28b430e4dcdca8d85f128bf Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 2 Mar 2023 10:45:39 +0000 Subject: [PATCH 1/3] 4.2.19 sensorOffset bugfix --- MotorDriver.cpp | 15 ++++++++++----- version.h | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/MotorDriver.cpp b/MotorDriver.cpp index 763e5a3..a6a1766 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -90,9 +90,8 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i else brakePin=UNUSED_PIN; currentPin=current_pin; - if (currentPin!=UNUSED_PIN) { - senseOffset = ADCee::init(currentPin); - } + if (currentPin!=UNUSED_PIN) ADCee::init(currentPin); + senseOffset=0; // value can not be obtained until waveform is activated faultPin=fault_pin; if (faultPin != UNUSED_PIN) { @@ -121,8 +120,8 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i if (currentPin==UNUSED_PIN) DIAG(F("** WARNING ** No current or short detection")); else { - DIAG(F("CurrentPin=A%d, Offset=%d, TripValue=%d"), - currentPin-A0, senseOffset,rawCurrentTripValue); + DIAG(F("CurrentPin=A%d, TripValue=%d"), + currentPin-A0, rawCurrentTripValue); // self testing diagnostic for the non-float converters... may be removed when happy // DIAG(F("senseFactorInternal=%d raw2mA(1000)=%d mA2Raw(1000)=%d"), @@ -144,6 +143,12 @@ bool MotorDriver::isPWMCapable() { void MotorDriver::setPower(POWERMODE mode) { bool on=mode==POWERMODE::ON; if (on) { + // when switching a track On, we need to check the crrentOffset with the pin OFF + if (powerMode==POWERMODE::OFF && currentPin!=UNUSED_PIN) { + senseOffset = ADCee::read(currentPin); + DIAG(F("CurrentPin A%d sensOffset=%d"),currentPin-A0,senseOffset); + } + IODevice::write(powerPin,invertPower ? LOW : HIGH); if (isProgTrack) DCCWaveform::progTrack.clearResets(); diff --git a/version.h b/version.h index f846e0d..d621edf 100644 --- a/version.h +++ b/version.h @@ -4,7 +4,8 @@ #include "StringFormatter.h" -#define VERSION "4.2.18" +#define VERSION "4.2.19" +// 4.2.19 - Bugfix for analog reading of track current sensor offeset. // 4.2.18 - I2C Multiplexer support through Extended Addresses, // added for Wire, 4209 and AVR I2C drivers. // - I2C retries when an operation fails. From b969563d355de74181ab4b1a0854a807980bcaa4 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 2 Mar 2023 12:56:30 +0000 Subject: [PATCH 2/3] Squashed commit of the following: commit 4d8efcdd056a021023b8c7d7942a05e8530adafe Author: Asbelos Date: Wed Mar 1 16:32:05 2023 +0000 Reinstate obsolete commit 003313998b3708b0b845d88a985d8515834cbe2f Author: Asbelos Date: Wed Mar 1 16:07:11 2023 +0000 Change to commit c72bf51959d77356ba0b1eb6be83b790439ce779 Author: Asbelos Date: Sat Feb 25 17:38:39 2023 +0000 G and I commands --- DCCEXParser.cpp | 18 +++- Release_Notes/CommandRef.md | 171 ++++++++++++++++++++++++++++++++++++ TrackManager.cpp | 30 ++++++- TrackManager.h | 3 + 4 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 Release_Notes/CommandRef.md diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index bcc25d7..9e2cf5f 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -79,6 +79,8 @@ const int16_t HASH_KEYWORD_TT=2688; const int16_t HASH_KEYWORD_VPIN=-415; const int16_t HASH_KEYWORD_A='A'; const int16_t HASH_KEYWORD_C='C'; +const int16_t HASH_KEYWORD_G='G'; +const int16_t HASH_KEYWORD_I='I'; const int16_t HASH_KEYWORD_R='R'; const int16_t HASH_KEYWORD_T='T'; const int16_t HASH_KEYWORD_X='X'; @@ -501,8 +503,10 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) return; case 'c': // SEND METER RESPONSES - // No longer supported because of multiple tracks - break; + // No longer useful because of multiple tracks See and + if (params>0) break; + TrackManager::reportObsoleteCurrent(stream); + return; case 'Q': // SENSORS Sensor::printAll(stream); @@ -583,6 +587,16 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) } CommandDistributor::setClockTime(p[1], p[2], 1); return; + + case HASH_KEYWORD_G: // current gauge limits + if (params>1) break; + TrackManager::reportGauges(stream); // + return; + + case HASH_KEYWORD_I: // current values + if (params>1) break; + TrackManager::reportCurrent(stream); // + return; case HASH_KEYWORD_A: // returns automations/routes StringFormatter::send(stream, F(" is actually read as + - Keyword parameters are shown in upper case but may be entered in mixed case. + - value parameters are numeric. + - [something] indicates its optional. + - Not all commands have a response, and not all responses come from the last commands that you have issued. + +Startup status + + +Track power management +<1> +<1 MAIN|PROG|JOIN> +<0> +<0 MAIN|PROG> + +Basic manual control + + + + + +DCC accessory control + + + + +Turnout definition +Note: Turnouts are best defined in myAutomation.h where a turnout description can also be provided ( refer to EXRAIL documentation) or by using these commands in a mySetup.h file. + + + + + + + +Outputs + + + +Sensors + + +Decoder programming + + + + + + + + + + + + + +Advanced DCC control + +

+ +<#> +<-> +<- cabid> + + + + + +EEPROM commands +These commands exist for +backwards JMRI compatibility. +You are strongly discouraged from maintaining your configuration settings in EEPROM. + + + + + + + + + + +Diagnostic commands + + + + + + + + + + + +<+ cmd> +<+> + + +User defined filter commands + + + +Track Management +<=> +<= track DCC|PROG|OFF> +<= track DC|DCX cabid> + + + + +Turntable interface + + +Fast clock interface + + + + +Advanced Throttle access to features + + + + + + + + +******************* +EXRAIL Commands +******************* + + + + + + + + + + + + +Obsolete commands/formats + + + + + + + + +Broadcast responses +Note: broadcasts are sent to all throttles when appropriate (usually because something has changed) + + + + + + + + + +Diagnostic responses +These are not meant to be software readable. They contain diagnostic information for programmers to identify issues. + +<* ... *> + diff --git a/TrackManager.cpp b/TrackManager.cpp index cbb672a..33d1d8a 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -423,7 +423,35 @@ POWERMODE TrackManager::getProgPower() { return track[t]->getPower(); return POWERMODE::OFF; } - + +void TrackManager::reportObsoleteCurrent(Print* stream) { + // This function is for backward JMRI compatibility only + // It reports the first track only, as main, regardless of track settings. + // + int maxCurrent=track[0]->raw2mA(track[0]->getRawCurrentTripValue()); + StringFormatter::send(stream, F("\n"), + track[0]->raw2mA(track[0]->getCurrentRaw(false)), maxCurrent, maxCurrent); +} + +void TrackManager::reportCurrent(Print* stream) { + StringFormatter::send(stream,F("getPower()==POWERMODE::OVERLOAD) ? -1 : + track[t]->raw2mA(track[t]->getCurrentRaw(false))); + } + StringFormatter::send(stream,F(">\n")); +} + +void TrackManager::reportGauges(Print* stream) { + StringFormatter::send(stream,F("raw2mA(track[t]->getRawCurrentTripValue())); + } + StringFormatter::send(stream,F(">\n")); +} + void TrackManager::setJoinRelayPin(byte joinRelayPin) { joinRelay=joinRelayPin; if (joinRelay!=UNUSED_PIN) { diff --git a/TrackManager.h b/TrackManager.h index 90a9345..4a548cc 100644 --- a/TrackManager.h +++ b/TrackManager.h @@ -77,6 +77,9 @@ class TrackManager { static bool isJoined() { return progTrackSyncMain;} static void setJoinRelayPin(byte joinRelayPin); static void sampleCurrent(); + static void reportGauges(Print* stream); + static void reportCurrent(Print* stream); + static void reportObsoleteCurrent(Print* stream); static int16_t joinRelay; static bool progTrackSyncMain; // true when prog track is a siding switched to main static bool progTrackBoosted; // true when prog track is not current limited From a17a55d90402d3481a780a826963184903c7670b Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 2 Mar 2023 13:03:05 +0000 Subject: [PATCH 3/3] Implement --- version.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index d621edf..a97aaec 100644 --- a/version.h +++ b/version.h @@ -4,8 +4,10 @@ #include "StringFormatter.h" -#define VERSION "4.2.19" -// 4.2.19 - Bugfix for analog reading of track current sensor offeset. +#define VERSION "4.2.20" +// 4.2.20 - & commands for multi-track gauges +// - Reinstate but remember its a bit useless when TM involved. +// 4.2.19 - Bugfix for analog reading of track current sensor offset. // 4.2.18 - I2C Multiplexer support through Extended Addresses, // added for Wire, 4209 and AVR I2C drivers. // - I2C retries when an operation fails.