To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 13357
13356  |  13358
Subject: 
"No Contact" Homebrew Train Sensor for Mindstorms
Newsgroups: 
lugnet.trains, lugnet.robotics
Date: 
Tue, 5 Dec 2000 18:31:59 GMT
Highlighted: 
(details)
Viewed: 
79 times
  
As has already been reported by others, I built an automated railroad
crossing for the NELUG train display at last weekend's Greenberg show.  I
wanted to take a moment to describe the "homebrew" sensor that I used to
detect an approaching train so that others might benefit in their own layouts.

I originally tried several techniques to detect the presence of a train,
including the touch sensor, the light sensor opposite a light source, and
the good old infrared "radar" technique that has been well-documented on the
robotics forum in the past.  I also considered using Vision Command, but I
didn't want to have a PC in the loop if I could avoid it.  None of these
techniques was very reliable: I couldn't find a good way to trip a touch
sensor without derailing the train, and the other techniques required a lot
of highly visible and unsightly "plumbing" somewhere along the track.  I had
pretty much abandoned the idea of using an RCX to detect a train before I
remembered an idea that I had awhile back but never tried, due to my
semi-irrational aversion to non-LEGO solutions.

I used reed switches which are small switches encased in glass that close
whenever a magnetic field is present.  I simply chopped a long electrical
connector in half, (ouch!) soldered the reed switch to the bleeding end, and
connected it to an RCX sensor input which was configured as a touch sensor.
Voilla!  The RCX could easily detect the presence of a magnetic field as if
a touch sensor were being pressed.

I then placed the touch sensor _lengthwise_ along the track, and found that
the magnetic couplers between the train cars were strong enough to trip the
reed switch.  (At first, I placed the reed switch perpendicular to the
track, but this didn't work due to the alignment of the magnetic field from
the train magnets.)  It was then a simple task to program the RCX to close
the drop-gates and turn on the signal lights at the crossing.

I went to Radio Shack to buy the reed switches.  The 'Shack used to sell
reed switches in a pack of four, but they don't any more.  Instead, I looked
at their home security stuff and found a sensor/magnet pair for $4 that I
was able to extract the reed switch from.  If I had more time+patience, I
would've gone to a larger electronics store and bought a pack of reed
switches instead.  It would've been a lot cheaper, and also I broke 2 out of
4 switches during the extraction process -- they are _very_ delicate!

At first, I didn't think the train magnets were strong enough to trip the
reed switch, so I stuck one of the Radio Shack magnets onto a 2x4 plate
(using the double-sided tape supplied with the magnet) and attached it to
the underside of the locomotive.  This worked great.  But later, we removed
the non-LEGO magnet from the train and found that it worked anyway.  I think
the reason this didn't work the first time I tried it was that I had the
reed switch oriented perpendicular to the track, because it fit between the
ties better that way.  However, I soon discovered that even the more
powerful magnet would not trigger the reed switch unless the N-S poles were
aligned lengthwise with the switch, and by then we had already attached the
stronger magnet to the train.  We turned the magnet and reed switch
lengthwise because we wanted to hide the offending non-LEGO magnet
completely on the underside of the loco; otherwise we might never have
discovered that the LEGO magnets alone will do the job!  So I must emphasize
that, although it is tempting to lay the reed switch between two ties, it
will only work with the train coupler magnets if the switch is lying
lengthwise along the track.  Otherwise, you'll need to add extra magnets
that are aligned side-to-side in order to trip the switch.

For the show, I simply used the RCX to close the gates for a fixed length of
time whenever it sensed the train coming.  This worked OK, as long as the
speed and length of the train remained constant.  But for our next show
(which I have now been tasked with creating several more crossings for) I
will improve the software to sense each train coupling as it passes to
determine how long to keep the gates down.  I also plan to use multiple reed
switches at each crossing in order to detect a train approaching from either
direction, and also to detect the actual speed of the train on-the-fly.

Anyway, I was amazed at how well this technique worked once I figured out
the alignment thing.  Maybe LEGO will add a reed switch sensor to the
Mindstorms product line so that I won't have to feel guilty about using a
non-LEGO component in our otherwise pure-LEGO train display.  Here's hoping...



Message has 5 Replies:
  Re: "No Contact" Homebrew Train Sensor for Mindstorms
 
(...) I might just add that while this was a bit over my head it work extremely well and the sensor itself was very small and unobtrusive. It was a non-LEGO solution but I loved it and recommend it. I think with some reworking it may even be (...) (24 years ago, 5-Dec-00, to lugnet.trains, lugnet.robotics)
  Re: "No Contact" Homebrew Train Sensor for Mindstorms
 
Wonderful info! If I could be so bold... On the PNLTC web site we have articles that discuss various building and other techniques. This reed switch discussion and design review would make a great article (with some pics & schematics) for NELUG! (...) (24 years ago, 5-Dec-00, to lugnet.trains, lugnet.robotics)
  reed switch w/2^n series resister
 
Chris If I understand correctly you can add a series resister to each reed switch using the formula r=2^n*R. Where n is the number of each switch (1,2,3...) and R is some resistence value that is friendly to the RCX. This way you can add several (...) (24 years ago, 5-Dec-00, to lugnet.trains, lugnet.robotics)
  Re: "No Contact" Homebrew Train Sensor for Mindstorms
 
Chris, Another great little sensor for train detection, via Radio Shack, is the little photo sensors they sell. I put them inside of a 2x4 technic plate and then snap them face up on the track. This way they use the omni light from the room as the (...) (24 years ago, 5-Dec-00, to lugnet.trains, lugnet.robotics)
  Re: "No Contact" Homebrew Train Sensor for Mindstorms
 
Hi Chris, thanks for sharing this. I had the same positive results with reed sensors in my automated rail station. The station actually detects the incoming train through the well known light sensor + lamp method, but I wanted a way to distinguish (...) (24 years ago, 6-Dec-00, to lugnet.trains, lugnet.robotics)

21 Messages in This Thread:








Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR