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

Exrail multiple enter/exits

This commit is contained in:
Asbelos 2024-10-23 11:58:26 +01:00
parent d25173e0b4
commit 68809fa8d5
3 changed files with 54 additions and 3 deletions

View File

@ -1364,11 +1364,11 @@ void RMFT2::killBlinkOnVpin(VPIN pin, uint16_t count) {
}
}
void RMFT2::startNonRecursiveTask(const FSH* reason, int16_t id,int pc, int16_t loco) {
void RMFT2::startNonRecursiveTask(const FSH* reason, int16_t id,int pc, uint16_t loco) {
// Check we dont already have a task running this handler
RMFT2 * task=loopTask;
while(task) {
if (task->onEventStartPosition==pc) {
if (task->onEventStartPosition==pc && task->loco==loco) {
DIAG(F("Recursive ON%S(%d)"),reason, id);
return;
}

View File

@ -202,7 +202,7 @@ class LookList {
static const FSH * getRosterFunctions(int16_t id);
static const FSH * getTurntableDescription(int16_t id);
static const FSH * getTurntablePositionDescription(int16_t turntableId, uint8_t positionId);
static void startNonRecursiveTask(const FSH* reason, int16_t id,int pc, int16_t loco=0);
static void startNonRecursiveTask(const FSH* reason, int16_t id,int pc, uint16_t loco=0);
static bool readSensor(uint16_t sensorId);
static bool isSignal(int16_t id,char rag);
static SIGNAL_DEFINITION getSignalSlot(int16_t slotno);

51
Release_Notes/Railcom.md Normal file
View File

@ -0,0 +1,51 @@
Railcom implementation notes, Chris Harlow Oct 2024
Railcom support is in 3 parts
1. Generation of the DCC waveform with a Railcom cutout.
2. Accessing the railcom feedback from a loco using hardware detectors
3. Utilising the feedback to do something useful.
DCC Waveform Railcom cutout depends on using suitable motor shields (EX8874 primarily) as the standard Arduino shield is not suitable. (Too high resistance during cutout)
The choice of track management also depends on wiring all the MAIN tracks to use the same signal and brake pins. This allows separate track power management but prevents switching a single track from MAIN to PROG or DC...
Some CPUs require very specific choice of brake pins etc to match their internal timer register architecture.
- MEGA.. The default shield setting for an EX8874 is suitable for Railcom on Channel A (MAIN)
- ESP32 .. not yet supported.
- Nucleo ... TBA
Enabling the Railcom Cutout requires a `<C RAILCOM ON>` command. This can be added to myAutomation using `PARSE("<C RAILCOM ON>")`
Reading Railcom data:
A new HAL handler has been added to process input from a 2-block railcom reader (Refer Henk) which operates as a 2 channel UART accessible over I2C. The reader(s) sit between the CS and the track and collect railcom data from locos during the cutout.
After the cutout the HAL driver reads the UARTs over I2C and passes the raw data to the CS logic for analysis.
Each 2-block reader is described in myAutomation like `HAL(I2CRailcom,10000,2,0x48)` which will assign 2 channels on i2c address 0x48 with vpin numbers 10000 and 10001. If you only use the first channel in the reader, just asign one pin instead of two.
(Implementation notes.. potentially other readers are possible with suitable HAL drivers. There are however several touch-points with the code DCC Waveform code which helps the HAL driver to understand when the data is safe to sample, and how to interpret responses when the sender is unknown. )
Making use of Railcom data
Exrail has two additional event handlers which can capture locos entering and exiting blocks. These handlers are started with the loco information already set, so for example:
```
ONBLOCKENTER(10000)
// a loco has entered block 10000
FON(0) // turn the light on
FON(1) // make a lot of noise
SPEED(20) // slow down
DONE
ONBLOCKEXIT(10000)
// a loco has left block 10000
FOFF(0) // turn the light off
FOFF(1) // stop the noise
SPEED(50) // speed up again
DONE
```
Note that the Railcom interpretation code is capable of detecting multiple locos in the same block at the same time and will create separate exrail tasks for each one.
There is however one minor loophole in the block exit logic...
If THREE or more locos are in the same block and ONE of them leaves, then ONBLOCKEXIT will not fire until
EITHER - The leaving loco enters another railcom block
OR - only ONE loco remains in the block just left.