Kolaf

Lego train crossing

22 posts in this topic

traintech1.jpg

The next chapter in my Lego prototyping quest has completed. I have created an automatic train crossing using two sensors, two servos, and an Arduino board.

There is one sensor at either end of the crossing which can detect when a train passes. As soon as either of them detect the train the gates are closed. The gates remain closed until the sensor the other side first has detected the train as it passes and then no longer detects any trains. In this way the gates remain closed until the entire train has passed regardless of the number of cars and the speed of the train.

Once I get longer leads I can place the sensors farther away from the crossing and thus slow the speed of the gates. I apologise for the very crude design, but given time bubble builds everything into neat Lego constructions which hides everything from sight. Also, the servos I use are a bit old, which is why things seem to shake. These will be replaced by new ones later on.

The video is included below:

Edited by TheBrickster

Share this post


Link to post
Share on other sites

I am not very familiar with those automated things....but it looks as you have done a great job.

If you could integrate it a little bit better in your city, e.g hiding cables and making it more rigid,

it will certainly look even better. :tongue:

Share this post


Link to post
Share on other sites

That's exactly what I always wanted to build: An automatic train crossing! :wub:

But I would like to build it with Lego only. Guess I will have to use Mindstorms bricks for that.

Thanks for sharing your pics. :thumbup:

Share this post


Link to post
Share on other sites

I completely agree, things would look much better in the Lego style. The problem with Lego mindstorms is that it is much more expensive than buying cheap servos. I am working on addressing things up and hiding cables, and I will show you more details once everything is completed.

My problem is that I am more into the technical stuff them into Lego building (although I like that as well), so all the technical stuff is done first regardless of the cosmetics :-/

Share this post


Link to post
Share on other sites
My problem is that I am more into the technical stuff them into Lego building (although I like that as well), so all the technical stuff is done first regardless of the cosmetics :-/

I wished I could say something similar about myself. :sadnew:

I' m more the Lego guy rather than the technician.

Share this post


Link to post
Share on other sites

In 2000 I designed an automated train crossing with flashing lights and bell (round siren module). It had a red micro motor for each barrier arm. It was powered by a Technics Control Centre II 8485. I would run a train at constant speed around the display and program the time delays into the controller.

cross1.jpg

Share this post


Link to post
Share on other sites

Nice, it's a much cleaner design than my own. The problem is, as I have stated previously, that I am inexperienced with building things that look nice from scratch. This can be exemplified by a couple of pictures that are included here of the silo that comes with a farm set. I have automated the unloading mechanism in it with a servo controlled by my remote control. In the first picture the mechanism is bare, and in the second picture I have tried to cover it up. As you can clearly see I have not done a good job. Do You guys perhaps have any ideas/suggestions as to how this can be achieved in a more elegant manner?

IMG_8401.JPG

IMG_8400.JPG

This third picture is of the mechanism I plan to use to encodecommands along the tracks to be read by my automatic locomotive. The strip of Lego can encode one of 15 different commands that will be read by the locomotive using the small black sensor in the picture.

IMG_8389.JPG

Finally, I have included a short video of my entire setup as it is now. There is one remote controlled switch, the remote controlled self unloading silo, and finally train crossing with updated software. There are still a few bugs in this video which have been ironed out in later versions. Please, if anyone has suggestions on how this can be beautified, e.g. making it look like Lego and hiding the cables I would be grateful.

Edited by Kolaf

Share this post


Link to post
Share on other sites

Very nice. I left you a comment and 5 rating :grin: Nice to see some people using micro controllers. Did you build that one from scratch or is it one of those built from a kit from online? You mentioned it is remote control, where did you buy it from? I want to replace the Infer Red Power Functions control system with a Radio Frequence Remote Control but I was just going to buy one of those cheap mini RC RF cars as they only cost $10-20. Then rip out the RC functions.

Share this post


Link to post
Share on other sites
Very nice. I left you a comment and 5 rating :grin: Nice to see some people using micro controllers. Did you build that one from scratch or is it one of those built from a kit from online? You mentioned it is remote control, where did you buy it from? I want to replace the Infer Red Power Functions control system with a Radio Frequence Remote Control but I was just going to buy one of those cheap mini RC RF cars as they only cost $10-20. Then rip out the RC functions.

Thanks!

I'm sorry to disappoint you, but the remote control is an Infrared remote control (Logitech Harmony one), and not RF. Interfacing the IR to the microcontroller was quite simple, and as I already have the transmitter the solution turned out quite cheap. I believe an RF solution would be more expensive/complex. Anyway, I have found that the reach and sensitivity of the IR system is not bad, I can point my remote control in the opposite direction and signals are still received by the controller. For what I am planning a simple RC car system will not afford minimal out of control I want to have from the system, e.g. running multiple switches, signal lights, and also various functions on the engine itself when I get that far.

The board is preassembled, I do not have the patience to solder such small things :-/. I bought it from Trossen Robotics and they shipped it and some more stuff to me in Norway.

Share this post


Link to post
Share on other sites

All of your work is great. It's neat to see people thinking outside the box and incorporating stuff like this into Lego.

This third picture is of the mechanism I plan to use to encode commands along the tracks to be read by my automatic locomotive. The strip of Lego can encode one of 15 different commands that will be read by the locomotive using the small black sensor in the picture.

IMG_8389.JPG

This I'm particularly intrigued by. Correct me if I'm wrong, but isn't that essentially a Lego barcode and reader?

Please, if anyone has suggestions on how this can be beautified, e.g. making it look like Lego and hiding the cables I would be grateful.

I can't tell from the video what your layout is built on, but the standard model railroading method for hiding wires is to drill a hole through the tabletop and route the wires under the surface.

If you're not adverse to "modifying" your bricks, you could use a dremel to hollow out a few pieces (or even glue together a few bricks, then hollow out the resulting structure), to hide your components in.

Share this post


Link to post
Share on other sites
All of your work is great. It's neat to see people thinking outside the box and incorporating stuff like this into Lego.

This I'm particularly intrigued by. Correct me if I'm wrong, but isn't that essentially a Lego barcode and reader?

I guess you could put it that way, although I'm not sure how numbers are encoded in barcodes. The encoding I plan to use is similar to what is used in IR codes. Each "high" (H) delimits a series of lows (L). The length of lows determines whether a 0 (LLL) or 1 (LL) is encoded. For example, HLLHLLHLLLHLLH translates to 1101.

Since the train travels at varying speeds and we know the length of each high, we can use this to calibrate and correctly determine the length of the low assuming that the rates of the change in speed of the train is slow compared to the length of the low portions of the code.

This can then be used to have the train stop at stations, decelerates realistically toward stations, slow down in curves or downhill, and even differentiate between stations.

With regards to the layout, it is currently on my dining room table so drilling holes is out of the question. I'm planning on building a separate table so I will have to wait until then to get everything perfect :-)

Edited by Kolaf

Share this post


Link to post
Share on other sites

Bumping a very old thread with the hope that someone is continueing this or doing more or less thesame thing.

I like the idea of the 'lego barcodes' someone in this thread hinted at. I'm looking for a way to identify my rollling stock, so that I know which train and wagons pass at certain points and when, so I can do more specific controls.

I was thinking of making lego barcodes of 4 bits, possibly with identifier bits aswell, with 2x1 black and white flat tiles under each wagon or engine. Has anyone ever attempted this? I'm wondering what sensor I could hook up to my arduino controller to read out these kind of values.

Included a short movie of my current arduino controlled setup that i filmed using a brand new potato:

Edited by zwiep

Share this post


Link to post
Share on other sites

a better option is using RFID, I have done that and it works well.

Share this post


Link to post
Share on other sites

Cool to see everyone has their own solutions. I once automated a level crossing with an Arduino microcontroller, also using the micro motors!

Share this post


Link to post
Share on other sites

a better option is using RFID, I have done that and it works well.

Cool to see everyone has their own solutions. I once automated a level crossing with an Arduino microcontroller, also using the micro motors!

Thanks for the replies guys, by now I have tried using a bright led and a photosensitive resistor and theres definitely some difference between white and black bricks but the problem is that it won't get those values when theyre close together due to the light being so spread. So right now I'm tempted to go with the RFID idea from JopieK.

Jopie do you have any documentation on how you implemented it or what parts you used, they would be very helpful in my process I believe.

Arjen thanks fro you reply on the tweakers forum aswell, you certainly have some nice stuff implemented in your track, already found out why my range was so bad, going to fix that asap but it's a matter of using different IR leds. Personally I work with PF trains so identification is crucial because I need to know which train I need to send a signal to, after I get identification right I think I can get some really cool things going.

Share this post


Link to post
Share on other sites

Take a look at model train forums, they use RFID as well, maybe you can find some info there. They stick an RFID tag on the bottom of the train and position the sensor between the sleepers...

Share this post


Link to post
Share on other sites

a better option is using RFID, I have done that and it works well.

Jopiek do you have any documentation on how you implemented it or what parts you used, they would be very helpful in my process I believe.

...identification is crucial because I need to know which train I need to send a signal to...

I would like to learn more about Jopiek's RFID solution too. :classic::thumbup: I discovered this old topic a little while back, but picardgk mentioned an issue about reader latency and didn't mention specifics of the RFID hardware he was using. It sounds like he may have resolved the latency issue, but knowing that doesn't help much without knowing what reader/tags he used.

I'm in the process of developing an open source Bluetooth replacement for the IR receiver. It works well enough and solves some of the issues of IR, but introduces others like the necessity of identification for automation. Using standard PF IR, you could just transmit on all four channels at once, but it would limit the system's finesse, which is not very desirable.

Share this post


Link to post
Share on other sites

there is an issue with latency, but... I have used latches to solve that problem, next railbricks will be a bit basic, but... the issue after I hope to discuss that as well. Bluetooth is also a good idea especially Bluetooth Smart, I have quite some experience with that for an other project.

Share this post


Link to post
Share on other sites

I'd love to be able to build something like this but annoyingly my knowledge of electrical circutes is quite low. Nevermind it is nice to see all of yours.

I do recall once on our old N Gauge set there was a level crossing that had no electrical stuff at all and just worked on the weight of the train on the track pushing down some pulleys and wire frame, this when weighted (A little way before the crossing.) pushed (or pulled.) the various bits lowering the gates, then when gone the weight was off the track and they would open again. I cannot find any diagram though of how it worked. I am sure that sort of thing could be rigged into a LEGO crossing if I knew how it worked?

Share this post


Link to post
Share on other sites

I was able to get my hands on some cheap rfid reader modules and some tags, i'll keep you posted but the time of arrival right now is july. I was thinking about trying thesame thing picardgk tried in his blog, too bad he's not posting or replying anymore, I'm very interested on what other controllers he used and how.

Meanwhile I'm also looking at remotely changing the railway switches. There's quite a lot of solutions about but I'm looking for a low-profile and preferrably cheap one :p

Edited by zwiep

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.