Return to A&M LEGO Place Home Page
  Trains - Projects - Train Collision Avoidance..............................................................................Operation LifeSaver Link
Collision Avoidance using Lego Mindstorm
By using LEGO Mindstorm you can control trains and do collision avoidance at cross tracks.  The figure below shows an electrical view of our current layout.

The color boxes represent the changes in electric sections.  This is necessary in order to have manual control for the switching area and also allow the RCX to control the trains.  Note that each RCX controls two sections of track: RCX1 controls Red and Green section while RCX2 controls Pink and Fusia Track.  Also note that the switching area is controlled by two train controllers.  This allows two engines to do switching independently.  RCX3 controls the motorized train bumper (trains - projects) and the Grey Track Section.  One push button from RCX3 is used to turn on/off this section of track. 

In order to have different circuits within the same track you must physically separate the track.  We use black electrical tape to insulate one "track circuit" from the next.  You can also physically separate the track and leave them1-stud apart.  You may run into complications, however, if you have too many circuits within a track using the 1-stud apart method.  We recommend you use electrical tape instead.

Electrical track layout image
At The Cross Tracks: Collision Avoidance
This is the idea behind the code used by the RCX.  (LS = Light Sensor; T = Track)

top

IF LS1 = on and LS2 = on THEN turn both tracks on

IF LS1 = off and LS2 = on THEN 

  1. turn off T2 (train passing on track 1)
  2. wait for 'x' seconds
  3. go to top

IF LS1 = on and LS2 = off THEN

  1. turn off T1 (train passing on track 2)
  2. wait for 'x' seconds
  3. go to top

IF LS1 = off and LS2 = off THEN

  1. turn off T2 (T1 train is given preference - this is the bigger of the two tracks on this layout)
  2. wait for 'x' seconds
  3. go to top

Back to top

The limitation to the software and current layout are the following:
  • Trains in the possession of the RCXs travel only in one direction.  Currently, clockwise direction only.
  • Light sensors, if not properly covered from ambient light, will not detect trains. Thus allowing collisions.

Go to my download page to get the NQC code for this project.

Top of Page Train Engine Image
 
Page Last Updated on

Free JavaScripts provided
by The JavaScript Source