Elevated Subway in HO Scale

by Charles R. Hentz


In March of 2021 the club started an elevated subway line in the HO layout.  This was to have a figure eight through Thomasville and Germantown.  However, possible routes were found to extend this to cover most of the layout.  Two powered Proto 1000 MTA (NYC Transit) R-17 Subway cars in Tuscan Red with Silver roof were purchased along with four unpowered cars.  These run very smoothly with two fly wheels and both trucks powered.  However, new out of the box, they did not run at all.  Sitting on the shelf for years causes the lubricant to get stiff.  The shell was removed and oil applied to the bearings of the motor.  Manually forcing the flywheels to turn, allowed the grease to soften.

The elevated line will have two three car trains running at the same time with four station stops.  At each station, the automatic control system will slow the train to a stop, wait about 15 seconds and then accelerate to normal speed.  If the trains gets too close together, then the rear one will be slowed.  Because of the crossover at the figure eight, any train at a station will wait longer if the next station is occupied.

This system uses a Mega Arduino, L298 motor drivers and Allegro ACS712 chip current sensors.  The single track loop is divided into eight sections each controlled by one motor driver.  The gaps between sections are placed a certain distance before each station.  When that section senses a train entering, the time necessary to stop will be written in the code to allow a precise stop at the station.  All section speeds will also be written in the code.  Red LEDs will show all extended waits at stations as well as slowed sections due to traffic congestion.  Eight green LEDs will show which section is occupied.  Manual mode will allow a hand held throttle to control speed and direction.  If two trains need to be repositioned, then by using center off toggle switch on each section of track, an operator will be able to move one train at a time.  A regulated power pack set to maintain exactly 14 Volts DC will provide steady track power.   Each three car train draws less than one ampere.   A separate 12 volt supply will power the control system.

Automating two trains on one track means that no delays are allowed in the code.  Instead the processor must always be doing something.  Like watching two kids, when one needs attention, the other could be in trouble at the same time.  To solve this, there is a clock that runs all the time.  You check that clock to see if enough time has elapsed since the last time you checked.  If it has, then you do something like decrease the speed.  Then take note of the time and save it for reference for the next event.  This code was completed on May 23, 2021.

While constructing the eight sections of track, two of eight L298N motor drivers would not supply current even though the voltage was normal.  Just touching one wire with metal held in your hand would reduce the voltage.  An internet search of circuits using two separate power supplies found that the ground wires of both supplies need to be connected together to avoid erratic behavior.




All current sensors are read by the Arduino Nano and if active, a HIGH is sent to the output to be read by the Arduino Mega microprocessor.  This allows more time for multiple readings and averaging.  To calibrate this Nano code, turn all toggle switches to center off so no current is flowing in each section of track.  Then Serial Read the voltages of the sensors of each section.  Set the trip point at .02 volts less than the no current Serial Read.  This should allow a stable indication whenever a train is in that section by showing a HIGH at the output pin of that section.

The Arduino Mega looks at the input from the Nano and if HIGH, determines that section is occupied.  The Mega will not look at that section again until the next section becomes occupied.  This prevents a false indication when the voltage gets lower due to a stop at a station.   If a section is occupied,  Mega will set that green LED on (or off if not occupied) on the control panel.    If an odd number section of track (station present) is occupied, Mega assigns that train to  StationF or StationS functions depending on which is busy or not.  Mega also controls three red or green signals located at each tunnel.  Any train will wait at a station until the next station is unoccupied.  If three trains are ever indicated, Mega will set all signals to blinking red and stop all trains.

Please keep in mind that this code contains no delays because it must keep control of two moving trains.  That is why we are using millis() which returns the current time since the program started.  By checking this clock, Mega can tell if a certain amount of time has occurred.  If time is completed, then it will execute the actions required. 

The Mega code has several functions which are at the end of the code. 

            RunManual will control the train using the hand held remote which has a potentiometer and a direction toggle switch.

            StationF will decelerate at that stations’ rate, wait for doors open, then accelerate to that sections’ speed.

            StationS will also do the same code but is Second if First is busy.

            TarryFirst will act as a timer for the StationF.

            TarrySecond will act as a timer for the StationS.

            SlowDown will slow any train that is too close to the one in front.