Sensor suggestions?

I'm doing some Arduino to model train (HO) work and I'm trying to figure out the best way to handle position locations.

My current thought is to use some kind of passive indicator on the track so that when a train is rolls over it can determine its position from the sensor. Each location point would have it's own way of being identified. I would like to be able to use up to 32 sensor points but this could grow.

So far I was thinking of

  • Different Colors and using a color sensor - they have them on sparkfun
  • Rfid - Fairly expensive (I think??) and I would need to get a sensor small enough to fit on the under carriage of a train
  • IR Light sensor and try an use it like a bar code <-- not quite sure how to achieve this.

I'm trying to keep this cheap (for obvious reasons) and I'd like to have the senor to be passive to avoid extra wiring. I aim to be connecting this to a Arduino Mini Pro and it's likely that the uart will be used for another component at this stage.

Has anyone got any other ideas or suggestion or even comments on the above methods?

Thanks
Andrew

When I did a computer model train layout in the 70s I used a reed switch embedded in the track and a magnet in the trains.

You could use a hall effect switch and have it detect the polarity of the magnets giving you two unique activators.

How about use a similar concept to the old Nintendo light guns? They would blank the screen and flash white boxes sequentially on possible targets.

You can use shift registers to place IR LEDs along the track, then continually flash the LEDs in sequence. It could be pretty fast, a few thousand full cycles per second. Your train has a sensor, and if you know which LED is on at the time the sensor is triggered, you know where the train is. All you need to figure out is how to sync any onboard intelligence with the LED pattern. Perhaps when the sequence starts at LED 0 the train receives a long pulse from another IR LED mounted above the whole setup, and every time the LED changes there would be a shorter pulse.

The only problem with a sensor on the train is that you have to communicate that information back to the computer through some sort of wireless communication.

so that when a train is rolls over it can determine its position from the sensor.

Well, that depends on what the definition of "it" is ;D

Do you want a CPU on the train to detect where it is? Or do you want a central computer to detect which train has rolled over a given sensor?

I like the Hall effect sensor idea. I'm not sure what their effective range is, but, if you place two of them near the rails, you might be able to increase the number of detectable trains by checking whether one, or both, has been tripped.

Some of the "port expander" chips (I think the MCP23017 is one of them) can be set to trigger an intterupt when one of more of their inputs changes. You could use a couple of those to take care of monitoring the sensors.

Ran

The most reliable way (in my opinion) of sensing position of an train is to sense the motor load in isolated sections of track. Where the current sensor sees load... there's your engine (or lighted cars).

http://home.cogeco.ca/~rpaisley4/BODGP.html

or

with modifications...

http://home.cogeco.ca/~rpaisley4/DccBODvt5.html

Thank-you for all the ideas! Although I'm not sure they are what I'm looking for. Perhaps I should have been clearer :slight_smile: - my fault.

I plan on the train to have an on board Arduino Mini/Pro that will communicate via XBee to other trains/command module. This is a personal project on automation and collision avoidance with possible changing conditions.

Do you want a CPU on the train to detect where it is? Or do you want a central computer to detect which train has rolled over a given sensor?

I want the CPU on the train to detect where it is. So when the train goes over a detector it can acknowledge it has gone over xyz point as opposed to ABC point. So every point needs a unique way of being identified by the train.

{begin random untested idea}

Could you put magnets in the track, and use a Hall effect sensor placed in the train? You would have to figure out a way to encode IDs into positions on the track. Perhaps set a fixed length between two positive up magnets, and then vary the distance of a negative up magnet in between. No matter the speed of the train, it should be possible to detect the positive magnet as a 'start' event, begin timing, and measure the time to the negative and end positive magnet. Somehow those distances could be translated into an ID code, and transmitted back to the computer for processing.

+....-....+

+..-......+

+......-..+

{end random untested idea}

Could you maybe invent simple barcodes, either beside or between the rails?
Problem here would be that it would only work when the train was moving.

Good basic from estranged I like that. Just measuring the ratio of the times should work providing the train doesn't change speed going through the magnets.

A variation might have a number of + magnets followed by a final - magnet with a simple count of the bumps giving the number.

Alternatively you could have say four magnets at each position and the + or - will act like a zero or one to give a binary number. Four magnets would give you a total of 16 positions.