Jump to content


Lego train crossing


21 replies to this topic

#1 Kolaf

Kolaf

    Posts: 24
    Joined: 25-December 09
    Member: 8735

Posted 28 December 2009 - 03:28 PM

Posted Image

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, 08 January 2010 - 03:59 AM.


#2 Selander

Selander

  • Swedish Train Engines Extraordinaire


    Posts: 347
    Joined: 07-July 09
    Member: 6607
    Country: Sweden

Posted 28 December 2009 - 07:52 PM

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:
My Flickr and brickshelf accounts:

Flickr link

Brickshelf link

Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#3 Sir E Fullner

Sir E Fullner

  • The Admiral's croissants smell delicious!


    Posts: 563
    Joined: 04-September 09
    Member: 7307
    Country: United States

Posted 28 December 2009 - 09:48 PM

:sceptic:
It kind of reminds me of the 12v's

My MOCPage Ett. FullnerMy Brickshelf

Eat yer spinach, kiddies! However, don't forget the fish.
Posted Image


#4 Holodoc

Holodoc

  • Has finally seen the box


    Posts: 3830
    Joined: 24-November 06
    Member: 1094
    Country: Germany

Posted 29 December 2009 - 03:07 PM

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:
Even more interested in LEGO bricks & parts? Read Tim Johnson's (aka Caperberry) blog: Posted Image

#5 Kolaf

Kolaf

    Posts: 24
    Joined: 25-December 09
    Member: 8735

Posted 29 December 2009 - 05:18 PM

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 :-/

#6 Holodoc

Holodoc

  • Has finally seen the box


    Posts: 3830
    Joined: 24-November 06
    Member: 1094
    Country: Germany

Posted 29 December 2009 - 06:07 PM

View PostKolaf, on Dec 29 2009, 06:18 PM, said:

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.
Even more interested in LEGO bricks & parts? Read Tim Johnson's (aka Caperberry) blog: Posted Image

#7 AllanSmith

AllanSmith

    Posts: 556
    Joined: 06-February 07
    Member: 1340
    Country: New Zealand

Posted 30 December 2009 - 07:30 PM

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.

Posted Image

#8 Kolaf

Kolaf

    Posts: 24
    Joined: 25-December 09
    Member: 8735

Posted 30 December 2009 - 09:15 PM

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?
Posted Image
Posted Image

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.
Posted Image
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, 30 December 2009 - 09:17 PM.


#9 Grimmy

Grimmy

    Posts: 288
    Joined: 27-November 09
    Member: 8354
    Country: USA

Posted 30 December 2009 - 10:35 PM

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.

#10 Kolaf

Kolaf

    Posts: 24
    Joined: 25-December 09
    Member: 8735

Posted 30 December 2009 - 10:44 PM

View PostGrimmy, on Dec 30 2009, 11:35 PM, said:

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.

#11 -The Hyphen-

-The Hyphen-

    Posts: 38
    Joined: 27-May 09
    Member: 6212
    Country: USA

Posted 31 December 2009 - 06:57 AM

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

View PostKolaf, on Dec 30 2009, 04:15 PM, said:

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.
Posted Image

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

View PostKolaf, on Dec 30 2009, 04:15 PM, said:

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.
Never stop seeking that which seems unattainable.
-The Hyphen-

#12 Kolaf

Kolaf

    Posts: 24
    Joined: 25-December 09
    Member: 8735

Posted 31 December 2009 - 10:54 AM

View Post-The Hyphen-, on Dec 31 2009, 07:57 AM, said:

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, 31 December 2009 - 10:54 AM.


#13 zwiep

zwiep

    Posts: 10
    Joined: 06-January 14
    Member: 118673

Posted 05 June 2014 - 10:41 AM

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, 05 June 2014 - 10:45 AM.

Posted Image

#14 JopieK

JopieK

  • Kneecap Buster


    Posts: 2412
    Joined: 04-January 07
    Member: 1180
    Country: Netherlands

Posted 07 June 2014 - 10:07 PM

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

New Member? Read This | Questions? Need Help?Ask Here
Site Guidelines | Eurobricks FAQ | Visual User Guide


Posted Image

-== Classic LEGO trains are the best ==-

Do you need replacement stickers for LEGO (reproductions and customs): ministickers.nl

What then about the LEGuanO?!


#15 AlmightyArjen

AlmightyArjen

    Posts: 236
    Joined: 19-February 13
    Member: 40405
    Country: Netherlands

Posted 07 June 2014 - 10:43 PM

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


Check my youtube channel for cool automated Lego stuff: https://www.youtube....r/almightyarjen

#16 zwiep

zwiep

    Posts: 10
    Joined: 06-January 14
    Member: 118673

Posted 08 June 2014 - 10:29 PM

View PostJopieK, on 07 June 2014 - 10:07 PM, said:

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

View PostAlmightyArjen, on 07 June 2014 - 10:43 PM, said:

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.
Posted Image

#17 AlmightyArjen

AlmightyArjen

    Posts: 236
    Joined: 19-February 13
    Member: 40405
    Country: Netherlands

Posted 09 June 2014 - 09:07 AM

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...
Check my youtube channel for cool automated Lego stuff: https://www.youtube....r/almightyarjen

#18 codefox421

codefox421

    Posts: 127
    Joined: 19-September 13
    Member: 87799
    Country: United States

Posted 09 June 2014 - 03:56 PM

View PostJopieK, on 07 June 2014 - 10:07 PM, said:

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

View Postzwiep, on 08 June 2014 - 10:29 PM, said:

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.

#19 JopieK

JopieK

  • Kneecap Buster


    Posts: 2412
    Joined: 04-January 07
    Member: 1180
    Country: Netherlands

Posted 09 June 2014 - 06:12 PM

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.

New Member? Read This | Questions? Need Help?Ask Here
Site Guidelines | Eurobricks FAQ | Visual User Guide


Posted Image

-== Classic LEGO trains are the best ==-

Do you need replacement stickers for LEGO (reproductions and customs): ministickers.nl

What then about the LEGuanO?!


#20 AlmightyArjen

AlmightyArjen

    Posts: 236
    Joined: 19-February 13
    Member: 40405
    Country: Netherlands

Posted 15 June 2014 - 09:13 PM

What's the date of the next railbricks? Curious about the whole RFID thing...
Check my youtube channel for cool automated Lego stuff: https://www.youtube....r/almightyarjen

#21 Hrw-Amen

Hrw-Amen

    Posts: 1667
    Joined: 05-April 11
    Member: 17080

Posted 15 June 2014 - 10:05 PM

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?

#22 zwiep

zwiep

    Posts: 10
    Joined: 06-January 14
    Member: 118673

Posted 17 June 2014 - 10:48 AM

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, 17 June 2014 - 10:51 AM.

Posted Image



Reply to this topic



  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users