Thursday, April 13, 2017

Cheapest DCC Command Station with Loconet interface

In a previos post I talked about the DCC++ Command Station. This is an open project to build you own DCC command station using the Arduino platform. It's quite simple and easy to mount, and features a full DCC command station with PC interface and compatible with Rocrail and JMRI. This time I want to go a little bit further and be able to build a more standard command station with Loconet interface. There are very cheap and professional command stations like DR5000, for sure much better than this, but building things by your own provides satisfaction, right?

Clicking Here you can read the complete information in my previous post.

Both the protocol and interface of the basic command station project shown in my previous post aren't standard, and despite you can connect to the available Arduino I/O's some sensors, lights or switches, it's not enough for a medium sized layout. Anyway is a good command station to have apart from your layout to program and test locos. It's worth the 12€, for sure.

I took the source code of the DCC++ project (it's open an published in github) and tried (successfully) to add Loconet support, with some goodies like:

  • 3 Led to know the state of the command station (ON, OFF, SHORT CIRCUIT)
  • 2 Buttons to turn on and off the track current
  • 2 relays to switch to the programming track current automatically when a programming command is received
  • Display support, showing CV values when reading or writing and current consumption
  • External emergency button
My new sketch can only work on Arduino Mega. I had to discard Arduino UNO and Arduino NANO support as the program was too big for them, and I wanted to have a better performance with a lower cicle time.

The source code and the sketch to upload to Arduino MEGA can be downloaded from my public GitHub repository:

The PC interface support does not longer exist in this version of the command station, as my intention is to have a pure Loconet command station, exclusively dedicated to manage the trains. I prefer to have individual devices for each function, so for PC interface I use a dedicated Arduino UNO with an Ethernet shield. I'll post the information about how to mount the PC interface for a Loconet network in the next post. All this has the advantage that I can change any device without affecting the other Loconet devices or having to change any setup.

Having an independent PC Interface allows me, for example, to change my Intellibox Basic command station and use my new Arduino Based DCC++, or a DR5000. It's just disconnect one, and connect another. No changes in PC, software, or any other device.

So let's go with the connection diagram:

 You see the base is an Arduino MEGA with the Motor Shield on top and the bridge between pins 2 and 13, exactly as the original DCC++ project.

Then you have the 3 led to indicate "track power connected", "track power disconnected" or "error/fault/shortcircuit".

Two external buttons to turn on or off the track power, plus an extra external emergency button. Pressing this emergency button will provoque sending an emergency stop message through the loconet network, and not a normal power off message like with the normal buttons.

Relays are also optional, but if you use them the isolated track section will have normal current and will switch to programming current just when needed (read or write command received from Rocrail or the program you use). So you don't need to use manual switches or to have a separated track for it.

The display is not exactly the one from the photo, sorry but I couldn't find the right one in Fritzing software, but the connection schema is correct. I'm using an standard Keypad LCD shield from DFRobot (check it here). Two of the keys of the Keypad LCD shield can be used to turn on and off the command station, so the external buttons are not necessary.

Finally, a loconet shield board (like GCA185 from Giling Computer Applications) has to be used, connected to pins 47 and 48 instead of the usual 7 and 8 when you are using an Arduino UNO.

But there is an important issue with Loconet!
Any Loconet network needs a "Loconet Terminator" and a 12V power source to work. This is always provided by the command station, but in this case we need to add this. In this page from RR-Cirkits you can find information about it. 

You can use an old ATX PC power source to supply the 12V to Loconet and build your own "Loconet Terminator".  A "Loconet Terminator" is just a 15 mA pull up constant current source to 12V.:

If you have a LocoBuffer conected to the LocoNet it has also the option to provide this pull up termination by selecting 'Term" option.

Finally there is another solution to the previous issues, this is using a GCA101 from Peter Giling. This a board that provides you 3Amp power to Loconet, so you will never run out of power to connect more and more modules, and the board has also a jumper to activate the "Loconet Terminator" already included in the board. This board also provides you the PC Loconet interface to connect you layout to Rocrail.

This is the command station mounted in a simple electricity box, but we use it in the club and has been proved reliable enough to drive trains during all week end in exhibitions with no errors:

I hope to have more free time to post other Arduino based modules I have developed. Thanks for reading!!!


  1. Hi, thanks for sharing the knowledge!
    is it working now or still a prototype?
    What decoder are you using in the train?

    1. Thanks to you for your comment. It is working, this is the command station I use in my second layout. We tested it with Uhlenbrock, LaisDCC, Kato, Doehler&Haas and Digitrax decoders. All types tested (N scale) work ok.

  2. Hi Dani, Will this integrate with a Digitrax Loconet command station? I'm thinking about using arduino to capture input from some infrared sensors on my layout built based on Digitrax loconet components.

    1. Yes! It will integrate to any Loconet existing system, from Digitrax, Uhlenbrock, Digikeyjs or any other.

  3. This comment has been removed by the author.

  4. This comment has been removed by the author.

  5. Hi,

    finally I made it running. Great project and work done so far.

    There was a correction needed. The grey line from A0 at the display needs to be read analog and the code says 'analogRead(15)'. This is A0 at Arduino Uno but not working with Mega. I connected it to A4 instead of 15 and wrote 'analogRead(A4)'. Then it works.

    Further I added a Long-Ack-Command as reaction to Slot-Write which enabled us to use FREMO Throttles.


    1. There was an error in the schema, now it is corrected. Sorry for the delay answering Philipp!!! Thanks for your advice!

    2. Thanks :)

      Sorry for spamming, I did not see, that my messages came through. Please delete the other with same content.

      BR, Philipp

  6. This comment has been removed by the author.

  7. Connection schema has been updated, there was an error with the connection of the gray wire from LCD Keypad Shield to Mega board. A0 from the LCD Keypad Shield is connected to A15 in Mega board.

  8. Hello Dani Guisado,

    how can i dispatch Fremo Fredi with this command station. it´s very interesting and not so expensive like a DR5000. what released you on the proto shield on the shematic. I´m searching for a cheap loconet station for my small narrow gauge projects in fremo for home use

    1. I don't use Fremo, so I cannot test it... but check the answer from Philipp some lines above, he managed to do it!

  9. hola
    por casualidad,no tendria una tutorial para hacer todo esto.
    soy novato y me lio un poco.

    1. Hola, he intentado escribirlo de la manera mas sencilla posible y con diagramas, pero realmente no es sencillo. Te recomiendo empezar por la central básica, sin loconet, que es el post anterior linkado en este mismo artículo. También puedes ir a la página original o ver los videotutoriales originales:

  10. Hi, Dani. I have assembled your DCC++ with Loconet and find it works great except for one thing: I cannot get responses (either from throttle or IDE monitor) for Functions above F4.
    I am using the latest Loconet library. Perhaps your system is based on a different Loconet library?
    Fred Miller

  11. I reported a problem with servicing functions above F4... turns out the problem only exhibits when using Digitrax UT-X series throttles. Works fine with Digitrax DT402 throttle as well as my own Arduino (loconet) based throttles.

  12. Hello Dany, my question is about the GCA185 Loconet interface. Is it fully compatible with Arduino Mega? I tried to run the Loconet Throttle example supplied with the Loconet Library loaded in a Mega, but unsuccesfully. The same sketch works perfectly with Uno.
    Livio Busnelli

    1. Hi Livio, it is fully compatible, but you cannot plug it on top of MEGA as you do with UNO because the communications pins are not 7 and 8. Communication pins are 47 and 48 instead as you can see in the schema.

  13. Hello Dani
    I have got your loconet version of DCC++ up and running connected to Rocrail and working with locos. Is it possible to control turnouts through DCC with it?
    Anders Thalme

    1. If you use Loconet for sure, this is how I do it. But I never tried using DCC to manage turnouts, I'm not sure...

      Sorry I don't have more experience on that.

  14. This comment has been removed by a blog administrator.

  15. Hi, would it be possible to connect the Loconet Railsync Lines directly to the motor shield's main track output to connect an additional booster? Or what do you think would be the best way to do so? Great project by the way!
    Tom Stirnkorb