DCC Simplicity
The key point that grabbed me was the utter simplicity – 2 boards+2 jumpers+1 download and this thing worked with the latest version of JMRI… the first time! Not bad at all Gregg! So naturally, I had to complicate my life—this was just too easy. To build your own, check out the references Dave Bodnar lists here: My Experiments with DCC++ https://forum.mrhmag.com/post/my-experiments-with-dcc-12202876 and get started yourself. Gregg Berman’s code can be found here: https://github.com/DccPlusPlus and he has a fine set of videos on Youtube.com as well. Read the material on each of his major github pages.
Now for my own adventure: First, I don’t use JMRI to run trains, other than on my workbench and test track. I really didn’t want the layout, sensors, and graphics of Gregg’s “Processing” solution either. What I did want was extensive Function control for my collection of 17 function decoders (again for bench testing). So I modified Gregg’s code for the DCCpp Controller and came up with this: dccpp_controller.zip http://www.scalemodelanimation.com/blog/dccpp_controller.zip Unzip this link and keep the entire contents of the DCCpp_Controller folder together, and run DCCpp_Controller.pde found in the folder with the Processing application loaded on your PC. This is what you will get:
DCCpp_Controller.pde Running on Processing 3.1.2
You should note that the layout display is gone, the window is smaller, the help widow fits in the smaller screen, the accessory decoder control window is relocated to fit as well as the power and quit buttons. The mobile decoder definitions have been changed so that several can access 18 Functions. If you want to change the address any of the “throttles” right click on the blue address button of the throttle you want to change, backspace over the listed address, and enter your new address. Unfortunately you cannot save the update. This version may useful to some of you, as it is to me.
The Next “Complication”
I already mentioned that I don’t usually use JMRI to run trains, nor do I want to use the dccpp_controller/Processing interface running on a PC. I also can’t stand the Accessory Control mechanism and addressing as provided – I prefer JMRI’s numbering scheme. While I could change that, I was intrigued by the utter simplicity of slapping the UNO and the Motor Shield together to make something so useful (the real utility to me is the $9 JMRI DCC interface!). Dave Bodnar’s creative external throttle was thought provoking as well. I wondered if I could take another pre-built, Arduino board -- an LCD Keypad Shield -- and use it as a standalone controller with the DCC++ code.
As you might already have guessed the answer is… yes! For those of you who have tried using multiple Arduino libraries at the same time, you might already realize that pre-built libraries sometimes contend for simultaneous access to the same hardware functions, causing problems. The same can be said for using multiple add-on boards, like the motor controller and the display board. Multiple boards can use the same pins conflicting with each other. Fortunately, some small changes can enable cooperation and provide a fairly simple solution.
I elected to use the use the larger, Arduino Mega2560 board, which will run the same sketch (program) but has more control pins. The same motor control board is used. A combination LCD Keypad board will act as the display and control for our “base station.” I wanted this to be self-sufficient—so no PC interface is supported. In fact the code I built substitutes for the PC interface and can mostly be found ing the file labeled SerialCommand.cpp.
Arduino Mega2560 Motor Shield LCD Keypad Shield V2.0
Motor Shield On Top of Arduino Mega2560 Board with Jumper
These 3 boards were picked for pin compatibility with minimal changes and minimal work. The Mega2560 and Motor Shield simply plug together with one jumper from D2 to D13 added, as per the DCC++ instructions. Please note that this specific motor shield is needed, as well as this specific LCD Keypad Shield. The SNS0, SNS1,Brake DIsable A and Brake Disable B Jumpers on the rear of the Motor Board also need to be cut. Note the small slide switch on the LCD board that turns the display backlight on and off. Some boards do this via Digital pin 10 – which is undesirable here. I put the jumper wire into the top female connector of the motor shield connecting pins D2 and D13. You can either bend out or completely cut off the corresponding male pins (2 & 13) on the bottom of the LCD Keypad Shield.
A0 Pin Removed (Cut)
A0 TO A2 Jumper Wire Installed
D2 and D13 pins of the LCD Keypad Board Bent Out Rather Than Removed (Cut)
The only other modification needed is to bend out or completely cut off the male A0 pin on the bottom of the LCD Keypad Shield, and solder a jumper from the A0 pad to the A2 pin on the top of the LCD Keypad Shield. Now plug the motor shield board into the Mega2560, and plug the LCD Keypad Shield into the motor shield board. Now you are done with the hardware!
The 3 Card Stack with a 12Volt Battery Pack and a SMA20 Decoder
You can load one of 2 sketches into your new base station/controller:
for loco/mobile/function decoder control
for accessory decoder control.
Operation is simple. Note that the buttons are labeled (left to right, top to bottom) Select, Left, Up, Down, Right, and Reset. Here’s how they work:
For Loco/Mobile/Function Decoder Control:
SELECT – will display SEL on the left side of the display and allow:
UP – will turn DCC power ON
DOWN – will turn DCC power OFF
LEFT -- will set loco direction to REVERSE
RIGHT – will set loco direction to FORWARD
LEFT -- will move the cursor to the LEFT to select the next changeable item in the display
UP – will increment the address or speed if selected, or turn a Function ON
RIGHT – will move the cursor to the RIGHT to select the next changeable item in the display
DOWN – will decrement the address or speed if selected, or turn a Function OFF
RESET – will perform a power on reset as if power had been turned OFF and then ON
Everything OFF to Start SELECT
UP UP UP to Address 3 F0 ON and Speed Up to 2 FOWARD
F0 ON and Speed Up to 2 REVERSE DCC Power OFF
Accessory Decoder Control:
SELECT – will display SEL on the left side of the display and allow:
UP – will turn DCC power ON
DOWN – will turn DCC power OFF
LEFT -- will set the accessory switch to CLOSED (CLSD – the OFF state)
UP – will increment the accessory address
RIGHT – will set the accessory switch to THROWN (THRN – the ON state)
DOWN – will decrement the address
RESET – will perform a power on reset as if power had been turned OFF and then ON
First Power On SELECT Button Pushed
Push UP for DCC Power ON UP…UP to Address 41 and RIGHT for THROWN (ON)
LEFT for CLOSED (CLSD – the OFF state)
Here are some representative sources for the boards:
R3 DC Motor New L298P Shield Driver Module 2A H-Bridge 2 way Fr Arduino UNO 2560 $4.93
Mega2560 R3 ATmega2560-16AU ATMEGA16U2 Board $9.90
LCD1602 16x2 Module LCD Keypad Shield V2.0 for Arduino $4.98
LCD 1602 Keypad Shield $7.50
UNO R3 MEGA328P ATMEGA16U2 $3,99
I understand that many modelers will approach DCC++ as a possible alternative for a commercial DCC base station, or even as a JMRI DCC hardware connection – after all, virtually all the JMRI normal capabilities should work with DCC++ including WiFi Android and iPhone throttles. So these simplistic controllers may seem out of place. However, many modelers using the 17 function decoders for Servo Switch control, or for lighting, or for layout animation could use these as a separate DCC bus and control mechanism, or as an interim control, or for testing, or for “portable” layouts and test tracks for clinics and shows. The power for my modules pictured was an 8 cell AA battery pack supplying 12 volts for DC power for everything. 12 Volt DC wall worts and small power supplies should work well too. Unless you follow the directions for modifying the motor control board, do NOT use more than a 12 volt power supply for your project. This article is not meant to be a substitute for the good work of Gregg, Dave and many others who have shown DCC++ to be viable. I had hoped with this short note to demonstrate the simplicity with which any modeler could put these together. While I consider these to be somewhat crude alternatives, you can put them together in very short order and get another modeling tool up and running.
Construction notes: There are variations of these boards out in the marketplace that I am aware that are of poor quality, and/or have production variations that make cause you trouble—take care. The references I listed I have used successfully. Even so, I have found the switches on some of the LCD Keypad board to be of dubious quality—they work… most of the time! Those modelers that have gotten used to using the Arduino Pro Minis in the 17 function decoders, should be aware that the UNO and Mega2560 boards need different “Board” settings in the “Tools” menu. These also use a different but standard, and simpler USB cable than the Pro Mini
Standard USB Cable for the Mega2560 and UNO
These larger Arduino boards makes it easier to put these multiboard assemblies together quickly, with trivial modifications. I hope some of you find this so! Have fun!
Best regards,
Geoff Bunza