Detecting each of up to 16 different things

I want to detect each of 16 different model railway wagons as they pass over a certain point. I need to know if wagon 1, 2...16 is the one passing over that point. They will arrive in no particular order. They will be travelling at a slow speed.

I have toyed with the idea of a self made barcode stuck to the underside of each wagon to identify it and reading this with an IR LED and detector, but don't know how to detect the start of the read cycle and how to control the timing of reading each bar. Although the speed will be quite slow, it may not be constant.

I don't want to use a standard barcode reader as the red laser light would be noticeable and out of place on a model railway.

Has anyone got any ideas how to do this?

RFID tag on each train and a reader at the track?

Ir LED on each blinking at different rates.

Henry_Best:
I have toyed with the idea of a self made barcode stuck to the underside of each wagon to identify it and reading this with an IR LED and detector, but don't know how to detect the start of the read cycle and how to control the timing of reading each bar. Although the speed will be quite slow, it may not be constant.

Assuming you've rigged up your IR reflectance sensor right (and that's a big assumption), it should trigger low when the white label of the barcode starts as hopefully the barcodes are the only reflective thing passing over the sensor.

Design your barcode with a black line three units wide in the front. Using pulseIn() you can measure the time it takes for the bar to pass over the sensor and now you've got your reference time. The remaining bars in your barcode are then either two or one unit wide and comparing those times to your reference you know if you've got a binary one or zero.

A little mirror with bits of evenly spaced black tape. Ir beam reflected once = car #1. Ir beam reflected twice = car #2.

RFID...
http://www.thebox.myzen.co.uk/Hardware/Crazy_People.html

Magnets + Hall effect sensor...
http://www.thebox.myzen.co.uk/Hardware/Dice_Game.html

I don't know these guys but it looks like a ready hardware part of the solution:

OTOH, knowing that black and white reflect differently you can try making your own sensor and yes, tape a bar code under each car.

Consider using white stripes (more reflective) for data and black stripes as reference widths. A zero would be a narrow white stripe and a one would be 3x as wide a white strip. The black stripes would all be narrow. You would be reading perhaps 10,000x a second, keep count of how many reads the last black stripe was and if the next white strip is less than 1.5x as many then it's a zero bit but if 2.5x or more then it's a one bit.
Then start your data sector with an attention section of 8 narrow b/w stripes followed by a wide black stripe, the next white stripe begins your data.

The boffo setup would read the same no matter which direction the train is going, attention section at both ends and each car's ID being symmetric. You could get away with 2 number / 4 white stripe codes that would read 0000 0000, 0001 1000, 0010 0100, etc.

I did kind of adapt an idea from Mitsubishi Labs there, but it's kind of adapted from old telegraph Morse code methods that had to be invented because humans don't tap keys with clock-like precision (long story short) so I doubt there will be a patent battle if you go to market.
Besides, I added the bit about using the black stripes for reference, Mitsubishi just used relative numbers of flash reads of data alone to know dit from dah.

The at least twice borrowed idea being that no data is not a data zero. That was used before computers, even the 1880's electro-mechanical type (hole or not being the data). IIRC the words are 'prior art'. 8)

Cool?

CrossRoads:
RFID tag on each train and a reader at the track?

An idea that I might consider. Where does one get RFID tags from and can they be programmed?

That would mean having a power source (battery) on each truck. Trying to take power from the rails for these would be a no-no as the power is PWM and the wagons are too light to make constant contact with the rails.

Chagrin:
Assuming you've rigged up your IR reflectance sensor right (and that's a big assumption), it should trigger low when the white label of the barcode starts as hopefully the barcodes are the only reflective thing passing over the sensor.

I've not rigged anything yet, just trying to sort out the feasability :blush:
Hopefully, the barcodes will be the most reflective thing passing over it. I could paint the remainder of the underside of the wagons matt black.
Thanks for your reply. I'll certainly consider it.

[quote author=Coding Badly link=topic=130297.msg980219#msg980219 date=1351839025]

A little mirror with bits of evenly spaced black tape. [/quote]

Thanks for your suggestion, but have you ever tried sticking 16 strips of tape, evenly spaced, to a little mirror?
A laser printer will give me quite reflective white and black evenly spaced lines.
But that's not the problem. The problem is: when do you start counting?

GoForSmoke:
I don't know these guys but it looks like a ready hardware part of the solution:
IR Reflective Sensor 5mm - 1102_0 at Phidgets

OTOH, knowing that black and white reflect differently you can try making your own sensor and yes, tape a bar code under each car.

Consider using white stripes (more reflective) for data and black stripes as reference widths. A zero would be a narrow white stripe and a one would be 3x as wide a white strip. The black stripes would all be narrow. You would be reading perhaps 10,000x a second, keep count of how many reads the last black stripe was and if the next white strip is less than 1.5x as many then it's a zero bit but if 2.5x or more then it's a one bit.
Then start your data sector with an attention section of 8 narrow b/w stripes followed by a wide black stripe, the next white stripe begins your data.

The boffo setup would read the same no matter which direction the train is going, attention section at both ends and each car's ID being symmetric. You could get away with 2 number / 4 white stripe codes that would read 0000 0000, 0001 1000, 0010 0100, etc.

I was thinking of making my own detector by mounting the IR LED and IR detector in 5mm ID brass tubes with the tops of the tubes level with the track bed and the LED and detector some way down the tubes (think optical rangefinder). That way, I can make the detector more sensitive and focused on a narrow area.

I wouldn't use tape to stick the B&W labels, as tape is reflective. Better to use glue of some sort.

I was thinking of some sort of lead-in (attention strip as you call it) but didn't know how to implement it.

And yes, I was thinking of making the labels symetrical, given enough space. Remembering that the old British 4 wheel wagons were much shorter than the US bogie types.

Thanks for your reply. It's given me food for thought and an avenue to explore.

Adafruit has a bunch of RFID tags and several readers.
The tags are programmable. Each also have a 4-byte unique ID that is not changeable.

"These chips can be written to & store up to 1 KB of data in writable EEPROM divided into banks, and can handle over 100,000 re-writes. You can use our PN532 NFC/RFID breakout board or Adafruit NFC/RFID Shield for Arduino to read and write data to the EEPROM inside the tag. There is also a permanent 4-byte ID burned into the chip that you can use to identify one tag from another - the ID number cannot be changed."

CrossRoads:
Adafruit has a bunch of RFID tags and several readers.
The tags are programmable. Each also have a 4-byte unique ID that is not changeable.
Wireless, RFID / NFC Products Category on Adafruit Industries

Thanks for that. It seems like a bit of an overkill for identifying just 16 different things.

Well, you said you didn't want obvious red barcode scanning light.
You wanted non-powered/passive ID for each car.
You were worried about identifying the start/end of barcodes/optical things on cars.

Adafruit is not the only source for tag readers.
If something else comes to mind I'll put it up here.

Henry_Best:
I was thinking of making my own detector by mounting the IR LED and IR detector in 5mm ID brass tubes with the tops of the tubes level with the track bed and the LED and detector some way down the tubes (think optical rangefinder). That way, I can make the detector more sensitive and focused on a narrow area.

Only the detector needs a tube if that. Put it behind an aperture. In the mid-80's at a Trenton Fest I saw some guys who made a scanner out on a dot-matrix printer. They mounted the light sensor in a pointed pen barrel and got recognizable images. The IR is just for illumination.

Depending on train speed you may be talking 1" long strips. You might try printing flat black stripes on silver reflective material and see if they have that on sticky-back sheets.

I've had Office Max laser-print sheets with strips of gradient and blocks with apertures on overhead projection sheets for maybe 50 cents. IR on one side, aperture and detector on the other I got analog of the strip position for a home made linear pot.

CrossRoads:
Well, you said you didn't want obvious red barcode scanning light.
You wanted non-powered/passive ID for each car.
You were worried about identifying the start/end of barcodes/optical things on cars.

Adafruit is not the only source for tag readers.
If something else comes to mind I'll put it up here.

Thanks, CrossRoads.

GoForSmoke:
Only the detector needs a tube if that. Put it behind an aperture. In the mid-80's at a Trenton Fest I saw some guys who made a scanner out on a dot-matrix printer. They mounted the light sensor in a pointed pen barrel and got recognizable images. The IR is just for illumination.

Depending on train speed you may be talking 1" long strips. You might try printing flat black stripes on silver reflective material and see if they have that on sticky-back sheets.

I'll have to dig out my old spectrum and thermal printer to get flat black on 'silver' paper. It won't be sticky-back, though :smiley:
Joking aside, a thin glossy white card would probably be reflective enough. I may be able to fit up to about 2" long strips. Train speed will be at a crawl, the scaled down (1/76)equivalent of about 3 - 4MPH (walking pace).

If you know what a hump-shunting yard is, I'm trying to automate one with 4 sidings, to sort a jumble of 16 wagons into numerical order. On the first shunt, siding 1 will get wagons numbered 1,5,9 and 13, siding 2 will get wagons numbered 2,6,10 and 14, siding 3 will get wagons numbered 3,7,11 and 15 and siding 4 will get wagons numbered 4,8,12 and 16. The loco will then pick up all the wagons in sidings 1 to 4 and again hump-shunt them. This time, siding 1 will get wagons numbered 1 to 4, etc.,etc. The wagons will then be in numerical order when the loco picks them up for the second time, no matter what order they started in.
This will give you some idea of what I'm trying to acheive.

IR reflectivity, you might be able to test with a webcam, but might have to modify it.

I note with my webcams and cheap DVR camera that a red led shows bright white even dimmed, there's so much IR from the led it overloads the sensor. I used webcam to check if my IR's really were lighting when I was having trouble with a circuit, they look white.

With -enough- IR, a cheap webcam might let you check reflection test patches quickly given strong IR lighting and shading the patches from direct room light. If you can see the difference with a webcam, an IR detector should be affected too.

Otherwise:
http://www.wikihow.com/Make-a-Webcam-Into-an-Infrared-Camera

You might try that anyway. You could run the trains in shade or dark with IR spots to make night train movies. (okay, sorry, just could resist)

GoForSmoke:
IR reflectivity, you might be able to test with a webcam, but might have to modify it.

I've read that mobile [cell] phone cameras will also do that, without modification.

Talking of night scene filming, there's a model railway here (Pendon, Oxfordshire, UK) part of which has a model man leaning against an outhouse, smoking a cigarette. When they dim the lights for the night scene you can see the end of the cigarette glowing. Now THAT'S dedication to modelling!