Home . LEGO® . DCC

DCC for the RCX

Digital Command Control (DCC) is a means of sending electrical signals over model railroad tracks to control DCC equipped locomotives and accessories. DCC is a standard of the National Model Railroad Association (NMRA). If you want to learn more, they have a DCC Basics page that should get you started. Also, Loy's Toys has a wealth of information on the subject.

LDCC is a program I wrote for the RCX that enables it to act as a DCC Command Station. The command station generates the necessary electrical signals to control DCC equipped train motors. The RCX remote control acts as the throttle. With it, you can control up to 9 locomotives at once.

Disclaimer

This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. The author assumes no responsibility for any property damage or personal injury resulting from the use or misuse of this software. Please exercise caution.

What You Need

Besides the usual train stuff (track, connection wire, etc...), you'll need the following to run LDCC:

If you don't have an RCX remote control, Chris Phillips has developed an excellent program for Windows called Dr. Vegetable's Virtual Remote.

Firmware Download

Once you've downloaded the firmware to your local computer, one way to download it to the RCX is to use the ScriptEd.exe utility in the LEGO MindStorms SDK 2.5. Other firmware downloaders should work, as well.

VersionFileDateComments
1.01ldcc101.srec5/30/2003 Changed Loco bank select keys to Beep + 1 instead of P1. It was too easy to accidently change the bank while using the remote.
1.00ldcc100.srec5/27/2003 Initial release!

Beta versions of LDCC can be found here.

Terminology

Here you can find the definitions of some common terms used in this document:

Decoder  This is a small module (actually a microcontroller board) that you install in a standard LEGO® train motor. Tom Cook has an excellent page covering the installation process.
Command Station  This is the DCC component that generates the electrical signals sent over the tracks to communicate with the DCC decoder in the locomotive. This function is performed by the RCX with the LDCC firmware.
Configuration Variable
(CV)
  Decoders have a number of configuration variables that can be used to adjust the behavior of the decoder. The values stored in these variables are persistant and will be retained even after power has been removed from the track. The manufacturer of your decoder will supply you with a list of CVs supported by your specific decoder. See the Decoder Programming section.
Decoder Address  Each decoder typically has a unique address assigned to it to differentiate it from other decoders. The address is in the range 1 to 127. Before you can use a decoder on your layout, you need to assign an address to it. This is done by programming the address into CV #1. See the Decoder Programming section. Note: DCC also has the notion of a "long address" which can extend the address range up to 9999. However, LDCC currently does not support this feature.

Throughout this document, buttons on the RCX are shown like this: View, while buttons on the remote control appear like this: P1. The Beep key is the button in the lower right corner of the RCX remote.

Some functions require that you press two keys, such as: Beep + 1. This means you hold the Beep key down while you press 1. Think of the first key as a "shift" key.

Setup

In order to have enough power to drive multiple locomotives, you need to hook up the motor outputs of the RCX in parallel. Click on the images below for larger views of the various methods. It's important to hook this up correctly - if you have any questions, email me.

If you want, you can attach a lamp brick to one of the track connection wires. This will let you know when power is applied to the track.

I've been able to run two locomotives with 5-6 cars each using this setup. Ironicly, the locomotives seem to draw the most power when starting up. Once I get more decoders, I'll try to see if I can run more than two trains at once. Eventually, I want to build an external DCC booster so I can free up two of the motor outputs to perform other operations (like operating switches).

Caution: It's quite conceivable you could overload your RCX if you operate too many locomotives or trains that are too long. Do so at your own risk. If you notice that the trains are starting to slow down for no reason (besides a curve), turn the power off to the RCX immediately and let it cool down.

Stand-by & Run Modes

When you first power up LDCC, it starts in Stand-by Mode. In this mode, no power is applied to the tracks, but the RCX will listen for commands from the remote control. Once locomotive commands are received from the remote control, LDCC will shift to Run Mode. In this mode, power is applied to the tracks and commands are issued to the locomotive over the rails.


Stand-by Mode
  
Run Mode

LDCC can handle up to 9 locomotives at a time. These are referred to as Loco #1, #2, etc... By default, the initial decoder address assigned to each Loco is the same as the Loco number. For instance, Loco #3 controls the decoder with address 3. If you wish to change the address assignments, see the Locomotive Options section.

The arrows on the RCX remote control are used to change the speed and direction of your locomotives. The A arrows control Loco #1, the B arrows control Loco #2, and so forth. Since there are only 3 sets of arrow keys, you can only control 3 locomotives at a time with the remote. To control Locos #4 - #6 press Beep + 2 and then start using the arrow keys as normal. For Locos #7 - #9, press Beep + 3. To return to controlling Locos #1 - #3, press Beep + 1.

The longer you hold an arrow key down, the faster the locomotive will go in that direction. Press the arrow keys briefly if you want to make small adjustments in speed. Holding both the up and down arrow keys down at the same time will stop the locomotive. The locomotive headlight can be toggled on and off by pressing the numbered button above the arrow keys.

If you are like me, you may find yourself pointing the remote control at the locomotive when you are trying to control it. Instead, you should keep it pointed at the RCX so that your commands are reliably obeyed (this is important if you want to avoid derailments!)

Run Mode
On-OffToggle RCX power
View Selects other modes:
Drct Direct Mode Programming
PHYS Physical Register Programming
PAge Paged CV Programming
Loco Locomotive Options
ConS Command Station Consisting
RunToggles between Run and Stand-by modes
Beep + 1Selects Locos #1 - #3
Beep + 2Selects Locos #4 - #6
Beep + 3Selects Locos #7 - #9
Up, Down Adjusts speed and direction of Loco
Up & Down Stops Loco (both arrow keys pressed down simultaneously)
1, 2, 3 Toggles headlight function on/off (FL)
Stop Stops all Locos. If pressed more than once, toggles between Run and Stand-by modes.

Decoder Programming

LDCC currently supports the following configuration variable (CV) programming modes:

Note: Support for Operations Mode programming will be added once I get my hands on a decoder with this capability.

When programming a decoder, make sure only one decoder equipped train motor is on the track at a time.

Program Configuration Variable

1)
From Stand-by or Run mode, press View repeatedly until the programming mode you want is displayed in the LCD:

Drct Direct Mode Programming
PHYS Physical Register Programming
PAge Paged CV Programming

Then press Prgm, P1 or P3 to enter programming mode.
2)
Select the CV you want to program using the remote arrow keys. The A arrows change the hundreds digit, the B arrows change the tens digit and the C arrows change the ones digit.


Press P3 to continue.
3)
Enter the value you want to write to the selected CV. Use the arrow keys to change the value.


By default, the value is entered in hexadecimal (as above). Press P2 to switch to decimal:


When you have the value entered, press P3 to write the data. If you have the acknowledgement circuit, you will hear a high tone from the RCX if the write is successful. If you don't have the acknowledgement circuit or a problem occurred, you will hear a low tone.

Continue to step 2 so you can program additional CVs. You can press Stop or Run to exit programming mode at any time.

Read Configuration Variable

If you've built the acknowledgement circuit, you can read CV values from the decoder.

1)
From Stand-by or Run mode, press View repeatedly until the programming mode you want is displayed in the LCD:

Drct Direct Mode Programming
PHYS Physical Register Programming
PAge Paged CV Programming

Then press Prgm, P1 or P3 to enter programming mode.
2)
Select the CV you want to read using the remote arrow keys. The A arrows change the hundreds digit, the B arrows change the tens digit and the C arrows change the ones digit.


Press P1 to start the read process.
3)
The display will show an incrementing number as LDCC attempts to figure out what value is stored in the CV. When a match is found, you will hear a high tone from the RCX. If there is a problem, nAk will be displayed and a low tone will be heard.


By default, the value is displayed in hexadecimal (as above). Press P2 to switch to decimal:


Pressing P1 will take you back to step 2 so you can read another CV.

You can modify the value displayed with the remote arrow keys. Press P3 to write the modified value back to the same CV. Continue to step 2.

Locomotive Options

1)
From Stand-by or Run mode, press View repeatedly until Loco is displayed. Then press Prgm or P1 to enter locomotive options mode.
2)
Select the Loco # using the remote arrow keys or the Prgm key:


Press View or P1 to continue.
3)
Modify the decoder address using the remote arrow keys. The valid range is 1 to 127. By default, the decoder address is the same as the Loco #, but you can change this to suit your needs.


Press View or P1 to continue.
4)
Select the speed mode using the remote arrow keys or the Prgm key. 14, 28, and 128 step modes are supported. 128 step mode is the default. When you change the mode to 14 or 28, be sure to also program your decoder to use the same mode (you may notice strange headlight behaviour, otherwise).


Press View or P1 to continue.
5)
Select the direction using the remote arrow keys or the Prgm key. When r is selected (i.e. reverse), the locomotive's forward and backward directions are reversed.


Press View or P1 to continue back to step 3. You can press Stop or Run to back out of the options mode at any time.

Consist Setup Mode

The functionality is there, I just haven't gotten around to documenting it yet... Stay tuned!

Acknowledgement Circuit (Optional)

This circuit allows the RCX to receive feedback from the decoder in the locomotive. You don't need it in order to program the CVs in the decoder. However, the circuit is nice to have because it makes it possible to read the current CV values out of the decoder.

You can make a simpler version of this circuit by only building half of it. If you hook this version to the RCX and it doesn't work, just rotate the input connector 180 degrees and it will then work (rotating the output end will have no effect).

The resistor is your standard 1/4 watt variety.

More...

For the curious, LDCC is written in C using the H8 GNU cross-compiler. It links to a library I wrote that makes it easier to use the basic hardware of the RCX. The library is written in H8 assembly code to keep it fast and small for use in big projects. At some point, I plan on releasing the source code for both of these (the library still needs work), but it's been enough just to get to this point!

So far, I've converted two train motors to DCC. These motors use the Digitrax DN121 decoder (about $20). I just purchased three Digitrax DZ143 decoders ($28 each) and have installed one of them. I've yet to enhance LDCC to take advantage of some of the additional features available on this decoder, but that should be coming shortly.

I welcome all comments on your experience with LDCC. I'm especially interested in comments about the use of other decoders besides the ones I've listed above. Please send your comments to me here. Thanks!

Tips

Links

DCC for LEGO® Trains:

LEGO® Trains:

LEGO® MindStorms:

General DCC: