DCC++ and CMRI, A Modular Approach

Softec Dec 28, 2019

  1. Softec

    Softec TrainBoard Member

    27
    9
    6
    I have started a Modular DCC Control System that is part DCC++, CMRI and JMRI. This is kind of a “kit-bash” project where I have taken various segments of code, libraries/algorithms, hardware ideas etc. and molded them into a modular system of controls with some additional “glue” to round out each module. In terms of “modular”, I mean that in two ways, one is that each module (node in CMRI terms) is dedicated to one common function ie. power districts, turnouts, signal I/O, etc. second, all interconnections utilize modular connections, RJ45 (8p8c) standard Ethernet connectors and cable for the control bus and RJ11 (6p6c) connectors and standard telephone flat cable for connections to remote devices, turnouts, signals, etc.

    Hardware:

    JMRI: A Raspberry pi4 running JMRI is the frontend for the system.
    DCC++: An Arduino MEGA running DCC++ for train control only.
    Modules: Arduino NANO’s running CMRI for all accessory layout control.

    Modules:

    Power District Node: Four power districts per node, each capable of detecting block occupancy and provide short circuit protection utilizing Arduino NANO’s. Node 1 can be optionally configured to provide AutoReverse functionality. Current PD design is based on IBT-2’s. Current sense is utilizing Current Transformers (CT’s). Other H-Bridges are being evaluated.

    Turnout Node: Twelve servo points and twenty four turnout status pins utilizing an Arduino MEGA. This is a shield board to plug on top of the MEGA.

    General I/O Node: Sixty four digital I/O points, configurable as inputs, outputs or a combination.

    The entire project is “open source”. All schematics, printed circuit board designs, software, etc. will be freely available to everyone to use or modify as they see fit.

    I will describe each component in posts to follow.

    Dan

    This is an expansion of the thread "Modifying DCC for Multiple Power Districts" https://www.trainboard.com/highball...fying-dcc-for-multiple-power-districts.97445/
     
    Sumner likes this.
  2. vasilis

    vasilis TrainBoard Member

    110
    39
    10
    Hi Dan,

    Are this node gonna be connected to the accessories cmri bus? How it will be handled by cmri in jmri?
    IMHO the boosters need a dedicated bus and a dedicated app for monitoring-conrolling. They are not accessories, but power devices. The D. Bodnar's design has the benefit of controlling and monitoring the booster from buttons on it's board. At any time you can switch it on/off or reset it. Another benefit is that can be placed, as this is the recommended practice, near to the power district. In your design, the control is centallized and that means long runs of cables from current sensors to the arduino and involves noise.

    It seems exaggerated (shield + Mega) and costly for only 12 servos and 24 feedbacks . A mini or nano can handle 12 servos from its pins with 24 inputs from shift registers by a little bit modification the nopxor's design.
    https://www.trainboard.com/highball...-in-48-out-card-for-jmri.116454/#post-1118129
    A minor comment, the rpi4 is good as is portable and has low power consumption, but always I need a PC to connect to it as it can't display nothing or get user input from a visual app. I find it usefull only as a remote controlled device for the model railroad. For other tasks, where the interaction with it is limited to service or adjustment occasionally, is excellent.
    Every new design must survive the comparison to the other builds. I sincerely wish you good luck and I will help if I can.

    I'd be grateful if you could answer to my latest questions to you, in the thread https://www.trainboard.com/highball...ple-power-districts.97445/page-7#post-1118166
     
  3. Softec

    Softec TrainBoard Member

    27
    9
    6
    vasilis,

    I'll answer you last question first, I thought I had answered it yesterday but the post was still waiting for me to push the Post Reply button this morning, sorry.

    The answer is over on the original thread.

    Formulating the answers to your other questions now.

    Dan
     
    vasilis likes this.
  4. Softec

    Softec TrainBoard Member

    27
    9
    6
    HEAD END:

    JMRI is used to control the entire system on a Raspberry Pi4. Keyboard, mouse, two HDMI monitors, a powered USB-3 hub and an Arduino MEGA are connected to the Pi. USB to RS-485 converters are plugged into the hub for multiple RS-485/CMRI paths.

    EngineDriver is the throttle used to control the trains over WiFi, however any JMRI WiThrottle compatible device should work.

    The Arduino MEGA is running DCC++ exclusively. Its only purpose is to send DCC signals/commands to the Power District Modules. Any other DCC++ compatible Arduino could be used. MEGA Pins 12 and GND are extended through the Control Bus Cable to all Modules/Nodes.

    RS-485/CMRI is also extended through the Control Bus Cable to all Modules/Nodes.

    JMRI work is actually performed on a PC due to familiarity and abundance of other tools to aid in system development. Once complete all files will be copied to the Pi to run the layout.

    Dan
     

    Attached Files:

  5. Softec

    Softec TrainBoard Member

    27
    9
    6
    POWER DISTRICT:

    The Power District Module provides self-contained control of four blocks by a local Arduino NANO. Multiple NANO based Power Districts can be placed around the layout. The NANO will monitor current levels to provide individual block detection and short circuit protection. The raw 5v DCC signal comes from the Head End Arduino Mega DCC++ module. The Nano gathers block status and transmits it over RS-485 using the CMRI protocol to the head end Raspberry Pi4 running JMRI. JMRI displays the status and provides control to turn on/off each block and reset repeated short circuit trips. DCC++ and CMRI information will be distributed to the Nano power districts over cat5 cable loosely following the NMRA LCC Cable Specification. DC power is provided by a local 100watt power supply adjusted to 18v for track power and a 5vdc buck converter provides power to the electronics. All components are mounted on an 8.5” x 16” plywood backboard

    Components:

    PCB: The Printed Circuit Board is the heart of the Power District Node. It contains an Arduino NANO for local control of the Power District, an RS-485 Module for CMRI communications, the Control Bus connections through RJ-45 jacks, an opto-isolator circuit (6N137) for the incoming DCC++ signal, a signal inverter (74LS04) to provide the opposite side of the DCC signal to the Motor Driver, a XOR gate (74LS86) to invert the signals to the Block 1 Motor Driver for AutoReverse, the connector pins to the Motor Driver IBT-2’s, voltage divider circuits for signal connection to the Current Transformers, LED status indicators and an RJ-11 jack for I2C connection to other local modules and has a secondary function to modify settings in the NANO.

    Motor Drivers: Four BTS7960 based IBT-2 H-Bridge modules, one for each block in the Power District. Each module connects to the PCB by an 8 conductor ribbon cable. I was hoping to do block detection with the motor driver board but so far it does not appear to have the low current resolution to detect occupancy. The current monitoring function has been extremely inconsistent. The R_IS and L_IS signals rarely scale properly or even work at all. This has led me to use Current Transformers (CT’s) for both over current detection and block detection.

    Current Transformers: Small 5A to 5mA, 1000:1 CT’s are used for current monitoring. The CT’s use a voltage divider on the PCB to offset the positive and negative voltages to a 2.5v base line. Four turns of the track conductor pass through the CT. CT’s are installed on 3d printed mounts. CT circuit design is based on the following discussion.

    https://openenergymonitor.org/forum-archive/node/156.html

    The CT circuit reliably detects occupancy and trip on overcurrent. A spreadsheet is used to predict proper values for the settings. The readings are fairly linear. Detection levels start at about 1800 ohms or 10mA.

    https://www.ebay.com/itm/5A-Sensor-...364221?hash=item59410b887d:g:gnYAAOSwdjdaQhNi

    BTW, the burden resistor values indicated in the ebay listings are often wrong. They say 100ohm, the image of the resistor is 1000ohm and the ones I received are 200ohm.

    Raw readings are taken by the Arduino Analog to Digital Converter (ADC). This removes any necessity of conversion to current which requires the use of the floating point library, all values are either INT or LONG (size reduction and speed of processing increase). The NANO processes the signal to determine occupancy/trip status and will forward the status and readings to the head end Raspberry Pi over RS-485/CMRI for display.

    Status LED’s: The NANO monitors the output of the Power District (PD) CT’s and takes appropriate enable, disable action and outputs to an RGB led its status.

    LED off, Block OFF.
    Green LED, Block Power ON.
    Blue LED, Block OCCUPIED.
    Red LED, Block Overcurrent TRIPPED.
    Red Flashing LED, Block TRIPPED and LOCKED OUT

    Power Supply: The power supply provides 18vdc at 7 amps to the Power District. A 3d printed terminal box contains an IEC power receptacle with fuse and a power switch.

    DC Buck Converter: A dc to dc buck converter provides 5vdc at 3 amps to the PCB.

    Dan
     

    Attached Files:

  6. Softec

    Softec TrainBoard Member

    27
    9
    6
    Vasilis;

    I believe the Head End and Power District Module descriptions above answers your first question. I'm working on the Turnout Module (servo) description now and it should answer the second.

    Dan
     
  7. Erik84750

    Erik84750 TrainBoard Member

    345
    136
    12
    Hi Dan, would it be possible to post the schematic and .ino file for this pcb please?
    Erik
     

Share This Page