DCC Companion
A Model Train DCC Accessory
‘by Martin & Ryan Wade
We are using MRC Wireless Prodigy Advanced Square control system. We have been very happy with the control system. We have added Switchit 8 Stationary Decoders with Tortoise Switch Machines. From there we have been developing our own additions which we call the DCC Companion. This device was built as a companion to the MRC Prodigy Advanced² DCC Model Train controller. The Prodigy Controller handles all the handheld controllers and track DCC signal. The DCC Companion will handle a variety of DCC Accessory functions and interfaces with a PC for direct control and feedback. The hardware interface was built around the Parallax Propeller Microcontroller. See below and attachments for capability, progress, and future development of this system.
Contents
|
Primary Design Goals:
DCC Companion Software
- MRC Prodigy Cab Bus: The DCC Companion would connect to the Prodigy Cab Bus using the MRC Prodigy Computer Wireless Interface.
- DCC Track Bus and I/O Bus: The Master Interface will detect and decode all signals on the Track Bus. It will pass back commands on a simple USB Serial port to the PC. The Master Interface will also control a separate I/O bus using I²C networking. This will allow full Input and Output control from both the Track Bus commands and the PC.
- Master Interface I/O Configuration: The configuration screen would match up each Object (Input, Output, Switch) with devices attached through the I²C network.
- I/O Control: The computer would show the status of each Input, Output, and Switch Object as a list. The display would allow control of each object. Switch Command will be sent through the Cab bus but separate I/O commands will be through the I/O bus (via the USB serial port).
- Graphical Layout control: The train layout would be shown on the screen allowing the user to click on the graphic to control the I/O objects.
- Automated control: An Automation table with Cab Bus commands (switches and locos) combined with input logic (switches and block detection) will allow automation of trains on the main line. These will be tied to logic definitions as well as the Cab Bus Fast Clock from the Prodigy System.
DCC Companion Hardware
- Master Interface: The Master Interface will be designed around the Parallax Propeller Microcontroller. This controller utilizes a common memory with 8 Processors. This will allow running the serial port to PC, I²C network for the I/O bus, Track bus detection and decoding. It will also use the I²C EEPROM for storage of configuration and current settings to retain operations during power loss.
- Stationary DCC Decoder Interface: A 16bit I/O Expander will be used to map 16 I/O ports onto the I²C network. Each Interface can map to 1 of 8 addresses on the same I²C network. This allows 128 I/O objects per network. Current plans will be to run up to 4 networks which results in 512 I/O objects. Each expander will separate the 16 I/O pins into 4 groups. Each group can use an add on interface for specific connections to Tortoise Switch Machines, general outputs, and general inputs.
Progress and Next Steps:
DCC Companion Software
- Version 1:�
- PC interface for Propeller to display and control Switch status. Visual Basic program has been developed to display stationary decoder values and allow their control through the PC. Since the Prodigy system is a 1 way controller for Stationary Decoders (no read back) the switch control can come from either the Prodigy system or the Visual Basic Program.
- Version 2:�
- MRC Wireless DCC Computer Interface was installed with MRC software. Using a serial port monitor we have decoded the communication protocol and are now working on the command protocol (Excel summary: Prodigy Advanced Command Syntax). Also, we used a digital logic analyzer on the cab bus to investigate protocol timing. Here is a summary of what we found: Prodigy Advanced Communication Documentation). Progress so far allows control of switches, Loco speed (128step mode), Loco Direction, and Function F1 and F2. These functions have been coded into a new Visual Basic program with a Virtual Cab Controller with those functions decoded so far.
- Additionally, a built in Terminal monitor has been added which shows all commands from any attached (wired or wireless) cabs on the MRC system. So now we can simply run commands on any cab and monitor the command codes on the bus. This will aid in further command decoding.
- The serial interface to the Propeller has been added back into the new Version 2. Since switches will now be controlled on the Cab Bus this has been removed. The communication protocol has been defined for this custom bus from the PC to the Master Interface (Propeller). It will use 3 Command Bytes and 1 Checksum byte. This basic communication code has been completed. Each individual command will simply be added to the basic communication structure.
- Configuration Arrays for Input, Output, and Switches have been defined. Coding to pass these arrays from the Master Interface to the PC are under construction. These arrays will be changed/updated in the DCC Companion Software but will reside in the Master Interface to allow stand alone operation with the PC disconnected.
- The entire GUI has been setup into Tabs. Under construction are the routines to turn off appropriate tabs when you are not using one side of the communications. This was actually working until we kept adding things and breaking what we had written. We currently have all the tabs on until we get to a more stable environment.
DCC Companion Hardware
- Master Interface�
- DCC Track Bus Detection and Decoding: Using minimal circuitry, the Propeller Microcontroller, and programming in Spin and Assembly we can correctly decode the Track Bus signals. One Cog detects the DCC track signal and translates into the standard DCC commands. These commands are passed to a second Cog for interpretation. Both Mobile (some modes) and Station Decoder commands are presently decoded. Presently only the stationary Decoder commands are utilized. The Prodigy system can control 255 separate stationary decoders and all of these are presently decoded correctly.
- LCD Display: A 3 line by 16 Character LCD has been added to the Propeller Proto Board. It is programmed to show current status of power up sequence and switch decoding for operational and debugging feedback.
- Save Current Stationary Decoder Values. The Serial EEprom is used to save the current Stationary Decoder values when changed. When repowering the system they are retrieved allowing all switches to return to their previous state. Under Construction is the routines to save the Configuration arrays.
- PC USB Serial Bus: The communication protocol is run in another cog and uses the built in USB Serial port on the Propeller Proto board. The core communication coding has been completed for the newly defined command structure.
- Stationary Decoder Interface:
- Version 1: Hardware interface for direct connect of 8 Switches to the Master Interface is completed and fully functional. This board takes the digital Propeller output (1 pin per switch) and uses it to drive the 15v needed to drive standard Model Train slow motion switch machines. This circuit was designed around the Tortoise Slow Motion Switch machine which has low drive current and low stall current for holding the switch in place. This is based on an H-bridge design with quad op amp ICs. While this board is functional it is going to be redesigned into 4 switch groups as add on boards to the network I/O board.
- The MCP23017 16 bit I/O Expander IC has been breadboarded with inputs and outputs. I²C routines have been complete to read and configure the I/O. From this model we have defined the plans for a new Interface hardware board with 4 groups of 4 I/Os onto one board. Each group will then either use a direct connect or a daughter board for final interface to the dedicated function.
- Next Steps: Finalize Design and Build of Version 2 of interface with 16 bit I/O Expander and interface daughter cards.
I am considering ‘reverse engineering’ the Prodigy Advance 2 command protocol, to allow automatic control of locos via a visual basic program running on a PC. Is there any chance you can publish the commands you have found to save me a lot of hassle? I have to admit the usb interface protocol (used with the MRC/Guagemaster CAB) is far more complex than the RS232 interfaces I have analysed in the past. Also as a suggestion have you considered using Industrial Programmable Logic Controllers (PLC’s) as an i/o interface? They can be used as i/o devices for the PC, but they are easy to network (reducing wiring as they can be distributed around the layout) and can be programmed to carry out automatic sequences independent of the PC.
All the best
Tim Bailey
I got a prodigy advanced today with the thought that any major dcc system was pc controllable through jmri and such. Wow was I wrong. LOL for the last week I have been working on controller/multi-zone booster on amtel based chips. Just about to switch over to chips with built in can transceivers. I will still work at that goal.