Adding Servo-Controlled Turnouts to Your Model Railway with DCC-EX and EXRAIL

Adding Servo-Controlled Turnouts with DCC-EX, EXRAIL and PCA9685

This support guide explains how to add reliable, low-cost servo turnout control to a working DCC-EX command station using a PCA9685 16-channel I²C servo controller and EXRAIL.

It covers wiring, HAL setup, turnout definitions and basic servo calibration.

Before you begin: this guide assumes you already have a working DCC-EX command station. If you are using the CSB1 Ready-to-Run system, your main command station setup is already handled and you can use this guide only for adding servo turnout expansion.

Which setup are you using?

Setup type How this guide applies
CSB1 Ready-to-Run system Your main DCC system is already complete. Use this guide when adding PCA9685 servo turnout control.
CSB1 Core / custom setup Make sure your command station, power supply and basic DCC-EX setup are working before adding servos.
DIY DCC-EX build Confirm your I²C wiring, firmware and command station configuration before continuing.

Hardware You Need

To add servo-controlled turnouts, you will need:

  • Working DCC-EX command station
  • PCA9685 16-channel I²C servo controller board
  • Servos — one per turnout
  • Regulated 5V power supply for the servos
  • I²C connection to your command station, such as Qwiic or SDA/SCL pins
  • Common ground between the command station, PCA9685 and 5V servo power supply

The PCA9685 is used as an expansion board. It allows one DCC-EX command station to control multiple servos for points, turnouts, signals or accessories.

Power warning: do not power servos directly from the command station. Use a separate regulated 5V servo power supply connected to the PCA9685 servo power input. The command station ground, PCA9685 ground and servo power supply ground must be connected together.

Note: many users with the Ready-to-Run system will only need to focus on the PCA9685, servo power and EXRAIL configuration steps below.


Wiring the PCA9685 Servo Controller

  1. Connect SDA on the PCA9685 to SDA on the command station.
  2. Connect SCL on the PCA9685 to SCL on the command station.
  3. Connect VCC for logic power, usually 3.3V or 5V depending on your board and setup.
  4. Connect GND between the command station and PCA9685.
  5. Connect your separate 5V servo power supply to the PCA9685 servo power input.
  6. Connect the servo power supply ground to the common ground.

Common ground example

Command Station GND  ─┬─ PCA9685 GND
                      └─ 5V Servo PSU GND

Without a shared ground, the servos may behave unpredictably or fail to respond correctly.


Checking I²C Detection

After wiring the PCA9685, power up the command station and check the console log. DCC-EX should list detected I²C devices and show the PCA9685 address.

The most common PCA9685 I²C address is:

0x40

If the console shows:

< No I2C Devices found >

Check the following:

  • SDA and SCL are connected correctly
  • The PCA9685 has logic power
  • Ground is shared with the command station
  • The board is connected the correct way round
  • The PCA9685 address has not been changed

HAL Configuration for PCA9685

Declare the PCA9685 in myAutomation.h using the HAL(...) macro.

Example PCA9685 HAL entry

// start vPin, count, I2C address
HAL(PCA9685, 100, 16, 0x40)

This creates 16 virtual pins, starting at vPin 100.

vPin to PCA9685 Channel Map

vPin PCA9685 Channel
100 Channel 0
101 Channel 1
102 Channel 2
... ...
115 Channel 15

Adding a second PCA9685 board

If you add another PCA9685, it must use a different I²C address and a different vPin range.

HAL(PCA9685, 116, 16, 0x41)

Defining Servo Turnouts in myAutomation.h

After registering the PCA9685 with HAL, define each servo turnout using SERVO_TURNOUT.

Syntax

SERVO_TURNOUT(id, vPin, active_angle, inactive_angle, profile, description)

Basic example

SERVO_TURNOUT(1, 100, 250, 250, Fast, "Turnout 1")
SERVO_TURNOUT(2, 101, 250, 250, Fast, "Turnout 2")

In this example:

  • 1 and 2 are the turnout IDs
  • 100 and 101 are the vPins assigned through the PCA9685 HAL entry
  • The angle values are placeholders for calibration
  • Fast is the movement profile
  • The final text is the turnout description

Calibrating Servo Angles

Servo angle calibration is usually the most important part of turnout setup. Start gently and avoid forcing the turnout mechanism.

  1. Start with both servo angle values the same, for example 250, 250.
  2. Use EX-Toolbox or your preferred DCC-EX method to test movement.
  3. Adjust the active and inactive values gradually.
  4. Upload the updated configuration.
  5. Test the turnout in both directions.

Test commands

<T 1 C>
<T 1 T>

These commands test turnout ID 1 in the closed and thrown positions.

Calibration tip: do not allow the servo to push hard against the turnout end stops. If the servo buzzes or strains, reduce the travel range.


Recommended Expansion Path

For a simple DCC-EX layout, the best approach is usually:

  1. Start with a working DCC-EX command station
  2. Confirm train control is working reliably
  3. Add the PCA9685 servo controller
  4. Configure servo turnouts in EXRAIL
  5. Add more automation later if required

Using a CSB1 Ready-to-Run system? You do not need to rebuild the command station. Add the PCA9685 servo controller as an expansion module, then follow the configuration steps in this guide.


Troubleshooting

Problem Likely Cause Check
No I²C device found SDA/SCL wiring, power or address issue Check wiring, ground and I²C address
Servo does not move No servo power or incorrect vPin Check 5V supply and HAL mapping
Servo jitters Weak power supply or poor grounding Use a regulated 5V supply and common ground
Turnout buzzes Servo over-travel Reduce active/inactive angle range

Useful Products

The following products may be useful when adding servo turnout control to a DCC-EX layout:


✅ Your DCC-EX command station can now support servo-controlled turnouts through EXRAIL and a PCA9685 servo controller.