# DCC++ vs Commercial DCC



## Mallet

I'm planning a G Scale layout that could best be described as a fun and unique, specific purpose. Assuming that I can pull it all together, I'll share the full details and pictures during the build, and when it is actually installed and running.

I have plenty of experience with HO and G scale equipment, and I develop manufacturing control system software (SCADA/PLC) for a living. Now I want to do a fun DCC type of project. I've been reading up on hardware options, and before I dive in at the next level, get some opinions from the gang here.

Specific Use Case:
- A single G Scale Loco and 2 or 3 pieces of rolling stock, nothing more than that. Ever.
- A single linear rail section about 40 feet long. It will never be expanded. Ever.
- Need to somewhat accurately (+/- a few inches) stop the loco at "Stations" spaced 2 feet apart, so at least conceptually, there could be 20 track segments/blocks to define the stations.
- "Home" is at one end of the track. When the train is at home, give it a command to move to a particular station. It would accel, travel, decel and stop. A separate command would be issued to return home.
- The ability to support a physical and/or PC display based panel to show the status.

I have used Arduino and Raspberry Pi for other home projects. I can program in multiple languages (Basic, C, C++, Javascript, PHP, PLC ladder logic, fluent in Cisco IOS, etc.) so this is not a challenge on the configuration and programming side.

I've done research, but here are some "sanity check" questions. I'm also looking for "Here's how I did it" or "Don't do THAT!" feedback:

I can do *all* of the software control/automation using JMRI?
I can use an Arduino or Raspberry PI with a Digitrax PR4 or Locobuffer USB interface? Would a PC be better?
I can use a monitor attached to an RPI running JMRI to display the panel status?
I can use a Digitrax BLD168 via the JMRI Reporter to get block status?

Assuming no drive train slippage, can you think of any reason that I couldn't use 10 track segments (instead of 20) and program 2 different decel rates to stop at two different locations in a single segment? This would reduce wiring/sensors.

Going a step further (assuming no slippage or load variations) is it realistic to program the stations strictly by speed and run time with no blocks/sensors other than Home?

Is there any reason that I should use ALL commercial hardware & software such as Digitrax instead RPI/JMRI?

Thanks!


----------



## mopac

Welcome to the forum. Sounds like a cool G scale project. Your questions are way above my pay grade. Good luck.


----------



## DonR

There seems to be commercially available electronics
designed to slowly start a loco, pace it to the next
stop, slow, stop, slowly restart and so on.

It's discussed here:

https://www.modeltrainforum.com/showthread.php?t=177972&page=2

Don


----------



## Shdwdrgn

I don't think I can answer most of your questions directly, but you might want to look into DCC++ESP32 (an offshoot of the original, but the main DCC code is synced between the two projects). The ESP32 branch adds wifi control, and also includes S88 and LocoNet functions (which I don't know if the plain DCC++ has?). Because of the networking features, it becomes possible from the raspberry pi to write a script that opens up a port that sends/receives DCC commands. So if you tie some track sensors to S88 or LocoNet, when a sensor is tripped that information will also appear on the network port, allowing your script to respond. For example, if sensor 1 is tripped you can send a DCC command to speed up the train, then start slowing down when you hit sensor 2, and stop for 60 seconds when you hit sensor 3.

My own current setup uses the raspberry pi to set up a private wifi access point. The esp32 runs DCC++ESP32 as a base station and connects to the wifi automatically, and will soon be running S88 to detect track sensors. I also have an arduino set up as a DCC decoder to run servo motors controlling the turnouts. And the esp32 also provides a web interface, so I can connect to the wifi with my cell phone and run the train and turnouts from there. There is maybe $100 in equipment here, not counting the Digitraxx decoders in my three locos, but it sure does provide a lot of possibilities.


----------



## Mallet

DonR said:


> There seems to be commercially available electronics
> designed to slowly start a loco, pace it to the next
> stop, slow, stop, slowly restart and so on.
> 
> It's discussed here:
> 
> https://www.modeltrainforum.com/showthread.php?t=177972&page=2
> 
> Don


Thanks! I'll take a look at that device.


----------



## Rabman

Take a look at some of my posts on using DCC++ and controlling turnouts with arduinos and motor shields. 

The one thing I would be concerned with is the power draw of G scale locomotives. I imagine the draw is considerable. You would need a booster. The standard DCC++ without any boaster is about 1.5A if u recall. I regularly run four HO locomotives on my layout at the same time with no issues. There is a setting in DCC ++ to bump the short current threshold up. 

Other than that I would see little of concern. I would personally make everything from scratch with no DCC off the shelf products as it would be a learning experience. I would use a magnet on the bottom of the loco with a reed switch in the track, IR sensor and LED or something similar. 

Also as mentioned you could open a serial communication with the DCC++ base station and send a script. Not sure how difficult that would be from a Pi or JMRI. From a computer it would be quite easy. The tutorial on DCC++ on YouTube shows you how to do it during the testing. Turning track power on/off, etc. 

There is also a YouTube video where someone has automated a layout with DCC++ if you search for it. 

Hope that helps.


----------



## Severn

Who knew, a DCC specific forum topic area! 

So this is a few months old thread and in the HO forum I put this new thread out on making the DCC++ and being happy that it "just worked" (more or less) -- and so it should have gone here.

Anyway on the topic of more amperage -- well I'm a little familiar with Pololus motor shield offerings. I have several of them. [limited use yet some...]

One would imagine the current code base of DCC++ could be ported to either of these other two higher current boards "with ease"... [VNH5019, TB9051FTG ]

https://www.pololu.com/category/113/arduino-shields

I have the VNH5019 already for other reasons... which doesn't mean I'm volunteering really but it seems like it could work instead of the MC33926.

In the HO and one imagines the other smaller scales the amperage needed is probably no more than 1 amp continuous at most [motors stalled out, sound on say and LEDs].

I'm a little familiar with O -- which is in fact why I have these things. The motors are bigger although I don't quite think anyone can state with absolute certainty except from the lionel/mth's mouths directly and they are mum on the topic -- what their amps neds are -- yet we can estimate.

For example I had an MTH SD70ACE apart the other day -- and I happened to notice its bridge rectifier part number and looked it up -- it's an 8 amp part.

Now I don't think MTH thinks that engine draws 8 amps continuously, but maybe with the engine stalled [it has 2 cheap chinese can motors] and the smoke blowing full bore and the sound cranked up and all the LEDs on and the couplers being fired ... maybe its something like that.

So one imagines that indeed for the larger gauges a higher amp rating board would be a good thing for DCC++.


----------



## Shdwdrgn

The 1.5A board usually mentioned with DCC++ is only for testing a couple of locos or running a programming track. You wouldn't use that board for anything larger, however the BTS7960 board is commonly available, really cheap (less than $10 usually), provides up to 43 amps with proper cooling, and is already well supported by the DCC++ group. I can't imagine even G scale needing more power than that.

The caveat here is that the BTS7960 board is not an arduino shield... you have to wire it up yourself, but there's only 8 wires for the interface plus screw connectors for the incoming and outgoing power, and connecting it for DCC++ is pretty well documented.


----------



## Rabman

Shdwdrgn said:


> The 1.5A board usually mentioned with DCC++ is only for testing a couple of locos or running a programming track. You wouldn't use that board for anything larger, however the BTS7960 board is commonly available, really cheap (less than $10 usually), provides up to 43 amps with proper cooling, and is already well supported by the DCC++ group. I can't imagine even G scale needing more power than that.
> 
> The caveat here is that the BTS7960 board is not an arduino shield... you have to wire it up yourself, but there's only 8 wires for the interface plus screw connectors for the incoming and outgoing power, and connecting it for DCC++ is pretty well documented.


I have been using the standard DCC++ set up with the 2amp motor shield. I have had good success in running 4 locomotives at the same time, 2 with sound. I went on vacation for a month and left it powered on by accident. I think I burned out the motor shield. Need to do some testing when I get a chance to see if it is the motor shield or arduino. If it is the motor shield, I might switch to the BTS7960. Is there anything special i need to do in comparison to the arduino motor shield? You referenced info being available- do you have a good URL link?


----------



## Rabman

This product looks interesting. 

https://www.amazon.ca/gp/aw/d/B019IHNR5K/ref=ox_sc_act_image_2?smid=AFAJ27QUDKWR8&psc=1


----------



## mapod1

Hello there,

I'd be grateful for more details on VNH5019 working with dcc++. The software itself is written to work with motor shields consuming a binary DIR signal, whereas VNH5019 provides two separate MxINa/B directional signal. This can be alleviated by adding a NOT gate (7404 or transistor based), but still there is a question of signal delay at the HS side (see https://forum.pololu.com/t/vnh5019-as-dcc-driver/12136).
Unsurprisingly, I was not able to get it working: I've revised pins to match the dcc++ selection of MEGA's timers, added the inverter for MxINA/B. The dcc++ test works, signals switch off and on. BUT, when I connect this to the track the HS signal simply disappears. It looks like MxINA=MxINB=1. So, again, if you're got this working - respect! And would be great to learn the way you've done it...

Cheers,


----------



## wvgca

the VNH5019 -may- require a circuit similar to the 43 amp booster circuit, if you do a search on threads i created, you will find the project for a 43 amp booster ...
again, the circuit works as a booster , and -should- work as a higher power supply for DCC++ , and it's only 10 bucks on ebay ..


----------



## mapod1

Thanks wvgca - super quick reaction - you mean like Dave Bodnar‘s work with bts7960b (http://trainelectronics.com/DCC_Arduino/DCC++/)? That‘s exactly what the combination of arduino mega (command station) and the shield (booster) are. Added the required inverter (given, not 2n2222 based, but using bc547 -npn) and still no avail. So, would be grateful if you guys can confirm vnh5019 works in the combo with arduino uno/mega and Dcc++ for you, and I will keep trying (although a schematics and Dcc++ Pin/current monitor config wouldn‘t be bad neither .


----------



## wvgca

nope, can't confirm the VNH5019 works, never tried it ....
as far as the booster is concerned, it's daves work in that the code and layout is his , all i did was the pcb for it ...schematic for the the arduino and the 7960 are there, in eagle format, with all the pins laid out .. semi-cleanly, lol


----------



## Shdwdrgn

Rabman said:


> I have been using the standard DCC++ set up with the 2amp motor shield. I have had good success in running 4 locomotives at the same time, 2 with sound. I went on vacation for a month and left it powered on by accident. I think I burned out the motor shield. Need to do some testing when I get a chance to see if it is the motor shield or arduino. If it is the motor shield, I might switch to the BTS7960. Is there anything special i need to do in comparison to the arduino motor shield? You referenced info being available- do you have a good URL link?


Below is my own schematic of how I have my system hooked up. This is of course for the ESP32 version, but I believe the standard DCC++ code uses the same libraries. You just need to select the correct pins on your arduino (which should be the same as the you used for the smaller motor shield), and there is probably something in the DCC++ code where you select the H-bridge board you are using so that it responds properly to an overload condition. Sorry I'm not particularly familiar with the original DCC++, I've only ever used the ESP32 version.

For reference, the yellow wire is the DCC signal, orange is the enable line, and blue is the current overload sensor.


----------



## Rabman

Shdwdrgn said:


> Below is my own schematic of how I have my system hooked up. This is of course for the ESP32 version, but I believe the standard DCC++ code uses the same libraries. You just need to select the correct pins on your arduino (which should be the same as the you used for the smaller motor shield), and there is probably something in the DCC++ code where you select the H-bridge board you are using so that it responds properly to an overload condition. Sorry I'm not particularly familiar with the original DCC++, I've only ever used the ESP32 version.
> 
> For reference, the yellow wire is the DCC signal, orange is the enable line, and blue is the current overload sensor.


Thanks for the information. I came across this information related to the board I am going to try. I don’t believe it has current sensing. 

https://model-railroad-hobbyist.com/node/35753

Bought the board which should arrive by mid-November. On the slow boat from China I guess. 

It doesn’t appear I need to use any additional circuitry.


----------



## Rabman

Well I have great news in my application. I finally got a chance to do some testing and work on my DCC++ last night. I suspected it had a defective motor shield but it wasn’t. I ran through the testing for DCC++ using the Arduino IDE Serial monitor, using <0>, <1> and <D> commands. It wasn’t working so I reinstalled the DCC++ program on the arduino, still no joy. I then selected a different DCC system in the preferences in JMRI then selected DCC++ again, with serial, selected Com3 again and that solved the problem. All the settings were correct prior to doing this but I guess the reset worked. 

I may try the higher amperage board in the future but currently I have not run into a current issue, even running 4 locomotives at once with my existing motor shield. I am going to put a heat sink on the motor shield IC though.


----------



## Shdwdrgn

Rabman - I missed it before, but note mapod1's reply at post #13, which is actually the site where I first saw this BTS7960B board mentioned and talks about using it with DCC++. I had seen the board that you purchased, but the lack of current sensing and the higher price drove me away from it. You can get the BTS board for around $9 off ebay. The difference is that it only runs a single channel, thus why I have a separate 1.5A bridge (modified) for my programming track. Also note that for running only a few locos at a time, you can remove the heatsink from the BTS board.

There's a lot of different H-bridge boards out there, and the ones I've seen all have consistent markings for the pins. Makes it real easy to swap them out. The small transistor/resistor circuit simply acts as a 'not' gate to provide an opposite signal from the direction control line. Basically the bridges need a positive and negative signal on two pins, always opposite each other for the way we use them, and this little transistor provides a cheap and simple means of doing that. For this purpose the 2n2222 and 2n3904 are identical so use whichever you have on hand.


----------



## jc286006

I am glad you posted this schematic I was really having trouble figuring out Dave Bodnar schematic for the high power motor driver now i can finally hook one up


----------



## Shdwdrgn

H-bridges are one of those oddball things that don't quite make sense until you've played with them, but once you have something to follow it becomes a bit clearer. Basically the transistor (yellow and green wires) ensures the two outputs are always opposite each other (-+ or +-). The logic chips require such low power that I use the enable line (orange wires) to also provide power to the board. For comparison, these H-bridges are identical to half of an L293D chip commonly used to drive small motors, and I use the same transistor circuit to switch motor directions with a single I/O pin.

I forgot to mention, but that center board provides a 5V @ 5A output for me to drive all of the arduinos off of the track power supply -- probably not needed by everyone so you can safely ignore it.


----------



## FlightRisk

*Details on your setup?*



Shdwdrgn said:


> H-bridges are one of those oddball things that don't quite make sense until you've played with them


Do you have a writeup of how your set things up? How you coded the ESP and what you are using all the other Arduinos for? Why do you have 2 different H-Bridges in your circuit? Just what you had on hand? Thanks!


----------



## Shdwdrgn

Sorry, no, I don't really have a write-up of the process. This discussion thread covers the DCC++ software for the ESP32, including the author's current project of building a dedicated circuit board with the ESP32 and H-bridges built in. If you're unfamiliar with working on the ESP32, that might be another option for you.

As for my own setup... You normally want one H-bridge for a programming track and another for your mainline. The L298 chip is commonly used for small motors, but only has enough power to run one or two locos (about 1 amp on each channel). The chip also has a built-in current detector, but that function is not available on most ebay boards you find. As discussed in the above thread, you can desolder a pin from the circuit board, attach a large resistor, and use that to provide overload detection. I only used 1/2 of the L298 to run my programming track. The second H-bridge is a monster, capable of handling up to 43 amps of output, and it still costs less than $10. I use that one for my mainline.

Beyond the ESP32 used as the command station (or base station), I also use an arduino as a DCC decoder to drive servo motors for the turnouts. My test loop only has three turnouts, but I'll be using a lot more arduinos when I build my layout, which will have over 80 turnouts -- including a few slip switches and turntables. The arduino only costs about $6 and will drive 16 servos each. These read the DCC signal directly from the track (I have a small circuit board I designed to grab the signal and plug directly into the arduino).

In addition, I am looking into sensor networks which also use arduinos. S88 is common, but there's a new one that adds a lot more capability and automation. I haven't worked much on the sensors yet but for my own automation I'll need a combination of block detectors, IR detectors, and hall sensors or reed switches. I also want to incorporate RFID tags into my cars so I can confirm everything that goes in and out of a yard.

For my own purposes, a lot of equipment will be required to achieve full automation, but most people prefer a more hands-on approach to operating their trains. What you need for arduinos and such depends on your goals.


----------



## wvgca

the biggest drawback [imo] to home brew DCC++ systems is the case, or lack thereof ... not enough standarization to settle one only a few cases ..


----------

