Train Detection and Signal Control

I am working on a modest layout (see New to the Scene) and I am now at the stage where I would like to add entry and exit signals at the two stations in the layout. I first thought of making my own signals, but N-scale quickly presents its special challenges due to its smallness. Achieving scale-correct appearance of objects is often difficult or impossible without special materials or manufacturing methods. Although my theme is Switzerland with SBB and BLS trains, I found the Viessmann signals, while modeled after the German railway system, very similar in appearance to the Swiss signals, and very nicely made on top of it.

My trains run on an analog system that I designed before the advent of DCC, and I can run 8 different locomotives independently. But the capability of DCC running all sort of ancillary equipment is naturally missing in my system. I am also not interested in running trains automatically with a block system controlled by signals as the layout is too small to run two trains in sequence on the same track. Even realistically long trains are not really feasible.

So, if the signals are not used to control the trains, perhaps the train controlling the signal is a realistic alternative. The signal is normally red and as the train approaches, the signal turns green and then returns to red once the train has passed. If a train approaches from the opposite direction (while shunting for example), the signal must remain red.

This requires detection of the train before and after the signal, of course. There are many ways to detect the presence of a train, infrared optically, magnetically with reed switches buried in the track and magnets attached to the train underside, with ultrasound sensing, or by sensing the locomotive current which is probably the least obtrusive method. The diagram below shows the live track separated into a block before and one after the signal. Each block is re-fed via a current-sensing transformer that mirrors the locomotive current to a sensing circuit which then controls the signal.

The Arduino platform is well suited to process the locomotive mirror current and to control the signal. It is also reasonably priced. The Uno has 6 analog inputs and 14 digital inputs/outputs whereas the Mega has 16 analog inputs and 54 digital input/outputs. The Uno could control 2 signals (not enough digital ports for 3), and the Mega could control up to 8 signals. The signal control program is quite straight-forward.

This train detection method works for AC and DC, provided the DC is not smoothed.


  • Hello Uli:

    That is a very nice system. I use something similar except that I have magnets under my locos and reed contacts in the track. Modelling in H0 allows to mount the magnets invisibly. I think the Arduino opens a complete new world for model railroaders.


  • Thanks Ulrich, I always appreciate your feedback. I like the reed switch idea and explored it too. Unfortunately, my N-scale locos don't have enough clearance over switches to attach all but the thinnest magnet (1/32") which would require the reed switch in the track to almost touch the underside of the loc to be triggered. Even then the reliability is questionable.
    Arduino is very versatile and fun too. I use it to operate a barrier with flashing lights as well.


  • Hello Uli:
    My father had N-scale and used reed contacts. He had to put relatively big magnets under some of his cars. If I were to model in the smaller scale, I would have followed your approach.


  • Great to hear that model railroading obviously runs in your family, Ulrich. I don't think my father would have had the patience for this hobby himself, but he was obviously not averse to the idea. I do remember finding some Trix HO equipment in our attic in Switzerland, probably from my brothers, but it was in pretty sad shape by the time I was old enough to use it.

    Some of my locs could probably carry larger magnets underneath between the bogies, but I wanted a more consistent solution.

Sign In or Register to comment.