All posts by andrew

A twenty year veteran of the software industry, Andrew brings considerable experience to electrongoo. From design, development, project management, and product usability; he delivers on all levels

Connecting DCC-EX to a Layout

This post assumes that you have built a DCC-EX command station and installed the firmware. If you have not completed those steps then please do so. The most challenging process of DCC-EX, assembling the DCC-EX command station, is now complete. Now it’s time to have some fun: verify your DCC-EX command station is fully functional and run some model trains.

Connecting the Track Power

  • Connect the power leads from the DCC-EX motor shield to your model railroad track. Polarity does not matter. Either lead can be attached to either side of the track. Your choice will determine which direction is forward and which direction is reverse on your layout. You can always swap the leads if you choose.
  • From the previous post, you should have one positive lead (connected to PA+) and one negative lead (connected to PA-) on the motor shield.
  • Connect each one of those leads to one of the rails of your track. You could solder the leads to the track or purchase a crimp-able alligator clips to make the connection easier.

Connecting the Power Supplies to the Wall

The DCC-EX command station has two power supplies. One for the track power (the larger 12 volt supply) and one for the Mega power (the smaller 9 volt supply). It’s recommended to plug the AC adaptors of both of those power supplies into a single surge protector with multiple outlets. This will allow you to power on the DCC-EX command station with the flip of a single switch on the surge protector.

Final Power Connections to the DCC-EX

  • Connect the 12 volt power supply adaptor into the adaptor on the motor shield
  • Connect the 9 volt power supply adaptor into the Mega board
  • Note, the USB connection on the Mega board can be left open since you will be using WiFi to communicate with your DCC-EX and not USB

Power on Test

With all of the power connections complete you can now power on the DCC-EX command station via the switch on the surge protector.

Next Step

The next step is Installing DCC Commander (iOS or Android) on your mobile device to use as a DCC throttle and actually run your model trains.

Installing DCC-EX firmware

This article assumes that you’ve assembled a DCC-EX command station in a well-defined manner as detailed in this article. The DCC-EX firmware is a set of instructions that tell the Mega how to generate the DCC timing and signals to control your model railroad layout. The easiest method to install the firmware on the DCC-EX hardware is to use the DCC-EX Installer. If you experience any issues with firmware installation and you are not using the well-defined DCC-EX then review the full DCC-EX Installer documentation to find settings that will support your specific needs.

  • Download the DCC EX-Installer for your operating system
  • Connect your assembled DCC-EX command station via USB cable to your system running DCC-EX Installer
  • A green LED on the Mega 2560 should illuminate telling you it’s powered-on and ready for a firmware update
  • The USB cable will supply power to the Mega 2560 to allow it to accept the firmware update. There is no need to plug in the 9V or 12V power supplies used for actually running trains
  • Launch the DCC-EX Installer you just downloaded from the DCC-EX website
  • Select “Manage Arduino CLI”
  • Select “Install Arduino CLI” if it is not already installed
  • The install process could take a minute, select “yes” if prompted to allow the installer to access your network
  • Select “Select your device” to continue
  • Since you used well-known parts to build your DCC-EX command station, the installer will automatically find your DCC-EX command station
  • Select “Arduino Mega or Mega 2560 on COM-X” (the above image shows COM4)
  • Select “Select product to install”
  • Select “DCC-EX, EX CommandStation”
  • Select the default options “Latest Production – Recommended”
  • Select “Configure options on the next screen”
  • Select “Configure EX-CommandStation”
  • Select “I have WiFi”
  • Select “STANDARD_MOTOR_SHIELD” from the “Select your motor driver” list box
  • Lastly select the “Wifi Options” tab located on the top-center
  • Select “Connect my EX-CommandStation to my existing wireless network”
  • Enter the WiFi SSID for your wireless network
  • Enter the WiFi Password for your wireless network
  • Select “Compile and load”
information

Note

The WiFi SSID and password are the same you use to connect any wireless device to your network.

  • A confirmation prompt is displayed. Select “Load” to program the firmware on your DCC-EX command station
  • You should see a status bar at the bottom of the installer window and the Mega will blink a few times. Be patient!
  • A final status window will be displayed
  • Congratulations! You’ve now programmed the firmware and you have a fully functioning DCC-EX command station.

Next Step

The next step is to attach your DCC-EX to your model railroad layout, verify your DCC-EX command station is fully functional, and start running trains!

Direct Command Control (DCC)

What is DCC?

DCC stands for Digital Command Control. It’s a standard used in model railroading that allows multiple locomotives to be independently controlled on the same section of track. National Model Railroad Association developed and maintains the DCC standards used by most manufacturers. For many hobbyists, DCC is the model railroad equivalent of moving from an old analog telephone system to a modern digital network. It transformed layouts from “control the track” to “control each locomotive individually.”

DCC Commander

DCC Commander is a mobile control center for Digital Command Control (DCC) model railroads, allowing operators to control locomotives, turnouts, routes, and layout functions from their iPhone, iPad, or Android device. Features include:

  • Controlling locomotives (up to 10 throttles per screen)
  • Throwing turnouts
  • Communicating with JMRI (WiThrottle-compatible communications) and compatible command stations
  • Communicating with DCC-EX command stations directly
  • Managing layout operations from a mobile device (iOS and Android)
  • Building layout schematics
  • Using swipe gestures to route locomotives along a layout

Tutorials and Setup

DCC-EX

DCC Commander

Building a DCC-EX Command Station

Building a DCC-EX command station is one of the easiest and most affordable ways to get started with DCC. If you’re comfortable with basic electronics or have built an Arduino project before, you’ll find the process straightforward. For a deeper dive into DCC-EX, including build-versus-buy considerations and the many available hardware options, visit the DCC-EX website.

If you’d rather skip the research, build a DCC-EX command station using a proven set of parts and get your model trains running, this guide is for you. The following sections describe a simple DCC-EX command station configuration that has become the “standard” DIY DCC-EX build because the parts are inexpensive, widely available, and well supported. You’ll find a complete parts list along with easy-to-follow assembly instructions.

If you’d rather skip assembling your own DCC-EX command station then you can purchase a pre-assembled unit directly from the DCC-EX group or one of their resellers.

Before You Start

This guide assumes you’re comfortable with basic electronics or you’ve assembled simple Arduino projects before but have never built a DCC command station. No soldering is required. You’ll only need a screwdriver, wire stripper and about 30 minutes. Genuine Arduino or compatible Mega 2560 boards both work fine.

information

Note

All assembly steps below are set apart as bullet-items for easy distinction between “wordy-words” and the steps required to assemble the DCC-EX. So, if you already have a good general understanding of assembling a DCC-EX then just look for the bullet-items and supported images.

Parts List

If you buy through these links, we may earn a small commission at no extra cost to you.

Notes: Genuine Arduino Mega 2560 boards and compatible clones both work well. The 9V power supply powers the Arduino and the electronics. The 12V supply powers the trains. They intentionally remain electrically separate as you will see below when you connect the Mega 2560 and the motor shield. Here is an image of all the parts you will need.

Connect Arduino to Motor Shield

Gather the Mega 2560 Microcontroller board and the Motor Shield board. The Mega 2560 is the brains behind the entire DCC-EX command station. It generates the timing and signals required for DCC to control your layout. The motor shield is the brawn behind the DCC-EX command station. It generates the necessary power (voltage and current) and transfers the DCC signal to your layout to control your trains.

The motor shield plugs directly into the Mega 2560 and sits on top of it.

  • The power output block (the blue, or sometimes green, terminal block with 6 screws) on the motor shield should face the same direction as the USB port on the Mega 2560 board
  • NOTE: Ensure the power pin labeled “Vin” or “VCC” is NOT aligned within the Mega 2560 board (see image below – that pin should hang outside of the Mega 2560 female header. This is so the power of the Mega 2560 board and the motor shield can remain isolated from each other)
  • Carefully align all pins and verify that every pin is entering its matching socket before pressing the boards together.
  • The final result should look like the image below (take note of the single Vin/VCC pin which is NOT sitting in the female header)
warning

Warning!

Aligning the Vin/VCC pin is the single most important step in the build. If the Vin/VCC pin is inserted into the Mega header, the Arduino and motor shield power supplies become connected together, which can damage the hardware.

Here’s an up-close image of the motor shield’s Vin/VCC pin slightly bent out so it does not sit in the female header of the Mega 2560 board. You can cut-off that extending pin if you prefer.

Connect WiFi to Motor Shield

  • Remove any jumpers on the WiFi shield’s 24-pin header (you can either remove the small black jumpers completely or have them hanging off a single pole on the header). These jumpers are only used when programming the ESP8266. They must be removed for normal operation with DCC-EX.
  • The WiFi board sits on top of the Motor Shield
  • The 24-pin header on the WiFi shield must be positioned opposite the USB port on the Mega 2560 board
  • Carefully align all pins and verify that every pin is entering its matching socket before applying pressure to the WiFi shield (note the pins might not seat entirely within the female headers – this is okay)

Connect Jumper Wires

Two jumper wires are required to connect the Mega’s serial port to the ESP8266 WiFi module. TX1 transmits data from the Mega to the WiFi shield, while RX1 receives data back from the WiFi shield. This allows the Mega to communicate with a wireless throttle, such as DCC Commander, via a WiFi network connection.

  • Connect one jumper wire from pin 18 (labeled TX1) on the Mega 2560 board to the left-most pin on the first row of the 24-pin header of the WiFi shield (see the text and arrows in white on image below)
  • Connect a second jumper wire from pin 19 (labeled RX1) on the Mega 2560 board to the right-most pin on the first row of the 24-pin header of the WiFi shield (see the text and arrows in yellow on image below)
information

Note

The left-most and right-most pins are referenced when holding the Mega 2560 board such that the USB port is pointing upwards and the WiFi shield pointing towards you (also, see arrows on image below)

Jumper wires connected to the Mega 2560 and WiFi shield:

The assembled DCC-EX command station:

Assemble Power Plug

Assemble a power plug to be used for easily plugging in the power supply for the layout to control your DCC trains and accessories.

  • Cut 2 wires about 4″ long using the 20 gauge wire and strip about 1/4″ of insulation from both ends
  • Loosen the screws in both of the terminals of the power connector
  • Insert the wires into the slots below the screws
  • Polarity matters, note the + and – on the power connector above the screws (for consistency, use the red wire for the + connector and the black wire for the – connector)
  • Tighten-down the screws in both of the terminals of the power connector to secure the wires
  • Gently tug each wire afterwards to ensure it is secure
  • Ensure no exposed copper is visible

Cut Track Power Wires

You will need wires to connect the output of the motor shield to your layout to control trains and accessories.

  • Cut 2 (or optionally, 4, if you’re going to use a programming track in addition to the Main track) pieces of 20 AWG wire long enough to reach from the DCC-EX to the track on your layout (for consistency, use red wire for + and black for – )
  • Strip about 1/4″ of insulation from all ends of the wires

Connect Power Plug to Motor Shield

  • On the blue power terminal strip on the motor shield, locate the Power In + and Power In – poles (these should be located just above the USB port on the Mega 2560)
  • Loosen the screws in both of the terminals
  • Insert the wires from the power plug into the slots below the screws
  • Polarity matters, note the + and – on the power connector above the screws
  • Tighten the screws in both of the terminals of the power connector
  • Gently tug each wire afterwards to ensure it is secure
  • Ensure no exposed copper is visible

Connect Main Track Power Lead Wires to the Motor Shield

  • On the blue power terminal strip on the motor shield, locate the PA + and PA – poles (these should be located just above the USB port on the Mega 2560)
  • Loosen the screws in both of the terminals
  • Insert one black wire (on the – pole) and one red wire (on the + pole) below the screws
  • Polarity matters, note the + and – on the power connector above the screws
  • Tighten the screws in both of the terminals of the power connector
  • Gently tug each wire afterwards to ensure it is secure
  • Ensure no exposed copper is visible

[Optional] Connect Programming Track Lead Wires to the Motor Shield

  • On the blue power terminal strip on the motor shield, locate the PB + and PB – poles (these should be located just above the USB port on the Mega 2560)
  • Loosen the screws in both of the terminals
  • Insert one black wire (on the – pole) and one red wire (on the + pole) below the screws
  • Polarity matters, note the + and – on the power connector above the screws
  • Tighten the screws in both of the terminals of the power connector
  • Gently tug each wire afterwards to ensure it is secure

Complete Hardware

Congratulations! Your DCC-EX hardware is built and ready to use. It should look something like this:

Final Hardware Checklist

Before applying power, confirm each item below:

✅ Motor shield fully seated on Mega 2560
✅ Vin/VCC pin NOT inserted into Mega 2560
✅ WiFi shield jumpers removed
✅ WiFi shield fully seated on motor shield
✅ TX/RX jumper wires installed from Mega 2560 to WiFi shield
✅ Power plug polarity correct
✅ Main track and programming track wires polarity correct

Initial Power-Up

A quick test to verify everything is looking good. After applying power, if you feel any heat from any of the boards or see any visible smoke then disconnect power immediately and review the checklist again. If you saw smoke then you’ll likely have to replace the part that smoked – extremely rare though!

  • Power on the Mega using the 9V power supply first on its own
  • You should see a solid green LED light up on the Mega and possibly some blue LED’s blink on the WiFi shield but not much else to see yet
  • While keeping the Mega 9V power supply plugged in, plug in the motor shield 12V power supply
  • You should see the 4 LED’s next to the blue power header on the motor shield blink. Pressing the small toggle button on the motor shield should reset the motor shield and blink those lights again. Not much else to see yet
  • If the LED’s light up then you can claim success. Congratulations!

Next Step

The next step is installing the DCC-EX firmware. Once that’s done, you’ll be ready to connect your command station to your layout and begin running trains.

Repairing a stuck Woodpecker Precision Router Lift

A router is a woodworkers best friend. The PRL from Woodpeckers makes it the perfect friend! I’ve been using my PRL V1 for almost 15 years without issue. The PRL V1 is no longer for sale – the PRL V2 has taken its place. Recently, the handle crank became hard to turn. After some digging-around and unscrewing, it turns out this was caused by dust between the nylon gear and the faceplate. Here’s how I fixed the issue.

Place the PRL on a sturdy surface:

You will need some tools: 9/16″ wrench, 4.5mm Allen wrench, and some lubricant (I used 3-1 oil but WD-40 or similar will work fine):

Place the PRL on its side with access to the 9/16″ bolts which hold the router in place:

Remove the router from the PRL for easier access to the gears and chain:

Once the router is removed, flip the PRL on its face with access to remove the gears and loosen the chain. Locate the gear underneath the crank handle (it’s the one with large metal stop-system and two Allen nuts) :

Unscrew the two Allen nuts to remove the stop-system:

One the adjacent side of the PRL, remove the single Allen nut holding the metallic gear:

the chain should flow freely to create slack to access the gears:

Now loosen the chain from around the nylon gear located below the hand crank:

Turn and pull the nylon gear by hand until it comes free from the face plate:

Now comes the fix! Clean the base of the gear and the inside hole on the face plate. First with a dry cloth or paper towel to get ride of the larger debris. Finally spray the areas with oil/WD-40. No need to use very much as it will dry eventually; use just enough to slide the gear back into the faceplate.

Once it’s all clean, slip the nylon gear back in the faceplate, place the chain back on the nylon gear, place the chain back on the metal gear, and screw the Allen nut so the metal gear is secure and the chain flows around all four gears. Re-secure the metal stop-system to the top of the nylon gear with the two Allen nuts. Finally, re-mount the router into the Lift.

Give the crank a whirl! Hopefully it’s back to new and cranks easily.

Getting a second video monitor to display correctly after resuming Windows 10

I run windows 10 and once in a while my second video monitor will remain dark after coming out of a suspend mode (sometimes even just turning off the monitors and turning them back on!). I believe this is an issue with the NVidia video card I have installed since I can get the monitor to refresh by restarting the device (or rebooting the PC).

Here’s how I solve this issue …

1. On the Windows Desktop (or some other folder if you prefer) create a new file named ResetVideoAdaptor.bat. You can use Windows Notepad or any text editor to do this. Just make sure the file extension is named ‘.bat’ and not ‘.txt’
2. Add the following lines to your ResetVideoAdaptor.bat file (see additional steps ‘how to customize for your system’ below)

@echo off

REM see details on blog.electrongoo.com to set your specific adaptor id!
SET MY_VID_ADAPTOR_ID=*PCI\VEN_XXXX*YYYY*

"C:\Program Files (x86)\Windows Kits\10\Tools\x64\devcon" disable %MY_VID_ADAPTOR_ID%
"C:\Program Files (x86)\Windows Kits\10\Tools\x64\devcon" enable %MY_VID_ADAPTOR_ID%

3. To use this batch file, whenever one of your video monitors goes dark, run ResetVideoAdaptor.bat as Administrator (right-click on ResetVideoAdaptor.bat and select “Run as Administrator”) and the video adaptor will be reset and the video monitor will come back to life.

How to customize for your system

You must have Microsoft’s devcon utility installed on your system for this to work. This utility is free and part of the Microsoft WDK which you can download here.

You must update the vendor id and device id in the ResetVideoAdaptor.bat file for your specific video card. You can find these values using Windows Device Manager. In the Windows Search bar type “Device Manager” and press Enter. You should see a window similar to this

Locate your video card under “display adaptors” and right-click and select Properties. From the Properties page select the Details tab and select “Hardware Ids” from the Property drop-down listbox. You should see something similar to this

Now jot-down the vendor id which will be the four digits after the “VIN_” tag (see example below) and the device id which will be the four digits after the “DEV_” tag (see example below).

Finally update your specific four digit vendor id and four digit device id in the ResetVideoAdapter.bat file. Search for “XXXX” and “YYYY” and replace those values with your specific id’s. As an example, for my video card I updated the line

SET MY_VID_ADAPTOR_ID=*PCI\VEN_XXXX*YYYY*

to

SET MY_VID_ADAPTOR_ID=*PCI\VEN_10DE*1187*

Save your final changes to ResetVideoAdapter.bat and your done.

I hope this helps!

Fixing itunes hang on Windows 10

I have a multi-user configuration setup on my Windows 10 PC at home. My entire family can log into their own Windows account and have their own desktop and storage space. This works nicely but I noticed that iTunes is not very friendly with this multi-user configuration – iTunes hangs after sync’ing with an iPhone/ipad and can’t be used again until after a system reboot. Here’s how I resolved this issue: I created a batch file which terminates iTunes and creates a “clean” state …

  1. On the Desktop create a new file called ResetITunes.bat. You can use Windows Notepad or any text editor to do this.
  2. Add the following to the ResetITunes.bat file
@echo off

taskkill /F /IM itunes.exe
taskkill /F /IM distnoted.exe

3. Now, whenever you close iTunes, simply run ResetITunes.bat as Administrator (right-click and select “Run as Administrator”) and iTunes will terminate and be ready for the next user to sync their iPhone or iPad.

Hope this helps!

Copying files recursively in MS Excel with VBA

When managing projects I use a few different off-the-shelf products.  But, it always seems there is some task I need to do that can’t be done efficiently with these tools so I make sure to include MS Excel (Office 365) in my suite of project management utilities.  VBA macros within Excel give me the power to complete any custom tasks I require.

I needed to copy a set of folders (an entire recursive tree) to a new location.  VBA does not natively include this feature.  I searched the web for solutions but it seemed all were either out-of-date (non functional) or simply incomplete (never worked!).  So, I thought I’d share my solution built on the VBA scripting.filesystemobject. Hopefully it will help others. Here it is …

Public Sub TestCopyFiles()
    ' Call the recursive copy operation
    CopyFiles "c:\temp\a", "c:\temp\b"
End Sub

Public Sub CopyFiles(ByVal strPath As String, ByVal strTarget As String, Optional ByVal basePath As String, Optional ByVal baseTarget As String)
    If basePath = "" Then basePath = strPath
    If baseTarget = "" Then baseTarget = strTarget
    Set FSO = CreateObject("scripting.filesystemobject")
    ' First loop through files in this folder
    For Each nextFile In FSO.getfolder(strPath).Files
        fullTargetPath = strTarget + "\" + nextFile.Name
        mkdir (strTarget)
        ' Copy one file
        FileInFromFolder.Copy fullTargetPath
    Next
    ' Next loop through folders in this folder
    For Each nextFolder In FSO.getfolder(strPath).SubFolders
        nextStrTarget = baseTarget + Right(nextFolder, Len(nextFolder) - Len(basePath))
        mkdir (nextStrTarget)
        CopyFiles nextFolder.Path, nextStrTarget, basePath, baseTarget
    Next
End Sub

Private Sub mkdir(folder As String)
    ' Create a folder if it doesn't exist
    Set FSO = CreateObject("scripting.filesystemobject")
    On Error Resume Next
    FSO.CreateFolder (folder)
    On Error GoTo 0
End Sub

Git cheat-sheet

As a recent cross-over user of Subversion to Git, I occasionally need a refresher of some command-line git operations … and I find myself searching the web.  So, I created this list in a single, easy to locate post.  Here is a list of Git operations I find most useful.  Listed in order of a typical workflow.  Hence more interesting (and more easily forgotten) operations are listed at the end.

Initial setup
sudo apt-get install git
Initial configuration
git config --global user.name "Iam me"
git config --global user.email me@here.com
git config --global core.editor nano
git config --global credential.helper "cache --timeout=900"
Configure ignored files (using .gitignore file)
nano .gitignore
*.o
nohup.out
doc/*.txt
.vscode
.idea
Help
git help <command>
Initialize a repository
git init
OR
git clone git://your.git.url.goes.here
View status
git status
git diff
Add/commit files
git add <filename>
git commit
OR
git commit -am "commit message goes here"     (add all tracked files and commit them in a single command)
Remove files
git rm <filename
Move files
git mv <filename> <newfilename>
Updating a commit (before push)
git commit -am 'initial commit'
git add <somefile>
git commit --amend
View commits
git status
Reverting a modified file (not yet staged)
git checkout -- <file
Reverting a staged file (e.g. via git add)
git reset HEAD <file
Reverting a commit
git revert <commit-id>
git push
Reverting all local changes
git reset --hard origin/master
Create a new branch
git checkout -b <name_of_your_new_branch>
git push origin <name_of_your_new_branch
Save/restore work temporarily
git stash
***change branches or whatever
git stash pop
Delete a remote branch
git push origin --delete <branchName>
git fetch -p    "to refresh local repro"
Delete a local branch
git branch -d <branch_name>
git fetch -p    #"to refresh local repro"
Tag a commit (for release or tracking)
git tag -a <tagname> <commitid>
git push origin <tagname>
Checkout at a tag
git checkout <tagname>
Merge a branch back into master branch
git checkout master
git pull
git checkout <branch>
git merge master
# if you have conflicts ... edit the conflicts and then run "git add <files_edited>" "git commit"
git push