Automated Point to Point Model Railroad With Yard Siding

2,332

11

11

Introduction: Automated Point to Point Model Railroad With Yard Siding

Arduino microcontrollers open great possibilities in model railroading, especially when it comes to automation. This project is an example of such an application. It is a continuation of one of the previous projects. This project comprises of a point to point model railroad layout with a yard siding to house a train. All of the operations are controlled by an Arduino microcontroller board with the help of feedback mechanism and the train and the turnout is controlled by an Adafruit motor shield.

Step 1: Watch the Video

Watch the video to get an idea of how this works. So, now you know what's going on, let's get started!

Step 2: Get All the Stuff

Here is what you will require for the build:

  • An Arduino board compatible with Adafruit motor shield v2.3.
  • An Adafruit motor shield v2.3.(Click here for more information.)
  • An expansion shield(Optional, recommended to expand the +5V and GND pins of the Arduino board in order to connect the sensors.)
  • 3 'sensored' tracks.
  • 4 male to male jumper wires(2 to connect track power and others to connect the turnout.)
  • 3 sets of 3 male to female jumper wires(A total of 9 wires used for connecting the 3 pins of each sensor to the Arduino board and power.)
  • A 12-volt DC power source with a current capacity of at least 1A(1000mA).
  • A suitable USB cable to connect the Arduino board to the computer.
  • A computer to program the Arduino microcontroller.
  • A screwdriver.

Step 3: Program the Arduino Microcontroller

Make sure you have the Adafruit motor shield library installed in your Arduino IDE. You can get full documentation about the motor shield and necessary software from this link.

Step 4: Make a Test Layout

Kato Unitrack is great for making temporary layouts, especially for testing purposes. Click on the image for more information. Make a layout as shown in the above image. The length of the track in the mainline(Between points A and B can be made of any length possible.) Make sure all the rail joints are properly made and the track rails are cleaned properly.

Step 5: Install the Motor Driver Shield on the Arduino Board and Connect It to Track Power and Turnout

Install the shield carefully on the Arduino board by aligning the pins of the shield with the headers of the Arduino board. Do it gently and make sure no pins of the shield get bent.

Connect the output pins of the shield marked as M4 to the track power wires and those marked as M3 to the turnout wires. Make note that the setup is compatible with only two wire solenoid type turnouts.

Step 6: Wire Up the 'sensored' Tracks

Install the expansion shield on the motor shield and connect the sensors' GND and power wires to GND and +5V rails of the shield respectively. Make the following pin connections:

  • Connect the output of the sensor in the yard to the Arduino board's pin A0.
  • Connect the output of the sensor in the point A track to the Arduino board's pin A1.
  • Connect the output of the sensor in the point B track to the Arduino board's pin A2.

Make sure no pins are loose to avoid malfunctioning of the system.

Step 7: Connect the Arduino Board to Power and Turn It On

Connect a 12V DC power source to the Arduino using a barrel jack and power it up.

Step 8: Place Your Locomotive in the Siding and Slide It Over the 'sensored' Track

The Arduino board is programmed to start the layout operation only after the locomotive has been placed in the yard and it gets to 'know' this only through the feedback from the 'sensored' track. Make sure you watch the video, in the first step, to understand it better.

After the 'sensored' track detects the locomotive, you should see that the turnout will switch to the siding if it is not and the locomotive will start to move forward.

If the turnout switches to a wrong direction, reverse the polarity of the wires connecting the turnout to the motor shield. Do the same for track power if the locomotive starts to move in the wrong direction.

Step 9: Watch Your Train Go!

If everything was done correctly, your train should start to move from the yard siding on the mainline and proceed as shown above.

Step 10: Done for Now?

Got your train running? Don't stop here! Try upgrading the setup to run the train between more points, change the acceleration and deceleration rate of the train, tweak with the Arduino code, there is a lot to do. All the best!

Arduino Contest 2019

Participated in the
Arduino Contest 2019

Be the First to Share

    Recommendations

    • Pets Challenge

      Pets Challenge
    • Fandom Contest

      Fandom Contest
    • DIY Summer Camp Contest

      DIY Summer Camp Contest

    11 Comments

    1
    bobbin04
    bobbin04

    Question 5 months ago

    Hi,

    Thank you for this really nice set up. Just wondering is there anyway we can use the 3 wired solenoid turnout for this set up? Thank you.

    0
    KushagraK7
    KushagraK7

    Answer 5 months ago

    Does the turnout have a common wire and each of the other two wires are for switching it in a direction? For example, 1st wire is common and is connected to -ve supply and the 2nd wire, when connected to +ve of supply causes the turnout to switch in one direction and disconnecting the 2nd wire from supply and connecting the 3rd wire to the +ve of supply causes the turnout to switch in the other direction?

    1
    bobbin04
    bobbin04

    Reply 5 months ago

    Thank you for your reply.

    Yes, the turn out have 3 wires one common ground and 2 positive to switch on either side. I was just confused since you said the code is just for a 2 wired turnout. Is there a way to use the 3 wired turnout and is there a different arduino code for it?

    1
    bobbin04
    bobbin04

    Reply 5 months ago

    Thank you! 😇 i will give it a go 👍🏽

    1
    bobbin04
    bobbin04

    Reply 4 months ago

    Hi KushagraK,

    The circuit you made works brilliantly. Unfortunately for some reason the output of the motorshield is 3V and not enough to run the train? Not sure why is it outputting 3V ive followed all the instruction and installed adafruit_motorshield.h and AFMotor in the librabries but still the same. I'm really confused why is this happening. Hope you can help me plesae. TIA.

    0
    KushagraK7
    KushagraK7

    Reply 4 months ago

    Did you try powering any locomotive from the motor output of the motor shield? I believe you are getting a low voltage on the output of the motor driver because the Arduino microcontroller is programed to provide a low voltage across the tracks initially to start moving the locomotive at a slow speed, after sometime, the voltage is increased slowly to speed up the locomotive gradually.

    1
    bobbin04
    bobbin04

    Reply 4 months ago

    will you be able to explain what's the variable of the IR sensors? My understanding is that if the IR is not getting blocked by anything the reading should be around 1022 and when there is obstacle it reads around 23 in analog?
    I cant see the variables that you used for the IR in the sketch.
    Sorry I'm new with adruino but i really want this set up for my train. Thank you for replying to my queries.

    0
    KushagraK7
    KushagraK7

    Reply 4 months ago

    The pins 'A0' and 'A1' are used here as digital inputs, not analog ones. We can use the analog input pins as digital inputs as well.

    1
    bobbin04
    bobbin04

    Reply 4 months ago

    Thanks,

    i guess my sensor is not working right. Im using this sensor i bought from ebay (see attached picture).
    Do you have a tutorial on how to make the IR sensors you are using in this build?

    WIN_20210302_21_27_30_Pro.jpg
    0
    KushagraK7
    KushagraK7

    Reply 4 months ago

    Connect the sensor to a 5-volt DC power supply. Adjust the sensitivity of the sensor by rotating the potentiometer with a screwdriver and place an object at a required distance in front of the sensor. Adjust the sensitivity as such that the second LED on the sensor turns on when the object is in front of it and turns off when the object is removed. Take care not to expose the sensor to bright light as it interferes with it. I have made an instructable for making 'sensored' track. I would recommend using a sensor that has the IR LED and the photodiode(Black one) with a diameter of 3mm(yours and most of them have 5mm) to make it easier to install in an N-gauge track.