Model_Train_DC is an arduino project/prototype which aims to allow a DC-powered model train to sequentially navigate and travel between most to any configuration of rail and rail stations, with minimal user inputs required. Navigation is achieved through the following:
- The user sets up their railway configuration, with proximity sensors marking the beginning and end of each rail section, as well as train stations/stops. A couple of rules must be followed.
- The user then creates a folder tree to reflect the organized rail structure - the folder tree acts as a sort of map of the rail sections.
- The included python script 'Rail_Parser.py' is used to populate required vectors in the Arduino script 'Model_Train_DC.ino' according to the specific requirements of the user's railway.
- The user manually updates some parameters in 'Model_Train_DC.ino' according to the specific requirements of their railway.
- The 'Model_Train_DC.ino' Arduino script is uploaded to the target Arduino, and run.
- The train starts from a predetermined rail section, and attempts to pathfind to user-declared rail stations. Once it reaches a target rail station, it idles there for some time, before pathfinding to the next target, and so forth.
- Currently, the scripts only support 1 train running on the railway. However, it was designed to be able to support multiple trains eventually. A couple of functions must be added & tested for multiple trains support (e.g., train traffic management to avoid collision).
- Currently, all rail sections must be adjacent to eachother, and any stretch of rail that is not included in any rail section must be of length < the length of the shortest train on that rail.
Possible future directions for this project includes:
- More complex train navigation, where train can navigate from any one station to any other station. Currently, trains can only navigate between stations that do not require direction reversal.
- Ability to run DCC trains.
- Ability to run multiple DCC trains on the same railway config. Recommends automatic traffic management functions to avoid collisions.
- Ability to run multiple DC trains on the same railway config, by powering individual rail sections accordingly. Recommends automatic traffic management functions to avoid collisions.
- (Folder) Examples
- (Folder) RAIL_SIMPLE
- funcs_arduino.cpp
- funcs_arduino.h
- Instructions.pdf
- model_train_dc.ino
- Proximity_IR.cpp
- Proximity_IR.h
- Rail_DC.cpp
- Rail_DC.h
- Rail_Parser.py
- Rail_Switch_DC.cpp
- Rail_Switch_DC.h
- README.md
- Train_DC.cpp
- Train_DC.h
- Arduino IDE.
- The following Arduino packages (for output to I2C OLED display): Wire.h, Adafruit_GFX.h, Adafruit_SSD1306.h.
- Python: Numpy, CV2 (opencv-python).
For detailed instructions for use, please refer to the included “model_train_dc_ino_diagrams_pdf.pdf” file. In summary, the following must be completed by the user:
- Setup rail configuration in-real-life (IRL). a. Divide the railway into separate rail sections. b. Place rail stations within designated rail sections.
- Create a folder tree which reflects the IRL rail configuration.
- Edit and run “Rail_Parser.py”.
- Edit “Model_Train_DC.ino” Arduino script. a. Edit the rail parameters and connect the rail-section and rail-station sensors, motor drivers for the trains, and motor drivers for the switches. b. Edit the train parameters.
- Connect the I2C Display (recommended). a. I used an I2C OLED Display of 128x64 resolution, and the “model_train_dc.ino” script reflects this. Thus, if you would like to run without a display, or on a different display, the script needs to be changed accordingly.
- Connect Motor Drivers Outputs to their Targets (e.g., Trains & Switches).
- Connect Power to the Arduino and Motor Drivers (for the Trains & Switches).
- Place the Train(s) at their Starting Rail Stations.
- Upload the “Model_Train_DC.ino” Arduino script to the Arduino Board.