To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.trainsOpen lugnet.trains in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Trains / 11466
11465  |  11467
Subject: 
Re: "No Contact" Homebrew Train Sensor for Mindstorms
Newsgroups: 
lugnet.trains
Date: 
Thu, 31 May 2001 22:21:15 GMT
Viewed: 
1194 times
  
In lugnet.trains, Tony Hedglen writes:
Hi everyone.

My name is Tony Hedglen and I’m very interested in automated Lego railroads.
I am a member of Michlug and we are one of the newer clubs. We have done one
train show so far and we won second place. I read these posts on sensors and
I think it’s awesome. I’ve been searching for some time now on how to
automate Lego trains. This is the first I seen someone talk about the
subject. I wold like to learn more. I have no idea on how mindstorms work
and I have basic electrical knowledge. Could someone please help me out on
this subject? Thanks.

Hi Tony - I haven't had a Mindstorms for long, but I've already built an
automated level crossing.

The Mindstorms is based around the Lego 'RCX'.  This is a large brick, about
the size of the old 4.5V battery boxes, but with some very special tricks -
it's a computer for a start.

You 'write' programs for it on a PC using a simple icon-driven
point-and-click system (no typing needed, and there are loads of tutorials
and examples to get you going), then use the transmitter you get in the
Mindstorms kit to transfer the program you've written to the RCX brick.
This is done by infra-red, so you only have to plug the Lego transmitter
into your PC, then hold the RCX near it to transfer the program.

Then, you press a few buttons on the RCX and it starts to run your program.

The RCX has six 9V contacts on the top - three allow it to power motors or
lights (outputs), and three are for connecting touch or light sensors
(inputs).  Two motors, two touch switches and a light sensor come with it,
by the way.

Your programs will usually drive motors, then change the power or direction
of the motors in response to what happens to the sensors.  So, a vehicle
could be made to drive forward, but have a touch sensor built into a bumper,
so if it runs into something the program makes it back up a bit then turn to
one side before moving off again.  With a little refinement, your robot
could bump-n-go its way out of a fairly complex maze.

The best feature is that the RCX brick carries its own batteries and, once a
program has been transferred to it, it is totally independent of your PC.
You can build it into anything you like, so your robots can run around
without having trailing power leads.  It's just a good idea to keep the
infra red window clear, so that you can transfer a new program over without
having to dismantle your model.

Obviously you can get more advanced, and do more detailed programs.  You can
even make two RCX units communicate via the infra-red port used for
downloading.  Look in lugnet.robotics for some extremely advanced robots,
like one that solves a Rubik's cube!  These really advanced ones generally
use another neat trick - replacement programming languages or development
tools, made by enthusiasts and freely available from the web.

You can get extras for Mindstorms - the most interesting is 'Vision
Command', which is a webcam with vision recognition software.  Unfortunately
this only connects to your PC, not the RCX, so if you mount the camera on a
robot it will trail a cable back to your PC.


As for automatic barriers, the problem is threefold.  The first step is to
build a set of barriers which can be raised or lowered by a motor or two.
Next is to construct some sort of sensor to detect the train and do
something on one of the RCX inputs, then finally you write an RCX program
that detects the sensor input, drives a motor to lower the barriers, waits
for the train to go past (either using a time delay or another sensor), then
raises the barriers again.

The solutions are many.  I use a single motor driving a worm gear, which in
turn drives a 'clutch' gear (all from the Mindstorms kit).  The axle through
that is a simple winch which winds in two pieces of string.  These pull my
barriers down, and the clutch slips if they pull too far.  Reversing the
motor unwinds the string, and the barriers are pulled back up by elastic
bands.  Problem 1 solved.

A reed switch is a little glass tube an inch long with two metal contacts
inside.  Solder the ends up to a Lego wire and you have a magnetic sensor.
A magnet coming near it causes the contacts inside the glass tube to come
together, and when they touch it's as if you pressed a switch.  So, you
simply connect this DIY sensor to the RCX instead of a touch sensor.  You
lay the reed switch down (lengthways) in your track, and any train magnets
passing over it close the switch - the RCX detects this in the same way it
would detect pressure on a touch sensor, and can be programmed to react.
Problem 2 solved.

Finally you write your program.  Mine is roughly along the lines of:

1. Wait for touch sensor input (i.e. the magnetic sensor)
2. Drive motor for 4.5 seconds (lowers barriers)
3. Wait 3.5 seconds
4. Drive motor in opposite direction for 3 seconds (raises barriers)
5. Repeat from step 1.

(This isn't real code by the way - just a list of what it does).
It takes longer to lower my barriers than it does to raise them, because the
motor's pulling against the elastic bands with a slipping clutch.  But,
because of the clutch, there's no harm in overdoing it.  I also have a siren
on top of the motor, which sounds one tone as the barriers lower and the
other tone as they raise.

And who turned it off at SCLF?  That siren is a vital public warning system.
Vandals.  :-)

If you really want to get clever, you could add more sensors so you can
detect when barriers are fully up or fully down, or when a train has cleared
the crossing.  You could power flashing warning lights from another output
on the RCX, which keep flashing all the time the barrier is down.

Other solutions to the detection problem use a light on one side of the
track and a Lego light sensor on the other.  You then program the RCX to
respond to changes in light levels caused by passing trains.

For my magnetic sensor, the connecting wire runs along the length of the
reed switch.  I've then coated it in a heat-shrink wrap and epoxyed this
little package onto a (very old and already slightly damaged) 2x6 plate,
with the middle 2x4 studs cut away.  I can just clip this onto any bit of
track in my layout and it picks up any train going over it.

If you can afford it, and you have a PC, the Mindstorms kit is excellent.
It's an amazing bit of kit that no one would have thought possible ten years
ago.  Ten years ago, this sort of robotics was confined to highly-funded
University labs, and now it's in Toys'R'Us!


Jason J Railton



Message is in Reply To:
  Re: "No Contact" Homebrew Train Sensor for Mindstorms
 
(...) Hi everyone. My name is Tony Hedglen and I’m very interested in automated Lego railroads. I am a member of Michlug and we are one of the newer clubs. We have done one train show so far and we won second place. I read these posts on sensors and (...) (23 years ago, 31-May-01, 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