How to run two trains automatically with a station passing loop
Let two trains take turns round a single circuit, each waiting in its own platform road, using two sensors, two DCC-controlled points and EXRAIL block reservation.
- Time
- 1 day
- Difficulty
- Hard
- Cost
- Moderate cost
- Steps
- 7
- Checked
What you’ll need
- A DCC-EX command station
- An oval (or circuit) with a two-road passing loop at the station
- Two points operated by servos, point motors or accessory decoders the command station can control
- Two IR or Hall-effect sensors Search Amazon for IR obstacle sensor module
- Two speed-matched, reliable locos
- Jumper wire Search Amazon for jumper wires male female
As an Amazon Associate we earn from qualifying purchases. The Amazon links go to search results, so you can compare what’s available.
Before you start
- Make sure both points are set before a train moves: a train running through a wrongly set point can derail or short.
- Don't leave automated trains running unattended.
Step by step
-
Step 1: Understand the plan
Only one train moves at a time. Each train has its own platform road (A or B) and stops at a sensor there. The rest of the circuit is treated as one block. A train must reserve the block before leaving and free it when it's back in its platform. EXRAIL's
Next: step 2RESERVE(block)makes a train stop and wait if the block is already reserved, andFREE(block)releases it (DCC-EX EXRAIL reference). -
Step 2: Fit the sensors
Put a sensor near the far end of each platform road, leaving room for the train to stop. Wire them to two free pins – here 30 (road A) and 31 (road B). Test each one first.
Next: step 3 -
Step 3: Make the points controllable
Define your two points in
Next: step 4myAutomation.hso EXRAIL canTHROWandCLOSEthem – for exampleSERVO_TURNOUT(id, pin, active_angle, inactive_angle, profile)for servos orPIN_TURNOUTfor pin-driven motors (see the EXRAIL reference for DCC accessory points). Check which position (closed or thrown) leads into which road and swap the roads in the script if needed. -
Step 4: Write the script
Add this to
myAutomation.h:``` // myAutomation.h – two trains taking turns round one circuit // Turnout 1 = loop entry, turnout 2 = loop exit (define them first, // e.g. with SERVO_TURNOUT or PIN_TURNOUT) // Sensor 30 = stopping point in road A, sensor 31 = stopping point in road B // Block 1 = the single-track circuit outside the station
SENDLOCO(3, 20) // loco 3 starts in road A SENDLOCO(4, 21) // loco 4 starts in road B DONE
SEQUENCE(20) // the train that uses road A RESERVE(1) // wait here until the circuit is free CLOSE(1) CLOSE(2) // set both points for road A FWD(40) AFTER(30) // wait until we've cleared our own sensor AT(30) // ...and come back round to it STOP FREE(1) // let the other train go DELAY(20000) // 20 s in the platform FOLLOW(20)
SEQUENCE(21) // the train that uses road B RESERVE(1) THROW(1) THROW(2) FWD(40) AFTER(31) AT(31) STOP FREE(1) DELAY(20000) FOLLOW(21) ```
Each train first waits for block 1, sets both points for its own road, departs, waits until it has cleared its own sensor (
Next: step 5AFTER), runs round until it reaches that sensor again (AT), stops, frees the block and waits in the platform. -
Step 5: Upload and place the trains
Upload with EX-Installer. Put loco 3 at the stopping point in road A and loco 4 in road B. Change the addresses in the
Next: step 6SENDLOCOlines to suit your locos. -
Step 6: Run it carefully
Power up and watch the first few circuits with your finger near the power button. Adjust speeds and the platform
Next: step 7DELAY. -
Step 7: Build on it
Once it's reliable you can add signals that change with the points (
SIGNAL,RED,GREEN), random dwell times (DELAYRANDOM) or a third road.
Tips
- Speed match the two locos so stopping positions are similar.
- Use
AFTERbeforeATso a train sitting on its sensor doesn't think it has already arrived.
Questions people ask
Why not use one sensor per road at each end?
You can – more sensors give finer control. This version keeps the wiring minimal.
Can I do the same with JMRI, iTrain or Rocrail?
Yes, with block detection – iTrain (Standard edition and up), Rocrail and JMRI all offer automatic running; see their documentation.
Sources
Checked 18 October 2026. We wrote this guide in our own words, using:
- DCC-EX: EXRAIL command reference (dcc-ex.com)
- DCC-EX: infrared sensors (dcc-ex.com)
- DCC-EX: which sensor type to use (dcc-ex.com)
- DCC-EX: install the software with EX-Installer (dcc-ex.com)
Was this guide helpful?
Report a problem with this guide
Printed from dcctrainautomation.uk/guides/automate-two-trains-with-a-passing-loop/ · Checked 18 October 2026 · General information only. Follow the maker’s instructions for your own equipment, and keep mains wiring inside properly made, enclosed power supplies.