Automated Signals Using Arduino (Block Detection) - Part 1 of 2

For some time I have wanted to install Automated Block Signalling ("ABS") on my model railroad.

From Wikipedia, the definition of ABS is: "a railroad communications system that consists of a series of signals that divide a railway line into a series of sections, or "blocks". The system controls the movement of trains between the blocks using automatic signals. ABS operation is designed to allow trains operating in the same direction to follow each other in a safe manner without risk of rear-end collision."

Following is a graphic depicting how an ABS system works.



There are several such systems on the market which are available for purchase. I find that these are either more than I am willing to pay or more complex than what I had in mind. Since I have had good experiences with the use of Arduino microcontrollers I had been thinking about how to design my own ABS using Arduinos. My biggest stumbling block was how to have one Arduino communicate to another and vice versa. All the methods I could find descriptions of were difficult for me to understand.

A few months ago I subscribed to a YouTube channel called DYI and Digital Railroad which is hosted by a personable fellow whose first name is Jimmy. Jimmy posted a video describing exactly what I was looking for. Here is a link to Jimmy's video (thank you Jimmy)  DIY Arduino Model Railroad Multiple Block Signal System. He also posted the complete Arduino code that he used to power all of the interconnected Arduinos, each of which controlled the signals which protect a block of the track by lighting the appropriate signals at each end of the block.

As can be seen in the above simple graphic, the train is located in the block which shows it is "Occupied". The signal facing to the rear of the train (which would be seen by the engineer of a train following) turns red, protecting the block against encroachment by the following train. When the Arduino changes the signal state to red it tells the Arduino to its left that it has done so. The Arduino to the left changes its signal state to yellow which cautions an approaching train that the block which is two ahead is occupied.

Each Arduino actually controls two signal towers, one facing out from the left of the block and the other facing out from the right of the block (not drawn in the above diagram). This ensures protection for each block in each direction. Each Arduino communicates to both adjacent Arduinos which control the adjacent blocks.

The "out" signal to both adjacent Arduinos is sent using digital pins. It is read using analog inputs by the adjacent Arduinos. The digital output is either "on" or "off" and is read by the adjacent Arduinos as having a value of 1,023 (can be lower because of line losses, signal noise, etc.).

Jimmy's presentation introduced me to a device made by the Digital Command Control ("DCC") system manufacturer NCE. The device, called a BD-20, can be installed very easily in an existing layout by making a fine cut in one of the rails at each end of the block for which you wish to detect the presence of a train. The wire which feeds this rail is looped through the sensing ring mounted on the top of the BD-20.

The BD-20 is powered with 12 volt DC and has a "logic" terminal which is connected to the appropriate Arduino input pin.

When a locomotive or other rolling stock that draws current occupies the block the BD-20 will communicate the occupancy to the Arduino.

Here is a graphic depiction of the key attributes of the setup:




In Part 2 of this post I shall explain how I built my own signal heads. I will also share the complete Arduino code - I tweaked Jimmy's code somewhat to overcome a couple of small shortcomings.