It occured to me while helping some modelers recently, who are running DC layouts, that some reprogramming and a perhaps a re-imagined veiw of cab control and throttles might open some new opportunities. I had already delved into the depths of Gregg Berman’s DCC++ project -- SMA25 Tinkering with DCC++ Base Stations: JMRI To Track Connections, Accessories & Fun ( https://forum.mrhmag.com/post/sma25-tinkering-with-dcc-base-stations-jmri-to-track-connections-accessories-fun-12204471) and the combination of all these influences fired up that one tiny brain cell that sometimes runs amok in me – why not make JMRI do DC?
The basis of all this starts with the nature of the motor control on the Arduino add-on shield – the two “H-Bridges,” that are essentially a set of four coordinated switches used to genernate the DCC signal in the DCC++ project. Originally this design was used for bi-directional DC motor control. Pulse width modulation was used to control the effective power delivered to the DC motor, thus enabling speed and direction control with only a single DC power supply. With DC power packs, train control pulses were sometimes used to kick start motors. Their power pusles would help to overcome motor drive starting friction in locos. Pulse width modulation (PWM) is commonly used in most all DCC decoders too.
The essential integrated idea was to convert the throttle commands from JMRI to the Arduino DCC++ “base station” to control each of the H-Bridges on the motor shield, as if they were separate DC cabs. With isolated track sections, anyone could then run two DC locos/trains with an unmodified JMRI throttle. Because JMRI was using precisely the same communications, and JMRI was not modified, all the available features would still be available for use! “All the features” would include the use of JMRI’s WiFi throttle server, enabling (for the first time as far as I know) the use of WiFi throttles for unmodified DC loco control. Not bad!
If you use more than a 12 Volt power source to the motor shield, you will have to cut the VIN jumper wire on the motor shield before applying power.
To create a total of four cabs, beyond the two provided by the motor shield, two additional H-Bridge DC drivers would be needed. One of the best I found was already described in detail in SMA31 - 15 Amps Plus of Raw Power for DCC++ ( https://forum.mrhmag.com/post/sma31-15-amps-plus-of-raw-power-for-dcc-12212047) and is shown below:
With the appropriate power supply, the new 15 Amp FET H-Bridge will power any DC loco. But one should remember that there is a larger Arduino, the Mega2560, with even more PWM pins, also compatible with both the Arduino motor shield, the new FET H-Bridge, and the DCC++ code. It can control up to 8 DC Cabs! To do so, it would need a total of 4 dual H-Bridges (remember the motor shield is a dual H-Bridge too). Interesting to some people (like me) the way the H-Bridge controls were actually reversed from the way they were use for DCC control. With DC cab control, the DIRection controls are actually used for loco direction, and the PWM control is used for PWM speed control. In DCC++ the DIR connection is used to generate the symmetrical, alternating DCC signal and the PWM control is used to turn the signal full on or full off.
Making It All Work
You can find the details of constructing a DCC++ hardware module and loading sketches in DCC projects using the Arduino in the March, 2017 issue of MRH (http://mrhpub.com/2017-03-mar/online/html5/?page=204). The article includes a description of the connection to JMRI. It may be difficult to believe, but once you have an operating DCC++ set of boards, connected to JMRI, then all you need do is load the new sketch (program) into your Arduino and you will have a dual cab DC control system, operated by JMRI throttles, including any form of WiFi throttle. The new code can be had here:
http://mrhpub.com/files/users/geoffbfiles/DCp_Cab2_1.zip
The name reference is to DC+ (not a stretch I know!)
Remember to cover the entire folder and its contents in the zip file into your …\Documents\Arduino\ folder. Then load the sketch DCp_Cab.ino into your Uno with the Arduino IDE editor.
If you use the Uno/Motor Shield combo alone you will have 2 DC cabs capable of delivering up to 2 Amps each. If you want 4 DC cabs, you will need to cut the 2 Brake Disable jumpers on the back of the Motor Shield to free up the additional pins for the extra cabs.
For any JMRI connected throttle, simply address the DC cab by setting the throttle address (1-4). There are no “functions” in DC control, but throttle speed, and direction, as well as power control can be set and adjusted. To change cabs simply release (REL) the address and set the new cab address. You can operate four separate cabs with an Arduino Uno. Now it should be clear that you can use a WiFi throttle to control your DC layout too. Four throttles can be used simultaneously.
To connect the additional H-Bridges use these pins on your Uno:
PIN Description
3 DC CAB 1 pwm (Motor Shield)
10 DC CAB 1 dir (Motor Shield)
11 DC CAB 2 pwm (Motor Shield)
5 DC CAB 2 dir (Motor Shield)
6 DC CAB 3 pwm (External H-Bridge Module) Make sure to cut Brake Jumpers
7 DC CAB 3 dir (External H-Bridge Module) Make sure to cut Brake Jumpers
9 DC CAB 4 pwm (External H-Bridge Module) Make sure to cut Brake Jumpers
8 DC CAB 4 dir (External H-Bridge Module) Make sure to cut Brake Jumpers
Wiring from UNO/Motor Shield combo (Uno Pins) to External H-Bridge for DC Cab 3 and Cab 4
Please note: These are NOT the same connections used for connecting this FET H-Bridge to the DCC++ motor shield in the DCC Application!
If you need 8 DC Cabs, you can use an Arduino Megaa2560 loaded with the same sketch listed above. Remember to cover the entire folder and its contents in the zip file into your …\Documents\Arduino\ folder,
Load the sketch DCp_Cab.ino into your Mega2560 with the Arduino IDE editor.
To connect all the H-Bridges use these pins on your Mega2560:
PIN Description
3 DC CAB 1 pwm (Motor Shield or External H-Bridge Module)
12 DC CAB 1 dir (Motor Shield or External H-Bridge Module)
11 DC CAB 2 pwm (Motor Shield or External H-Bridge Module)
2 DC CAB 2 dir (Motor Shield or External H-Bridge Module)
6 DC CAB 3 pwm (External H-Bridge Module) Make sure to cut Brake Jumpers
7 DC CAB 3 dir (External H-Bridge Module) Make sure to cut Brake Jumpers
9 DC CAB 4 pwm (External H-Bridge Module) Make sure to cut Brake Jumpers
8 DC CAB 4 dir (External H-Bridge Module) Make sure to cut Brake Jumpers
2 DC CAB 5 pwm (External H-Bridge Module)
4 DC CAB 5 dir (External H-Bridge Module)
46 DC CAB 6 pwm (External H-Bridge Module)
48 DC CAB 6 dir (External H-Bridge Module)
45 DC CAB 7 pwm (External H-Bridge Module)
47 DC CAB 7 dir (External H-Bridge Module)
44 DC CAB 8 pwm (External H-Bridge Module)
42 DC CAB 8 dir (External H-Bridge Module)
These all connect in a similar fashion as designated in the previous diagram above.
You do not have to implement all the DC Cabs. (You can build as many as needed.)
Additional Project Notes:
Do not make connections or disconnections while any power at all is applied to any of the connected modules. The 12 Volt power will instantaneously destroy any of the control logic circuits if shorted to the wrong place on the boards. H-Bridges do not have to be powered with 15 Amp power supplies. They work just as well with 1 Amp power.
The four DC cab Uno configurations have been tested as described. I am still amazed that they work as well as they do. The 8 DC cab configuration with the Mega2560 has not been tested. If you build one, let me know how it turns out. All the software mods are already in place.
In my opinion, the fact that all this can work is a tribute to the genius and inventiveness of all the JMRI developers and Gregg Berman -- the shoulders that this project is built upon. I hope you have as much fun with this as I have, and build your own projects, perhaps using a piece of two of this work too!
As usual, all relevant comments and suggestions are most welcome.
Have fun!
Best regards,
Geoff Bunza