Subscribe via RSS
27Jul/210

DCC via an Arduino!

And now, back to the topic that started this entire blog: DCC! Back then, I was creating breadboard circuits to get a PC to talk DCC, and although it worked, it has now been made much easier thanks to the Arduino platform. All you need is a motor shield and an Arduino Mega! It seems that DCC on the Arduino started as a project named DCC++. Sometime around 2016, the 'great rewrite' occurred and DCC++EX was born. What follows is what's required to get this up and running in no time!

First off, you need a supported Arduino with a matching motor interface. My expectation is to use my PC to control the DCC trains, so I wont need any extra throttle hardware. For any electronics projects, make sure you have a solid power supply. Especially with DCC, which requires intricate signals running over the model railway rails, you should follow the power supply guidelines here, preventing any further issues.

To make life easy, I purchased a legit Arduino Motor Shield from Core Electronics and attempted to plug it into my Arduino Mega 1280... used in most of the Arduino posts on this blog.

DSC03759

Turns out, my Mega is so old that the pins don't even line up! Seems that the pin layout changed at some point in the last 11 years.

DSC03760

Luckily I had a spare Uno on-hand from previous Remote Control tinkering.

DSC03769

With the newer Uno, things fit together nicely...

DSC03771

Note that there's still a mod required on the motor shield to make sure that you isolate the USB power from the track power.

DSC03766

Following the instructions here, I cut/scratched the thin trace between the VIN pads on the board. With the pads still there, I can solder a jumper wire on later if I want to restore the use of the Arduino's voltage input.

DSC03773

Once you've got your hardware setup, plug it into your PC and make sure the Arduino interface is all up-and-running, including the installation of the Arduino drivers. You can then go and download the latest version of CommandStationEX. Extract the zip and open the folder, you'll find the PDE is associated with the Arduino IDE and can just be double-clicked. Finally, just make sure your Arduino is configured correctly (type/port) in the IDE and upload the sketch.

DSC03776

Note that the software above is just the code for the Arduino. The Arduino acts as a bridge, with its own command set, so you'll then need a controlling application to get trains moving. I downloaded and extracted WebThrottle-EX, but you don't even have to do that! On the computer connected to the Arduino, just run it from the cloud!

dcc-webthrottle-ex

Firstly, hit Connect in the top-right. It'll ask you to choose a Serial Port, which USB2Serial should be listed. Mine was COM6 and it all connected straight away. From there, hit the Power Switch in the middle. Finally, you need to enter the vehicle ID in the top left and then hit the arrow to the right of it. Thanks to my record keeping, I knew the ID I'd set the Kirara to. With the number 12 in place, I toggled the headlights button and the headlights came on! The track was dirty and the vehicle wheels were too, so I flipped it over to clean and found...

DSC03777

Hah! I left a note to myself that I hadn't even seen this time-around.

I didn't need N Scale to work this time around, so I packed it all up in ready for a HO DERM install! Mission accomplished!

Filed under: Arduino, DCC No Comments