LCOS and the Arduino bridge

How the switches, detectors and signal lamps out on the layout talk to the computer.

Radio nodes under the layout

HART's field wiring uses LCOS, a wireless layout control system from Beagle Bay. Instead of running long cables back to one big panel, small client nodes sit in cabinets next to the switches and signals they look after, and talk to each other by radio. There are about a dozen of them around the room.

Wiring diagram of one LCOS client node with its input, output, signal driver and block detector boards
One client node: an Arduino Nano with a radio, an eight-input board, eight-output boards for 12-volt switch motors and 5-volt lamps, and block occupancy detectors. A layout control bus carries power to all of it.

Each node has a radio address, written in octal. The master, 00, sits by the helix. Nodes 01 to 05 talk to the master directly, and a three-digit address is a node hanging off one of them: 041 is the fourth node attached to node 01. Its messages pass through 01, so it has to be within radio range of it. The bridge to the computer is node 015.

Floor plan grid of the layout room with each LCOS radio node address in the square where that node sits
Radio addresses on a floor plan of the room. Orange squares are benchwork, and each address is in the square where its node sits. Yellow squares are the nodes in service: the master (00), the five nodes that talk to it directly (01 to 05), 012 at East End, 013 at the Barn and the bridge, 015.

What a node does

The wiring viewer shows every node pin by pin.

The bridge

The computer running JMRI has no radio of its own. The bridge is one more Arduino Nano with the same radio, plugged into a PC by USB. It joins the LCOS network as a node and hears what the others say. A small Python program on the PC passes each message on to MQTT, a lightweight message service that JMRI is also connected to.

  1. Nodes on the layout
  2. Radio
  3. Arduino Nano
  4. USB to the PC
  5. MQTT
  6. JMRI

Messages go both ways. From the layout come switch positions, occupied blocks, and what each signal is showing. To the layout go commands to throw a switch or set a signal to red, yellow or green. Every device has a number built from its node and its place on that node, so the first signal on node 4 is 432.

Keeping the link alive

The PC checks in with the Nano every few seconds. If the radio link drops, the bridge signs back up with the nodes on its own, and a lamp on the dispatcher's panel shows whether LCOS is connected.

Open source

The bridge firmware and the PC program aren't specific to HART. They work on any LCOS layout with a JMRI MQTT connection, and the code is on GitHub: LCOS_ESP32_MQTT_Client.

More: How the signals work · Wiring viewer · Device viewer · Layout documentation