DCC Diagnostic Tools¶
*Work in Progress. More detail and pictures soon!*
LEVEL: Engineers or Serious Tinkerers
There are many tools to help you operate your layout and find issues with your trains and accessories. We will list some of the most helpful tools here including where to buy them assembled or how to build them yourself.
Sniffer vs. Analyzer¶
A “sniffer” is a device (often made with an Arduino) that connects to the track to read the data packets and display them as the human readable DCC commands on a serial monitor. It is also sometimes called a “PACKET analyzer” which shouldn’t be confused with “LOGIC analyzer” in the next section. We recommend using our DCCInspector-EX sketch.
Figure 1: Example outputs of a DCC Sniffer. Click on any of the images to view them full size.
A logic analyzer is a device that connects to the Command Station signal pins and to a computer via a USB connection and uses software to capture the DCC waveform for a set period of time. The software can also decode the packets and display them along with the waveform. The display looks similar that what would appear on an oscilloscope. Since it captures the waveform, it can let you see details about the signal that may be causing issues like irregular pulses.
DCC Sniffer (PACKET analyzer)¶
Well it isn’t quite a turnkey solution, but it’s close. You need this shield and an Arduino Uno or Mega and then to download our free DCCInspector-EX file and upload it to your microcontroller with the Arduiono IDE. This is really a well-designed board. It is not only a packet sniffer, but can also be used as a decoder with different software. It has a wealth of configuration options and can even deliver ACK pulses if you use it as a programmable mobile decoder.
It costs about $30 US.
And since it is a shield, you just stick it on top of an Uno or Mega, upload DCCInspector-EX, connect two jumpers to your track, connect the Arduino to your laptop USB and open your serial monitor and you are done.
* Wiring and more info goes here *
Now things get fun! A DCC sniffer is a very simple device that contains only 2 or 3 simple sections. Tinkerers and Engineers will have no trouble cobbling one together or buying a board and soldering on a few parts. You don’t even need anything other than an Arduino or an ESP8266 or ESP32 if you connect to the signal pin of the DCC++EX Command Station instead of to the track.
You will need to upload our DCCInspector-EX software to whatever microcontroller you choose.
Power From Track This part is optional. You can use the USB cable connected to your computer to power everything. If you want the sniffer to be self-contained, for example if you attach a display to see the data or use WiFi to connect to the sniffer from a phone or another computer, then you can power the sniffer from the track OR from batteries.
DCC Signal Interface This is the part that connects to your track and reads the DCC signal and converts it to a safe level for your microcontroller. This can be as simple as a diode, two resistors and an opto-isolator chip.
Microcontroller Decoder This is usually an Arduino of some kind or a WiFi Capable board like an ESP8266 with the DCCInspector-EX sketch.
DCC Signal Interface¶
Connect directly to the Signal output (enable pin) of the Arduino CS¶
Easy! You don’t need an interface since you will bypass the track and connect to the Arduino signal pins that are already at 5V (or 3.3V for some Teensy’s) and seeing only positive going pulses. You jumper wires directly to your command station logic-level direction signal pin to the input pin on your sniffer and from GND to GND on both devices. (DO NOT WIRE TO THE MOTOR BOARD OUTPUTS!!) See the DCCInspector-EX download page for which pins to use.
Connect to the track¶
With this option, you can connect to anywhere on your track. Wiring can be temporary with alligator clips. In order to connect directly to the track, we need something that can isolate the track voltage from your sniffer, rectify the DCC signal so we just get the positive (or negative) going pulses, and level shift the track voltage to a safe 5 Volts to connect to an Arduino. It turns out a diode, a resitor and an optoisolator (aka optocoupler) are all you need for the job! However, to do it right, we do recommend a few other components.
While you could substitute other optoisolator chips and get mixed results, the 6N137 was specifically chosen for it’s switching speed. This allows for more reliable decoding and can even check the accuracy of the DCC signal.
The circuit above represents the minimal number of components to potentially interface the track signal to the microcontroller running your sniffer software. It has been tested and eliminates the issues with many of the circuits available on the web. There should also ideally be a .1uF capacitor across pins 8 and 5 as close to the pins as possible. If you have one, a 1.3k resistor for R1 gives a little better range for track voltages from 10V up to 18V and a LED can be substituted for D1 as a track voltage indicator, though our DCCInspector-EX sketch uses the pin 13 LED to provide the same function.
Another tested circuit (courtesy of Geoff Bunza)
The above is actually a simple circuit to build. To make it easy, Geoff has provided the CAD files that you can download, unzip, and then send the board file to one of many fabricators (like Oshpark) and have them make boards for you. DCC-EX may be selling these, so keep checking back. Here is what the boards look like:
All you need to create your DCC Sniffer is to solder up this board and connect it to an Arduino. You can wire it to an Uno or Mega, but we like to use an Arduino Nano or ESP32 because you can connect the microcontroller and interface both on another carrier board or mount them in a case. The Nano and ESP32 are powered from the USB connection to your computer running a serial monitor, and it, in turn, can send that power to the DCC Interface Board.
Please check out Dr. Geoff’s excellent blog on this board here:
* add info on wiring and sketches here *
Optional Power Supply Circuit
If you always intend to have your computer or laptop connectd via the USB port to read the decoded DCC packets, then you can power everything from the 5V coming out of your USB port. But if you want something standalone, for example a sniffer with a display or that has wireless capability, then you are either going to have to power it from a 5V power supply (like a wall charger) or take your power from the track.
Showing you how to build a power supply here wouldn’t make much sense when you see Geoff Bunza’s 17 function decoder board. It already has everything on it you need, power, optoisolator and space for an Arduino Pro Mini or Nano! You can use that little board to do just about anything you would ever want to do on your layout. Not only can it be programmed to be a DCC Sniffer, but it can be a fully functional decoder with up to 17 functions. It even has the option to have an H-Bridge chip (motor controller) right on the board to power motors!
Geoff Bunza’s 17 Function Decoder AND Sniffer
If you just need the power supply for your own board, use the schematic to get what you need. Here at DCC-EX labs, we use lots of these decoders and solder just the components we need. If we need a DCC interface, we just solder those components. If we need to connect it to the track, we add the rectifier and voltage regulator components.
Ready made circuit boards
17 function decoder
Have them fabricated
DCC Interface board
*TODO: Add this board*
Build it in a case with a display!
And if you want to get into the development of DCCInspector-EX and why we recommend the circuits we do, and see how to add a display and put it in a neat little case, please visit DCC-EX team member Neil McKechnie’s blog. This version has plans for a 3D printed case and uses an ESP32 development board with an OLED display attached.
No need to make this yourself, simply buy it. You will need the following items. They are available under many manufacturer names from many suppliers. Ebay and AliExpress are good sources:
Search for the best source. As usual, you can often find the hardware items from online stores or Amazon, but also find them cheaper on eBay or AliExpress or BangGood direct from China.
Any set of probes that will connect to the pins that are exposed between the Arduino and the Motor Shield will do, however we really like these “T” or “swept wing” probes. They are easy to hold and to open, can accept jumper wires from either side, and are pointed and use tiny hooks so they fit in tight spaces.
Since the install instructions are particular for your operating system, we will just refer you to the SigRok page where you can follow their detailed instructions:
Install the Plugin¶
Download the plugin from the link above and unzip it. Then install it in the user protocol decoder folder. This folder is NOT the main Sigrok folder where the factory installed decoders are. Here is that folder in Windows:
C:\Program Files (x86)\sigrok\PulseView\share\libsigrokdecode\decoders
You want to drop the “dcc” folder you unzipped inside this folder:
It will look something line this. There will be just 2 files. The “cache” file will get created the first time you run PulseView and select the DCC decoder:
Download USB Drivers¶
These device need USB drivers from Saleae. Download and install the 1.x drivers from here:
Connect the Analyzer¶
Connect a jumper wire into a probe if you haven’t already and then connect that into pin 0 or 1 on the logic analyzer
Connect a jumper wire into a probe and connect the other end of the jumper into the GND pin on the analyzer
Connect the GND probe to GND on the Arduino
Connect pin 0 or pin 1 probe to the DCC signal output (enable pin) you want to measure on the Arduino/MotorShield connection. For the MAIN track, this would usually be pin 13 for a STANDARD_MOTOR_SHIELD. Pin 12 would be the PROG track.
Connect the Analyzer to the USB port of your computer
Capture the samples in PulseView¶
Open the PulseView software
Click on the “select device” dropdown and select the Saleae Analyzer
Click on the red probe icon to “configure channels”. Check channel 1 (you could add two more. See below)
Click on the new channel in the left column and give it a name and a height (Main and 26 or more)
If you want to have a channel for PROG and one for a trigger if you want to use a trigger output in DCC-EX to begin the capture, you can add those too.
Select the waveform icon to add a protocol decoder. Choose “DCC”
Click on the new channel and change the name to DCC, then link it in the “data line” dropdown to MAIN (or whatever you named your first channel)
For “01 or 10”, select 10 to display both the bits and the decoded packets. 01 will show just the bits
In the main PulseView window, select “100kHz” for the sampling rate
Next select your data sample size, which will determin how many seconds of data you save. If you select 100kHz sample rate and 100k samples, that is only 1 second. 1 M (as in Mega) is 1 Million sample, so that is 10 seconds.
Get ready to send whatever commands you want to monitor, then hit the “run” button in the upper left corner and run your tests for however many seconds you are capturing.
Analyze the data. You may want to click the “zoom/+” button several times to be able to see the waveform pulses and to have the decoder.
You can save your captures and display them again at any time. More details coming soon.