Introduction: Simple Automated Point to Point Model Railroad Running Two Trains
Arduino microcontrollers are a great way of automating model railroad layouts due to their low-cost availability, open-source hardware and software and a large community to help you.
For model railroads, Arduino microcontrollers can prove to be a great resource for automating their layouts in a simple and cost-effective way. This project is such an example of automation of a multi-point model railroad layout to run two trains.
This project is an upgraded version of some of my previous point to point model railroad automation projects.
A bit into this project:
This project focusses on automating a multi-point model railroad layout which has three stations. There is a starting station, say 'A' which initially houses both the trains. The mainline track leaving the station branches into two lines which go respectively to the two stations say 'B' and 'C'.
Step 1: Watch the Video
Watch the above video to understand the operation of the layout.
Step 2: Get All the Required Stuff
Here is what you will need for this project:
- An Arduino microcontroller compatible with the Adafruit motor shield V2.
- An Adafruit motor shield V2. (Know more about it here.)
- An expansion shield(Optional but highly recommended)
- Three 'sensored' tracks.
- 6 male to male jumper wires(To connect the turnouts and track power wires to the motor shield.)
- 3 sets of 3 male to female jumper wires, a total of 9(To connect the sensors to the Arduino board)
- A 12-volt DC power supply adapter with a current capacity of at least 1A(1000mA).
- A suitable USB cable(For connecting the Arduino board to the computer).
- A computer(For programming the Arduino board)
- A small screwdriver
Step 3: Program the Arduino Microcontroller
Make sure you have the Adafruit's motor shield v2 library installed in your Arduino IDE, if not, press Ctrl+Shift+I, search for the Adafruit motor shield and download the latest version of the Adafruit Motor Shield v2 library.
Before uploading the code on the Arduino microcontroller, make sure to go through it to get an idea of what all is happening and how.
Step 4: Make the Layout
Click on the above image to know more about the layout and the location of each 'sensored' track and the turnout.
Step 5: Install the Motor Shield on the Arudino Board
Install the motor shield on the Arduino board by carefully aligning the pins of the shield with the herders of the Arduino board and make sure no pin gets bent.
Step 6: Connect the Turnouts to the Motor Shield
Make the following connections:
- Connect the output of the motor shield 'M3' to turnout 'A'.
- Connect the output of the motor shield 'M4' to turnout 'B'.
Step 7: Connect the Track Power to the Motor Shield
Connect the output of the motor shield 'M1' to the track power feeder installed in the mainline.
Step 8: Install the Expansion Shield on the Motor Shield
Step 9: Connect the 'sensored' Tracks to the Shield
Make the following connections with the 'sensored' tracks:
- Connect each sensors' pin labeled 'power', 'VIN' or 'VCC' to the header rail of the expansion shield labeled as '+5V' or 'VCC'.
- Connect each sensors' pin labeled 'GND' to the header rail of the expansion shield labeled as 'GND'.
- Connect the sensor A's output to pin 'A0' of the Arduino board.
- Connect the sensor B's output to pin 'A1' of the Arduino board.
Connect the sensor C's output to pin 'A2' of the Arduino board.
Step 10: Place the Trains on the Tracks in Station 'A'
Place the trains in the tracks of station A. The train A will be placed on the branch line of station A and the train B on the straight one. Refer to step 4 for more information. A diesel locomotive has been used here to represent train B.
Use of a rerailer tool is recommended, especially for steam locomotives.
Step 11: Connect the Setup to Power and Turn It On
After powering up the setup if the locomotive starts to move in the wrong direction, reverse the polarity of track power's connection with the terminals of the motor shield. If any of the turnouts switch in the wrong direction, you know what to do!
Step 12: Sit Back, Relax and Watch Your Trains Go!
If everything was done properly, then you should see the train in the sideline at station 'A' start to move and the operation to carry on as shown in the video in the first step.
Step 13: What's Next?!
If you want you can go ahead and tinker with the Arduino code and make changes to suit your needs. You can expand the layout, add more motor shields to run more trains, increase the complexity of railroad operation such as running two trains simultaneously and so on, there is a very long list of what you can do.
If you want you can also take a look at some different layout automation projects here.