Answers.Body: <p>I've wanted to do something similar since I took part in a public event last year and we had trains running continuously on separate little ovals. My ambition was to have two stations, each with some switches, and run one train at a time between them and switch it to an empty track where it would stop.</p>
  
  <p>Since I already had two RCXs, my solution was to place one at either station with light sensors to detect incoming and outgoing trains. I motorized the switches (using a modified version of instructions I found online - I could make some instructions if you wish), and wrote a program that allows the RCXs to communicate with each other about the state of the trains and the switches.</p>
  
  <p>There were two tricky parts: one is that although you can send PF commands from an RCX, there is no feedback from the PF receiver so you'll have to resend the command several times and hope for the best. The other is that the communication between the RCXs is affected by the PF commands. When you send a PF command, the receiver in the RCX will end up in a state where the next serial byte is lost, and although there is collision detection for the communication between the RCXs, there is nothing similar for the PF commands (the sending of which requires the disabling of all interrupts on the RCX).</p>
  
  <p>My solution was to design a protocol for communication between the two RCXs such that they, in effect, negotiate whose turn it is to send PF commands and stay silent when the other RCX is sending. This worked very well in my living room, where the trains would happily run and stop and be handed back and forth between the two RCXs (since you can't easily ID the trains, you have to <em>know</em> where they are). I then tried to set this up at an event, but unfortunately the room was anything but compatible with PF. Possibly because of the fluorescent lights, the PF IR range was severely limited and the trains would not receive the signals from the RCXs.</p>
  
  <p>A solution based on NXT (or EV3) could probably be a lot more powerful and reliable, especially since you'll have much better ways of detecting the trains. Even so, I suspect they'd run into the same problems in some showrooms as my RCX solution.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-02T10:27:37.437Z
Answers.Text: I found that places with white walls work better for IR communication. The fluorescent lights can in some instances completely mess-up with the IR networks, but most of the time when there is no line of sight the signal is transmitted by reflection from the walls and ceiling. A solution a friend uses now is to setup a white ceiling over his installations in large open spaces. The ideal solution would be mirrors, but they are expensive and cumbersome. His preferred solution for shows remains a white waxed fabric. I hope this will help you for your future installations.
Answers.UserDisplayName: Coyote
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-02-27T13:16:08.677Z
Answers.LastActivityDate: 2013-02-27T13:16:08.677Z
Answers.UserDisplayName: Carl T
Answers.Body: <p>LEGO trains are primarily toys, and the recent ones aren't even using metallic rails.</p>
  
  <p>As such, they're usually considered ill-suited for automation purposes. That doesn't mean it's impossible, but it'll prove challenging. In any case, you'll definitely need some computing, so it's good that it's OK with you.</p>
  
  <p>For trains themselves, sticking to available parts will be an issue. PF trains are supposed to be remote controlled via RC and have no awareness of the track of or anything at all. The problem you'll have here si to make sure that whatever signal you send, the train will receive it. Some your RC emitters need to be very well placed, and the bigger your layout, the more this is going to be a problem. Forget about tunnels. And your number of trains is limited, too.</p>
  
  <p>You'll probably need to use a Mindstorms Kit and an <a href="http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&amp;key=NIL1046">IR Link Sensor</a>; the NXT itself can be programmed directly or easily controlled by a computer.</p>
  
  <p>Since you'll be using Mindstorms, sensing trains shouldn't be too much of a problem, either with available sensors (not sure which one would be best though) or by making your own (a reed sensor on the track usually detects LEGO train magnets if there are 2 or more of them together); but you'll be limited by the number of sensors you can plug on a NXT. You can of course use several, or grab some <a href="http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&amp;key=NSX2020">sensor multiplexers</a>. When using Reed sensors, you'll probably hav enough with <a href="http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&amp;key=NSX2020">touch sensor multiplexers</a>.</p>
  
  <p>So far, you see using only standard material (and admitting HiTechnics or other third-party vendors as such) is already becoming a complex solution - feasible, certainly, but not cheap either. And we haven't touched switches yet - not that it's complicated to motorize, but if using NXT motors, it's going to take some place.</p>
  
  <p>In the past, <a href="http://www.eurobricks.com/forum/index.php?showtopic=71749">some people</a> have had some success <a href="http://www.lgauge.com/trains/dcc/dcc.htm">transforming 9V trains for DCC</a>, but I wouldn't consider 9V trains as available any more, and this solution does also require a lot of work and good understanding of DCC and whatnot. I have none of this, so I won't talk much more about it, except to say that this usually doesn't address the problem of switches either, and that you'll need a lot of non-LEGO stuff to make it all work.</p>
  
  <p>In short, I think you can do a lot of fun automation even with current trains, but if you want a complete solution right from the start, LEGO may not be the best suited for that. On the other hand, the challenge of making it work may be a greater experience for you and your son, so I'd advise trying anyway. You can start with simple things, keeping the most complicated things (switches) for later.</p>
  
  <p>One other thing you can do to simplify is make sure that the layout itself is simple. For instance, you can have a single track with a train going back and forth (mimicking the <a href="http://www.peeron.com/scans/7720-1/11">good old 4,5V system</a> shouldn't be hard with a PF <a href="http://www.brickset.com/detail/?set=8869-1">Polarity Switch</a>, and that by itself adds a lot of movement to an existing layout, without actually requiring any automation at all.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-01-03T09:31:03.667Z
Answers.Text: Thank you for the detailed answer. It brings material to explore and ponder over before making a choice. I will take the time to explore the options. Have you noticed the headphones hat makes your avatar looks like a demon?
Answers.UserDisplayName: Coyote
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-01-03T13:51:12.243Z
Answers.Text: Now that you mention it, indeed. I guess I should take the time to make a correct avatar though before worrying about what putting an hat on does to it :-)
Answers.UserDisplayName: Joubarc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-01-03T09:05:32.793Z
Answers.LastActivityDate: 2013-01-03T09:05:32.793Z
Answers.UserDisplayName: Joubarc
Answers.Body: <p>LDCC provides a lego solution if you are willing to look for 9V track and modify the motors. There are an endless number of things you can do combining DCC and Mindstorms NXT amoung other things. It really has a lot to do with how much time you personally want to invest. It doesn't matter if it is HO or L(LEGO) scale, they both require a large investment of time to get good results. I have both HO and L scale experience. The LEGO train club I am part of has all kinds of lighting, sound, and action in the exhibits, including light rail that stops at platforms and multiple trains on the same track.</p>
  
  <p>The long and short of it is that LEGO will require more initial investment, but it can do the same things as HO except it is infinitely more reusable. I use LEGO my father used as a child, I am sure my daughter will play with mine when she is old enough. Once something is made in HO, it is very hard to unmake it, but LEGO can be a new creation every day.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-04-30T17:54:03.497Z
Answers.LastActivityDate: 2013-04-30T17:54:03.497Z
Answers.UserDisplayName: LEGO Train Nut
Body: <p>How would you tackle the automation of a lego rails set. I am looking for a solution that can be achieved with available parts.</p>
  
  <p>From the answer I will chose either to invest into lego rail sets for my son or into digital H0 sets.</p>
  
  <p>What I am looking for:</p>
  
  <ul>
  <li>start given engine and run to given destination, stop.</li>
  <li>when approaching a rails crossing stop if segment busy.</li>
  <li>change switches for engine to send to destination.</li>
  <li>run multiple engines independently and concurrently.</li>
  </ul>
  
  <p>Optionally:</p>
  
  <ul>
  <li>if multiple routes are available sent train to free route.</li>
  <li>if train is running low on power send to service station.</li>
  </ul>
  
  <p>I am not interested in setting timings. I want to be able to simply run the different engines each on their own. This requires detectors which are able to return the ID of the engine entering and leaving the different segments.</p>
  
  <p>I'm pretty good at programming and I would appreciate a doable solution running from a computer.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-01-07T01:04:41.823Z
Comments.Text: You might also want to check out our question on [cost comparison](http://bricks.stackexchange.com/q/1264/56) too - although I've seen a video of a very impressive Mindstorms controlled LEGO train set, if it's really an automated train set you're after I'd probably have to recommend a DCC or similar HO set - they're certainly going to be simpler to set up and configure.
Comments.UserDisplayName: Zhaph - Ben Duguid
Tags: <trains><automation>
Title: Simplest approach for rail sets automation
UserDisplayName: Coyote
ThreadText: # Simplest approach for rail sets automation
  
  (Asked by: username_0 on 2013-01-02)
  
  How would you tackle the automation of a lego rails set. I am looking for a solution that can be achieved with available parts.
  
  From the answer I will chose either to invest into lego rail sets for my son or into digital H0 sets.
  
  What I am looking for:
  
  * start given engine and run to given destination, stop.
  * when approaching a rails crossing stop if segment busy.
  * change switches for engine to send to destination.
  * run multiple engines independently and concurrently.
  
  Optionally:
  
  * if multiple routes are available sent train to free route.
  * if train is running low on power send to service station.
  
  I am not interested in setting timings. I want to be able to simply run the different engines each on their own. This requires detectors which are able to return the ID of the engine entering and leaving the different segments.
  
  I'm pretty good at programming and I would appreciate a doable solution running from a computer.
  
  **Tags:** trains, automation
  > **Comments:**
  > **username_1**: You might also want to check out our question on [cost comparison](http://bricks.stackexchange.com/q/1264/56) too - although I've seen a video of a very impressive Mindstorms controlled LEGO train set, if it's really an automated train set you're after I'd probably have to recommend a DCC or similar HO set - they're certainly going to be simpler to set up and configure.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2013-02-27. Score: 7
  
  I've wanted to do something similar since I took part in a public event last year and we had trains running continuously on separate little ovals. My ambition was to have two stations, each with some switches, and run one train at a time between them and switch it to an empty track where it would stop.
  
  Since I already had two RCXs, my solution was to place one at either station with light sensors to detect incoming and outgoing trains. I motorized the switches (using a modified version of instructions I found online - I could make some instructions if you wish), and wrote a program that allows the RCXs to communicate with each other about the state of the trains and the switches.
  
  There were two tricky parts: one is that although you can send PF commands from an RCX, there is no feedback from the PF receiver so you'll have to resend the command several times and hope for the best. The other is that the communication between the RCXs is affected by the PF commands. When you send a PF command, the receiver in the RCX will end up in a state where the next serial byte is lost, and although there is collision detection for the communication between the RCXs, there is nothing similar for the PF commands (the sending of which requires the disabling of all interrupts on the RCX).
  
  My solution was to design a protocol for communication between the two RCXs such that they, in effect, negotiate whose turn it is to send PF commands and stay silent when the other RCX is sending. This worked very well in my living room, where the trains would happily run and stop and be handed back and forth between the two RCXs (since you can't easily ID the trains, you have to *know* where they are). I then tried to set this up at an event, but unfortunately the room was anything but compatible with PF. Possibly because of the fluorescent lights, the PF IR range was severely limited and the trains would not receive the signals from the RCXs.
  
  A solution based on NXT (or EV3) could probably be a lot more powerful and reliable, especially since you'll have much better ways of detecting the trains. Even so, I suspect they'd run into the same problems in some showrooms as my RCX solution.
  
  > **Comments:**
  > **username_0**: I found that places with white walls work better for IR communication. The fluorescent lights can in some instances completely mess-up with the IR networks, but most of the time when there is no line of sight the signal is transmitted by reflection from the walls and ceiling. A solution a friend uses now is to setup a white ceiling over his installations in large open spaces. The ideal solution would be mirrors, but they are expensive and cumbersome. His preferred solution for shows remains a white waxed fabric. I hope this will help you for your future installations.  
  
  ---
  
  ### Answer by username_3 on 2013-01-03. Score: 6
  
  LEGO trains are primarily toys, and the recent ones aren't even using metallic rails.
  
  As such, they're usually considered ill-suited for automation purposes. That doesn't mean it's impossible, but it'll prove challenging. In any case, you'll definitely need some computing, so it's good that it's OK with you.
  
  For trains themselves, sticking to available parts will be an issue. PF trains are supposed to be remote controlled via RC and have no awareness of the track of or anything at all. The problem you'll have here si to make sure that whatever signal you send, the train will receive it. Some your RC emitters need to be very well placed, and the bigger your layout, the more this is going to be a problem. Forget about tunnels. And your number of trains is limited, too.
  
  You'll probably need to use a Mindstorms Kit and an [IR Link Sensor](http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NIL1046); the NXT itself can be programmed directly or easily controlled by a computer.
  
  Since you'll be using Mindstorms, sensing trains shouldn't be too much of a problem, either with available sensors (not sure which one would be best though) or by making your own (a reed sensor on the track usually detects LEGO train magnets if there are 2 or more of them together); but you'll be limited by the number of sensors you can plug on a NXT. You can of course use several, or grab some [sensor multiplexers](http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NSX2020). When using Reed sensors, you'll probably hav enough with [touch sensor multiplexers](http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NSX2020).
  
  So far, you see using only standard material (and admitting HiTechnics or other third-party vendors as such) is already becoming a complex solution - feasible, certainly, but not cheap either. And we haven't touched switches yet - not that it's complicated to motorize, but if using NXT motors, it's going to take some place.
  
  In the past, [some people](http://www.eurobricks.com/forum/index.php?showtopic=71749) have had some success [transforming 9V trains for DCC](http://www.lgauge.com/trains/dcc/dcc.htm), but I wouldn't consider 9V trains as available any more, and this solution does also require a lot of work and good understanding of DCC and whatnot. I have none of this, so I won't talk much more about it, except to say that this usually doesn't address the problem of switches either, and that you'll need a lot of non-LEGO stuff to make it all work.
  
  In short, I think you can do a lot of fun automation even with current trains, but if you want a complete solution right from the start, LEGO may not be the best suited for that. On the other hand, the challenge of making it work may be a greater experience for you and your son, so I'd advise trying anyway. You can start with simple things, keeping the most complicated things (switches) for later.
  
  One other thing you can do to simplify is make sure that the layout itself is simple. For instance, you can have a single track with a train going back and forth (mimicking the [good old 4,5V system](http://www.peeron.com/scans/7720-1/11) shouldn't be hard with a PF [Polarity Switch](http://www.brickset.com/detail/?set=8869-1), and that by itself adds a lot of movement to an existing layout, without actually requiring any automation at all.
  
  > **Comments:**
  > **username_0**: Thank you for the detailed answer. It brings material to explore and ponder over before making a choice. I will take the time to explore the options. Have you noticed the headphones hat makes your avatar looks like a demon?  
  > **username_3**: Now that you mention it, indeed. I guess I should take the time to make a correct avatar though before worrying about what putting an hat on does to it :-)  
  
  ---
  
  ### Answer by username_4 on 2013-04-30. Score: 4
  
  LDCC provides a lego solution if you are willing to look for 9V track and modify the motors. There are an endless number of things you can do combining DCC and Mindstorms NXT amoung other things. It really has a lot to do with how much time you personally want to invest. It doesn't matter if it is HO or L(LEGO) scale, they both require a large investment of time to get good results. I have both HO and L scale experience. The LEGO train club I am part of has all kinds of lighting, sound, and action in the exhibits, including light rail that stops at platforms and multiple trains on the same track.
  
  The long and short of it is that LEGO will require more initial investment, but it can do the same things as HO except it is infinitely more reusable. I use LEGO my father used as a child, I am sure my daughter will play with mine when she is old enough. Once something is made in HO, it is very hard to unmake it, but LEGO can be a new creation every day.
  
  
  ---
  
  