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.
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.
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].
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.
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.
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.
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.
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.
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.
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:
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 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.
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.