# DCC++ Arduino Track voltage question



## BrokeCurmudgeon

I am playing around with a Arduino DCC++ project. A YouTube video ( 



) has one to use a 12vdc wall wart . After connecting a Motor Shield to the Arduino the track voltage is the same as the input voltage to the Arduino. In this case, 12vdc (wall wart). 
*Question:* Is 12 AC from the motor shield sufficient to power a small DCC layout and drive the decoder in the engine?
I see where people have used 15vdc inputs which would produce 15vac track power but the higher voltage can destroy the Arduino. (So I am told.) In one of the videos the narrator says to cut a trace on the motor shield to avoid this problem. The problem with this approach is that the motor shield that I have doesn't have such a trace. So, any suggestions and/or comments? All would be greatly appreciated!


----------



## wvgca

i used a 15 volt power supply, my shield had the traces [two] that were cut for powering with 15 volt ..
i ran HO, for N scale i -beleive- 12 volts is enough ??.


----------



## BrokeCurmudgeon

wvgca said:


> i used a 15 volt power supply, my shield had the traces [two] that were cut for powering with 15 volt ..
> i ran HO, for N scale i -beleive- 12 volts is enough ??.


Thanks WVGCA! I have a Fundumoto motor shield and data is very hard to find. (http://rc.mired.org/2017/09/the-fundumoto-motor-shield.html) What I want to do is duplicate cutting the trace so that the shield doesn't feed vin to the Arduino. However I am lost now. Any further thoughts?


----------



## Shdwdrgn

Yep that's what I've heard too... 12V for N scale (although I have also seen some HO that runs on 12V) and usually 15-16V for HO.

As for the board itself, just reading a little bit of that page would make me avoid trying to use that board. At the very least, there does not appear to be any access to the current-sense feature of the L298 chip (it can be added to some boards with a 3W 1.5 ohm resistor and a bit of soldering). Without being able to sense the current to the track, the board has no way of shutting down power if you get a short across your tracks. Also note that the L298 will only provide up to about 1.5amps to your layout, maybe enough for two locos, but only IF you add a heavy heatsink to that chip on your board.

If you can pull yourself away from 'shield' boards, there's a much better choice. Search for a BTS7960B (sometimes listed as IBT_2). This board can be found for about $7, includes the current-sense function, and can handle up to 43 amps of power (way more than you will probably ever need). Note this board only handles ONE track though, so you'd only use this on the main layout. You would also need a transistor and a couple resistors to complete the circuit. Here's what the circuit looks like connected to my ESP32:









The blue wires are the current sense lines, orange is the enable line, and yellow is the DCC signal output. The logic pins on this board get power directly from the I/O lines on the arduino, so no need to cut traces. It is also compatible with both 5v and 3.3v devices.

The circuit above is what I run here. The L298N board has been modified with the resistor to allow current sensing on my programming track, and I have a separate board to provide a regulated 5V power source out of my 16V power pack (which I also use to run an arduino that is set up as a decoder to run turnout servos). You can get much smaller arduino boards than the Mega/Uno, and plug them directly into a breadboard with the transistors and any other parts you might need. I use an ESP32 board with a built-in display and the corresponding DCC++ESP32 project code to allow wifi access, but not everyone cares about that.

Anyway, there are alternatives available that are much better suited for DCC if you are willing to do a little breadboarding.


----------



## BrokeCurmudgeon

Thanks for your expert advice Shdwdrgn! Many years ago,Uncle Sam made me a Heavy Ground Radio Repairman after almost one year of training. Today I struggle with even the most basic electronic projects. Soldering is terrible. The suggestion to use discrete components is a good one. However it is beyond my abilities today due to my age effects, both physical and mental:laugh:. 
A shield seems to be a easier solution howbeit not as flexible. There must be a way to enable the current sensing capabilities in the chip. I will continue on...

p.s. for some reason I do not see your diagrams.


----------



## Shdwdrgn

Here's the direct link to the schematic... http://sourpuss.net/projects/trains/misc/DCCppESP32.png

When I referred to breadboarding the circuit, I was actually meaning a solderless breadboard. Sure I plan to eventually move my setup to a permanent soldered breadboard, but it's working just fine as it is. Note that the 43A bridge board already has header pins soldered on it, so you can just use jumper wires to hook it up to the arduino, but you still need that transistor to complete the circuit. Basically the transistor is just acting as a logic inverter, so something like a 7414 IC chip could probably perform the same function.


----------



## BrokeCurmudgeon

Shdwdrgn said:


> Here's the direct link to the schematic... http://sourpuss.net/projects/trains/misc/DCCppESP32.png
> .


When I tried to access the link my virus protection said "Website blocked due to a Trojan". Are you comfortable with this site?


----------



## Shdwdrgn

It's my website and server, so yeah I'm comfortable with it.  Some virus scanners keep blocking my domain simply because of the name, not because they've ever actually found any malicious content on my servers.


----------



## tankist

Interesting discussion. 
Althoug I don't expect to exceed 1.5A capacity ofL298 I Ordered a BTS7960B to try it out.


----------



## Shdwdrgn

There is certainly an advantage to having a board that greatly exceeds your needs. I have two of these boards, and the first board I got didn't seem to work right (before I had a working DCC setup and was fumbling around in the dark)... I decided to try and troubleshoot so I pulled off the big heatsink from the back -- then the board started working. Must have been a trace shorting against the heatsink, but I never put it back on again. So far I haven't felt any heat at all coming from the chips, but I'm also only running a single loco. However I've heard of other people also pulling the heatsink to save space, and apparently you have to run quite a few locos at once before this chip starts generating any noticeable heat.


----------



## BrokeCurmudgeon

Shdwdrgn, I found out why I could nolt see your diagrams and posts from sourpuss.com. For some reason Malwarebytes flagged it as a threat. I had to have your site "White Listed" and now all is good.
Also, I am wondering why you need a reg 5vdc and if you have a source of inexpensive boards similar to what you are using. 
And, I assume that you are using WIFI and a program like JMRI Decoder Plus to control. Can you elaborate more?
Thanks!


----------



## Shdwdrgn

I've actually opened up a ticket with Malwarebytes to try and get that cleared up. It appears they've been listing my domain as a source of malware for over a year! Ugh.

So the 5V regulator... I found this board on ebay for about $2.50. It will take up to a 24V input and provide a regulated 5V output of up to 5 amps, so if you plan on running a number of arduinos this could be an easy way to get power to them all from your track supply (which is what I'm doing).

As for the rest, it's actually pretty straightforward. The DCC++ESP32 program uses the current DCC++ code as its core, but adds wifi functionality and a small status display. The ESP32 is also capable of creating its own web server, so once you know the IP address of the controller you can browse to it with a desktop or cell phone, and it provides a web page that acts as a throttle, function controller, and turnout controller. I have not yet had to mess around with JMRI or any of the other programs because it's all built in (albeit the web interface doesn't scale well to a cell phone, but it's still a work in progress).

So my entire setup currently consists of the following... A 16.5V DC power supply, the 5V regulator, an ESP32 running DCC++ESP32, the BTS board to provide the AC signal to the track, a small solderless breadboard to hold the ESP, transistor, and resistors, and a 'nano strong' arduino board which contains headers to plug in servo motors directly. Finally I have a raspberry pi 3 set up as a wifi access point, so it creates its own private network that the ESP talks to, and can also accept connections from my cell phone and other devices, but in the future I also intend to have it running scripts that control the locos over wifi.

I recently designed a small circuit board that carries the 6n137 chip to decode DCC signals for an arduino. My next electronics project will be working on a small board that holds an ESP32 and all the support chips to read signals from both DCC and wifi, control the loco motor, provide an expandable interface for controlling lights and other features, and will have a micro-SD card to load sound effects on. Basically a full-featured loco decoder card, except I think I can build these for around $30. I'm hoping to have a couple of these board made and assembled by the end of this Winter, then I'll have to work on the software.

So yeah, a great big pile of DIY, but I'm working towards a fully-automated layout.


----------



## BrokeCurmudgeon

Hopefully someone can answer this. I have JMRI and DCC++ working on my Raspberry Pi. I am using a Fundumoto motor shield. The perplexing question is why if I am powering the motor shield with 12.4 vdc but the output voltage on the motor output terminals reads 4.7 vac? Not enough for the engine motors.My understanding is it should be the same potential as the input. I was expecting to see something around 12vac. Any ideas?


----------



## Shdwdrgn

Limited experience with DCC troubleshooting here, but the first question that comes to mind is whether you are sure your meter reads true RMS? Mine claims to, then only reads 1.6VAC across my rails. I would assume you've actually tried a loco on the tracks to see if it will run?

If that all looks good except the loco runs slow (as expected for a 4.7V supply) then I would think this indicates that your power supply voltage is not being put to the tracks, but rather only the 5V source from the arduino... in which case it's going to come down to the specifics of your motor shield. Are there traces to cut to allow for a separate voltage source? Is there a set of jumpers to select the source? Since I've never used a shield I can only relay suggestions I have seen on the DCC++ board which were given to others, and of course this may be things you have already gone through and checked. Sorry I can't be of more help here.


----------



## BrokeCurmudgeon

My meter sa7y it reads RMS. I read17.4 at my layout so I assume the meter reading is good. An engine on the RPi track just sits there with no response with 4.7vac. I don't have access to a O Scope so I don't know if I am even getting PCM at the test track. All reviews on this motyor shield are bad and there is a lack of documentation to boot! I am about to give up and buy another NEC PowerCab. The trouble is, I don't like to admit defeat. Maybe after a break, I will try a different motor controller.hwell:


----------



## Rabman

I am using this motor shield with a 19 VDC Laptop power supply. It feeds in to a Buck Converter that steps the voltage down to 15VDc. Here are the amazon links of the Motor shield and buck converter.

I have operated 4 HO DCC locomotives at the same time with this setup.

https://www.amazon.ca/gp/product/B077V429MN/ref=od_aui_detailpages01?ie=UTF8&psc=1

https://www.amazon.ca/gp/product/B07CK4TDZ2/ref=od_aui_detailpages01?ie=UTF8&psc=1

I did bump up the setting in DCC++ for the short circuit cutout from 400 to something higher (about 1.5 amps I think), don't recall off hand. The motor shield hasn't burned out yet.


----------



## train4fun

Shdwdrgn said:


> I've actually opened up a ticket with Malwarebytes to try and get that cleared up. It appears they've been listing my domain as a source of malware for over a year! Ugh.
> 
> So the 5V regulator... I found this board on ebay for about $2.50. It will take up to a 24V input and provide a regulated 5V output of up to 5 amps, so if you plan on running a number of arduinos this could be an easy way to get power to them all from your track supply (which is what I'm doing).
> 
> As for the rest, it's actually pretty straightforward. The DCC++ESP32 program uses the current DCC++ code as its core, but adds wifi functionality and a small status display. The ESP32 is also capable of creating its own web server, so once you know the IP address of the controller you can browse to it with a desktop or cell phone, and it provides a web page that acts as a throttle, function controller, and turnout controller. I have not yet had to mess around with JMRI or any of the other programs because it's all built in (albeit the web interface doesn't scale well to a cell phone, but it's still a work in progress).
> 
> So my entire setup currently consists of the following... A 16.5V DC power supply, the 5V regulator, an ESP32 running DCC++ESP32, the BTS board to provide the AC signal to the track, a small solderless breadboard to hold the ESP, transistor, and resistors, and a 'nano strong' arduino board which contains headers to plug in servo motors directly. Finally I have a raspberry pi 3 set up as a wifi access point, so it creates its own private network that the ESP talks to, and can also accept connections from my cell phone and other devices, but in the future I also intend to have it running scripts that control the locos over wifi.
> 
> I recently designed a small circuit board that carries the 6n137 chip to decode DCC signals for an arduino. My next electronics project will be working on a small board that holds an ESP32 and all the support chips to read signals from both DCC and wifi, control the loco motor, provide an expandable interface for controlling lights and other features, and will have a micro-SD card to load sound effects on. Basically a full-featured loco decoder card, except I think I can build these for around $30. I'm hoping to have a couple of these board made and assembled by the end of this Winter, then I'll have to work on the software.
> 
> So yeah, a great big pile of DIY, but I'm working towards a fully-automated layout.


Do you happen to have a schematic or a sketch of this setup that you can share?
Thank you


----------



## Severn

curmudgeon ... what do you mean you have dcc++ on a raspberry pi? surely you don't mean you ported the arduino base station code to some kind of Linux pi driver? I mean maybe that could work. even some kind of user level port perhaps could ... maybe... although with Linux in the way this all seems hard.


----------



## BrokeCurmudgeon

Severn said:


> curmudgeon ... what do you mean you have dcc++ on a raspberry pi? surely you don't mean you ported the arduino base station code to some kind of Linux pi driver? I mean maybe that could work. even some kind of user level port perhaps could ... maybe... although with Linux in the way this all seems hard.


Sorry I find it difficult to answer. Since I originally posted this my memory has slipped a bit. I will try to remember why I said that and respond but I have little hope...:laugh::laugh:


----------



## Severn

That's ok. I built the arduino dcc++ base station. I used the pololu motor control board. But I also have the pi version of the same board and a pi b.


----------

