Simple Automated Model Railroad Loop With Yard Siding

by KushagraK7 in Circuits > Arduino

1763 Views, 7 Favorites, 0 Comments

Simple Automated Model Railroad Loop With Yard Siding

IMG_1588.JPG

This project is an upgraded version of one of my previous projects. This uses an Arduino microcontroller, a great open-source prototyping platform, to automate a model railway layout. The layout comprises of a simple oval loop and a yard siding branching out from it to house the train. The Arduino microcontroller gets feedback from two 'sensored' tracks installed at two locations of the layout to carry out specific functions when the train crosses over them.

So, without further ado, lets get started!

Watch the Video

Simple automated model railway loop with yard siding

Watch the above video to understand how this project works.

Get All the Parts and Stuff

IMG_1585.JPG

For this project, you will require:

  • An Arduino microcontroller board compatible with the Adafruit motor shield v2
  • An Adafruit motor driver shield v2(Learn more about it here)
  • An expansion shield(Optional but recommended to expand the power and ground pin connections for the sensors.)
  • Two 'sensored' tracks
  • Two sets of 3 male to female jumper wires(To connect the 'sensored' tracks to the Arduino board.)
  • 4 male to male jumper wires(2 each for connecting the track power and the turnout to the motor shield's output terminals.)
  • A 12-volt DC power source with a current capacity of at least 1A(1000mA)
  • An appropriate USB cable (To connect the Arduino board to a computer.)
  • A computer(To program the Arduino microcontroller.)

Program the Arduino Board

Arduino code.PNG

Make sure you have the Adafruit motor driver shield v2 library installed in your IDE. Go through the Arduino code to get an idea of how it works and how you can modify it in the future to experiment with the setup.

Connect the Arduino board to your computer and upload the attached Arduino code on it.

Make a Test Layout

IMG_1582.JPG

Click on the above image before proceeding to get more info about the layout. Make sure all the rail joints are properly made and the track's rails are cleaned to prevent the train from derailing and/or stalling.

Install the Motor Shield on the Arduino Board

IMG_1581.JPG

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 Track Power Feeder and the Turnout Wires to the Motor Shield

IMG_1580.JPG
IMG_1579.JPG
IMG_1578.JPG

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

Connect the 'sensored' Tracks to the Arduino Board

IMG_1573.JPG
IMG_1574.JPG
IMG_1575.JPG

Install the expansion shield on the motor shield and connect each sensor's GND and VCC pins to the GND and +5-volt headers of the shield. Then make the following pin connections:

  • Connect the output pin of the first sensor to the input pin A0 of the Arduino board.
  • Connect the output pin of the second sensor to the input pin A1 of the Arduino board.

Place the Train in the Siding

IMG_1572.JPG

Place the train in the yard siding to prepare for the test run. Use of a rerailer tool is recommended to ensure that the locomotive and the rolling stock are placed properly on the tracks to prevent derailments.

Connect the Arduino Board to Power

IMG_1576.JPG

Connect the 12-volt DC power source to the Arduino board either through the power terminal block of the motor shield or the female barrel jack connector of the Arduino board. Before turning on the power, make sure all the wiring connections are made correctly and none of them are loose.

Turn on the Power and Watch Your Train Go

Arduino controlled model railway loop with yard siding | Model railroad automation | DIY

After turning on the power if the turnout switches the wrong way or the train starts to move in the wrong direction, reverse the polarity of the respective wires connected to the motor shield's output terminals.

What's Next?

If you have reached this far, you might want to relax a bit and enjoy your project. But if you want to do more stuff then you can try to modify the Arduino code and experiment with the setup to do something new. Whatever you do, all the best!