Installing JMRI DC For 4 Cab DC Control

How to use JMRI for 4 cab DC train control.

This page is under construction. But what is here is enough to get you started.  It just must be reorganized.

 

dc Cab WiFi Throttles

The information in this page will be summarized from https://model-railroad-hobbyist.com/node/35760

Summary

You need the base station set up for Wifi –

You need the throttle .Build the throttle

JMRI to track connections

Here is the basic discussion to be summarized to be useful.

Old DC is New Again with “ 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 generate 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 pulses 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!

Also what better mechanism, than using the decoder address selection in the throttle to specify which DC “Cab” the throttle was connected to? This is how I implemented it.

But there was more! In the Arduino hardware, there is a built-in mechanism to generate PWM signals. The same that could be used for motor speed control. And there were more than two of these in each Arduino! I wanted to try to preserve the use of the motor shield as is for two DC cabs. With the Arduino Uno there were two unused PWM pins available, once the “braking” feature was disabled on the motor shield. The Arduino Uno could control four DC Cabs via JMRI throttles! . I typically run the H-Bridge drivers with an external 12 Volt power supply. If you want to run the DCC bus at a higher voltage using the motor shield, follow the advisory here: https://github.com/DccPlusPlus/Documentation/blob/master/Motor%20Shield%20Pin%20Mappings.pdf
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://model-railroad-hobbyist.com/node/35753) and is shown below:

motor controller
15  Amp FET Dual H-Bridge
This FET H-Bridge can handle a lot of current! There is NO SHORT CIRCUIT PROTECTION on this board, and yes, I have already destroyed one myself.  Adding fuses, circuit breakers, or DCC power protection devices are all really good ideas. If you run this at the high end of its range, be prepared that those small metal fins are likely to get hot. You cannot simply add a common heat sink to them all without insulating all of the fins (on the FET’s). You do not have to use this with a high current supply. It will work just fine with a lower current (1 Amp) even lower voltage (8 Volt) supply too.

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:  /sites/model-railroad-hobbyist.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.

I have tried to minimize the changes to Gregg’s original DCC++ code for DC+ in case some intrepid modeler might find a use for some of the remaining original functions. However most of the DCC signal generation code has been removed. No modification was made to JMRI, and no additional JMRI scripts need be run. This should enable the modeler to use DC+ for JMRI throttle control and even allow JMRI to operate with a different DCC system (like Digitrax) for signaling, sensors, turnouts, ops , etc. My bulk JMRI sensor interface: SMA28 JMRI Sensor Channels – Direct Arduino to JMRI Communications – Simple Support for Lots of Detectors https://model-railroad-hobbyist.com/node/34392  and bulk JMRI turnout channel: SMA29 JMRI Turnout Channels – Direct JMRI to Arduino Communications – Simple Support for Lots of Data Out From JMRI  https://model-railroad-hobbyist.com/node/34417  can be used with the DC cabs in DC+.
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! smiley
Best regards,
Geoff Bunza


We hope that you found the information in this page useful. The internet is all about getting and giving. And giving back is the best. Please donate $1 or more to aid us in our continuing quest to add to and polish the information in our site.


Scroll to top