Let's Make Robots!

Simple / Cheap object recognition?

I'm not sure if "object recognition" is the correct phrase for this, as that has connotation of computer vision etc but what I am after in theory is far more simple.

Basically I have a train set. The trains go along the track. Currently I have 3 trains, but I could get more in future. I guess 8 would be a practical limit.

Currently I can quite easily detect when a train goes down a particular piece of track by having a simple IR sensor mounted trackside - this then sends a signal to my microcontroller which acts accordingly changing lights or whatever.

Now, what I am looking for is a simple / cheap way of detecting which train has just passed the sensor?

At this stage I am thinking of having a passive componant on the train, and active componant on the track-side. This is simply so I can easily run wires from the track-side equipment back to my microcontroller. However this may change if I decide I would like more track-side sensor stations, but that would involve some telemetry equipment on the trains.

Does anybody have any ideas?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Optical Encoders? Like this one - but stretched. 
Different Magnets and hall sensor?
Color LED and color sensor?
Train-Motor magnetism detected with Hall sensor? 

First thing that came up in my mind is a barcode attached at the train. Barcode reader could be a simple reflex coupler (Phototransistor /IR LED).

I see your barcode and I raise you a punchcard.

Ok, so a HO train is what, 1" wide? If you were to put (4) QRD1114 sensors side-by-side it would probably fit between your track rails. 3 would fit for sure. Now, on the bottom of your train, you have a series of black dots on a white card. Basically, you would have 4 "columns" on this white paper, with each column aligned with one of your QRD1114 sensors. Each column gets a dot or no-dot. At 3 dots-across, you are looking at 8 combinations and 4 dots gives you 16 (I think its 16... its %00001111, BTW)


Unless, you plan to have a black/white stripe leading the actual train number. Otherwise, your 0000 or 1111 will be showing up while there are no trains there.

I think the barcode idea has merit along the same lines. Make a black bar followed by the same length white bar to prime the micro, and, give it an idea on how fast the barcode is passing. After that, 8bits shouldn't be too difficult to fit in the length of an engine. Admittedly, less hardware, but, more software. I guess it depends on the number of trains you seriously consider monitoring.

It is going to have to be lines instead (the train is moving).

I would say a couple stripes sideways at the start to trigger a %1111 or %0000 --this might be a good "get ready to read stripes" index. From there, our "dots" need to be long rectangles. The length is whatever the 4 ADC's will need vs. the speed of the train.

So basically, if train A leaves the station traveling at...

i'm really no expert but i thought i might as well just put this out there, if it is wrong or doesnt make sense it cant hurt anyone

instead of using a whole barcode what about just two stipes which are different distances apart on each train then all you would have to do is measure the time between each stripe, save that time as that particular train, repeat for all trains. when a train comes along it would measure the time and go with the closest one one the list.

If the trains are moving at less than full speed, the code will read differently. I suggested that there be equally sized black and white stripes at the beginning of the code to let the micro know at what speed to read the barcode.

I am not saying your idea is wrong, just needs some refinement due to speed of the train.

Well that has given me a few ideas to think about, thanks :-)

For interest, it is actually L-gauge - they are Lego trains! The spacing between the 2 rails is about 32mm, 1.2inches.

I am liking the idea of using the QRD1114s with a sort-of-Barcode, but I still haven't decided whether it would be best to have the active part on the track on the train...!

I think I am always going to have less trains than "track markers", so from this point of view it might make sense to have the active part on the train, and the barcodes on the track.