DCC Train AutomationAn independent UK guide to automating a DCC model railway — home

Automation projects

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
Report a problem

What you’ll need

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.
Circuit with station passing loopT1T2road B (sensor 31)road A (30)block 1: single-track circuit
Wiring diagram Each train has its own road in the station; the rest of the circuit is one reserved block.

Step by step

  1. 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 RESERVE(block) makes a train stop and wait if the block is already reserved, and FREE(block) releases it (DCC-EX EXRAIL reference).

    Next: step 2
  2. 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
  3. Step 3: Make the points controllable

    Define your two points in myAutomation.h so EXRAIL can THROW and CLOSE them – for example SERVO_TURNOUT(id, pin, active_angle, inactive_angle, profile) for servos or PIN_TURNOUT for 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.

    Next: step 4
  4. 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 (AFTER), runs round until it reaches that sensor again (AT), stops, frees the block and waits in the platform.

    Next: step 5
  5. 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 SENDLOCO lines to suit your locos.

    Next: step 6
  6. 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 DELAY.

    Next: step 7
  7. 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 AFTER before AT so 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:

  1. DCC-EX: EXRAIL command reference (dcc-ex.com)
  2. DCC-EX: infrared sensors (dcc-ex.com)
  3. DCC-EX: which sensor type to use (dcc-ex.com)
  4. DCC-EX: install the software with EX-Installer (dcc-ex.com)

Tags: automation block reservation DCC-EX EXRAIL passing loop points

Was this guide helpful?

Report a problem with this guide
What’s the problem?

Please don’t include personal details we don’t need. See our privacy notice.