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.
The information in this page will be summarized from https://model-railroad-hobbyist.com/node/35760
You need the base station set up for Wifi –
You need the throttle .Build the throttle https://model-railroad-hobbyist.com/node/35652
JMRI to track connections https://model-railroad-hobbyist.com/node/27318
Here is the basic discussion to be summrized 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 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!
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.
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:
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:
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:
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.