Basic Layout Control Nodes

In the last post I introduced the basic building block of my layout control system — the Layout Control Node or LCN. An Arduino board equipped with a wireless communications device constitutes a basic LCN.

In this post I describe the standard hardware components I use when assembling a functional LCN. I’ll also talk about the layout power bus you will need to support an LCN network.

The Arduino Board

The NANO is my standard LCN microcontroller.

An Official Arduino NANO, V 3. The NANO is fairly popular so it is widely cloned and adapted to specific uses.

The NANO works well for LCNs for a number of reasons:

  • Its a space efficient design that has a built-in UART for USB Serial monitoring and programming
  • It has the same capabilities as an UNO.
  • Its an older, popular board design, so it is readily available inexpensively; there are also some new variants that include built-in communications devices.
  • It is a 5 volt board; for model railroading purposes, the 5 volt boards work best with most peripherals.

Can you use a different board? Sure. I use a Mega 2560 in one situation because the sketch requires a great deal of memory, but that is the only instance. Everywhere else I use a Nano with peripheral devices as needed. As you follow along I think you will see that I gain an lot from standardizing on the NANO.

Here a Mega has been converted to an LCN by removed the old Ethernet shield and mounting an nRF24L01 header on a custom pin breakout shield I created. This Mega monitors 24 blocks for occupancy and runs turnouts, signals and lights on Module 1 lower level, so it is quite busy.

Wireless Communications

I have selected the nRF24L01 radio as the LCN wireless communications device. It is a high performance, ultra low power transceiver that works in the 2.4 GHz range. These are really inexpensive, costing a $1 or less each in a modest quantity [Amazon, Aliexpress].

nRF24L01 Radio. Supply power from the NANO 3v3 output pin; all other pins are 5 volt tolerant so level shifting is NOT required.

With all the interest in IOT (Internet of Things) these days, most people gravitate to IP-based WIFI devices when they think of wireless communications. All of my early experiments were with WiFi and wired Ethernet using the TCP/IP protocol.

IP technologies have been around a while, so the parts are mature and reliable. But the processing demands of the protocol introduce noticeable lag on the relatively slow micro-controllers we use (relative to Intel or Apple computers), particularly with traditional shields that rely on the micro controller for message processing.

ESP01, ESP12 and ESP32 from Espressif systems represent a significant improvement in Arduino IP communications; essentially they are microcontrollers with WiFi built in. They perform well and would be viable on a layout. Their main drawback is they have relatively few general purpose IO pins so they aren’t a complete substitute for a standard Arduino. Also, they do not support high speed serial wire protocols — like I2C or SPI — so their ability to communicate with other Arduino’s by wire is limited to standard serial data rates.

That said, the ESP01 [Amazon with programmer, Amazon bulk, Aliexpress] would be the right choice for a basic LCN if you went IP, and with careful coding performance will be fine.

An ESP01 board. Like the nRF24L01, this has an 8 pin header for interfacing with an Arduino. The pin-out, however, is completely different. Also, since this is a programmable microcontroller, but is doesn’t have a programming port, you need a USB to Serial adapter.

All IP devices suffer from a common problem — relatively high power requirements. The specifications for WiFi are for standard computing devices seeking to connect within a few hundred feet of an access point, which takes power. When using a lot of these devices, having to supply 100 – 300 mA to each one, in addition all other power loads, represents a significant burden on a layout. Wired Ethernet is the worst offender, causing load and heat problems with every shield I tried. WiFi is better, but still power hungry.

For these reasons, LCNs are not an ideal context to use either WiFi or wired Ethernet. What an LCN needs is short range but very fast communications. It need only reach nearest neighbors to guarantee it can send and receive freely. Because a mesh network requires nodes to cooperate to pass messages, overall transaction speed on each hop is what matters the most.

In contrast to ESP devices, the nRF24L01 does not have a built-in protocol stack; instead relatively simple protocols are implemented in software libraries on the attached microcontroller. What the nRF24L01 offers is fast transmission speeds up to 2Mbps, ultra low power consumption of 12 mA when transmitting and about 26 μA in standby (you read that right – 26 micro amps). It is a 3.3 volt chip; power is easily supplied by the Nano’s 3V3 aux power output so there is no need for a separate 3.3v supply.

The radio connects via SPI, using 2 dedicated pins on the NANO in addition to shared SPI pins, providing rapid Arduino-to-radio communication. All IO lines are 5 volt tolerant, so level shifting is not required.

The software implementation creates a self-healing mesh network that does not require a router and can support over 3000 nodes. You read that right, too.  More about that in an upcoming post.

IO Expansion

The small size of the NANO makes direct connection to pins difficult, and there is no way to easily mount a NANO to a substrate on its own. Fortunately, a large selection of “IO Expansion” boards are available to solve both problems. These are boards, a little larger than a NANO, that have headers to receive a NANO and either terminal blocks or pin headers to give access to NANO pins. They usually include mounting holes.

NANO IO Expansion boards are readily available and come in a number of common configurations. Some simply hold the NANO, have screw terminal blocks for connections and a couple of mounting holes. Others have additional connectors, including power jacks and 3-pin headers for servos. Finally, a subset have a header ready for a communications device of some kind, such as an nRF24L01 or ESP01.

IO Expansion Board selected for my LCNs.

I’ve chosen an IO Expansion board that includes an nRF24L01 header along with terminal blocks and a power jack. It is marketed under “Emakefun” name and available on Amazon. Other brands are available on Aliexpress.

All three components of a basic LCN.

Power & Wiring

Your LCNs and the devices they run will need power.  DCC users could, I suppose, tap into track power, rectify it and use a DC-to-DC Buck Converters or some other power regulator to get the voltage right.

Before doing that, I’d want to add up all the potential loads to see if I might be pushing the limits of the DCC system, which is quite possible. I’d also want circuit breakers on every track feed to prevent shorts on the rails from shutting the entire system down.

The better solution for safety and power management is to have a Layout Control Bus or LCB that is independent of the track bus. The layout control bus should be powered by an independent DC power supply with sufficient capacity to handle the intended load.

Voltages Needed

The NANO is a 5 volt device, and the microcontroller can be powered from USB. However, when powering the board from an external power source other than USB, you have to provide power in the 7 to 12 volt range.

For powering LCNs, you should supply 12 volts DC power. For model railroaders that is a convenient voltage because many of the accessories we might work with, including most stall-motor turnout machines, require 12 volts DC.

You will also need a 5 volt supply. This power is for logic devices other than your Arduinos, and for servos, steppers and other 5 volt motors you might use for turnouts and layout animation.

So I recommend a 3 wire Layout Control Bus: 12 volt, 5 volt and Ground.

The easiest way to supply the LCB is with a multi-voltage power supply like a Mean Well RD-125A, or something like it.

MEAN WELL RD-125A offers both 5v and 12v with a common ground. It is available on Amazon, Mouser, Aliexpress and elsewhere.

You could also use 2 DC power supplies, and tie the two grounds together. Smarthobby LLC has a selection of appropriate single voltage power supplies. You’ll find similar products everywhere electronics are sold. The advantage of two power supplies is you can tailor current capacity to your actual needs.

I use converted computer power supplies which gives me an additional 3.3v power option. So I have a 4 wire LCB in addition to the 2 wire track bus:

Typical Bus tap. Green & Purple are track, Blue = +3v, Red = +5v, Yellow = +12v and Black is Ground.
Each Module interconnects with its neighbors at a junction like this. Wired Ethernet has been removed in favor of wireless LCNs since this picture was taken.

Using A Basic LCN

What can you do with a basic LCN and no additional devices?

Quite a bit, actually.  At this point you have 8 analog pins and 8 digital pins (3 PWM) available. Keeping the native current limits of a NANO in mind, a basic LCN could service two servos, monitor a few buttons/switches and a run a few leds. So a single basic LCN could reasonably support a small layout zone with a main track plus a siding, 2 turnouts, 2 signals and a small local control panel to control the turnouts.

A basic LCN deployed on Module 2. This one directly manages 2 turnout servos, communicates by wire with the JAX Tavern controller, and [with the help of peripherals] manages all the lighting (and eventually signals) on Mod 2 lower level.

A second basic LCN can serve as Master Node and provide wireless command access to the first, and to additional LCNs as you add them, creating a mesh network of LCNs.

Temporary Master LCN
Module 2 Lower Level

Coming Next

A basic LCN can do a lot on its own, but it needs peripherals to overcome pin count and current limitations to handle any significant number of servos, lights or buttons/switches. Block occupancy detection, well within the capabilities of an LCN, requires CT sensors on block feeders. To fully manage track and turnout power, a peripheral is needed to control polarity reversing relays.

In the next post I’ll go over essential peripherals you’ll need to empower LCN’s to service your layout.

Leave a Reply

Your email address will not be published. Required fields are marked *