Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Detecting Individual Cars

1092 views
22 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    June, 2003
  • From: Greer, SC USA
  • 99 posts
Detecting Individual Cars
Posted by mrnimble on Friday, February 08, 2019 10:52 AM

Wondering if anyone has found a reliable way to detect individual cars passing a fixed location on a layout (so I can count them with an Arduino as an example)?  I've tinkered for quite some time with a variety of IR devices, some home-brewed and some MR products such as Azatrax.  Continually run into problems with the variety of shapes to detect as well as colors (IR doesn't get along accurately with black for instance) as well as geometry challenges (cross track, reflective, between the rails, etc.)  "Occupancy detection" is not what I'm looking for. Perhaps someone that is also a robotics hobbyist has some guidance what with all of the type of sensors available nowdays that I am totally unfamiliar with.  Thanks, Geoff

Tags: detectors , sensors
  • Member since
    January, 2001
  • From: SE Minnesota
  • 6,796 posts
Posted by jrbernier on Friday, February 08, 2019 11:14 AM

  Have you tried RFID tags like the prototype uses?

Modeling BNSF  and Milwaukee Road in SW Wisconsin

  • Member since
    July, 2009
  • From: somerset, nj
  • 2,328 posts
Posted by gregc on Friday, February 08, 2019 1:54 PM

someone described a block occupany approach that counted wheels.   An IR emitter and detector were mounted just above the rails.

this approach might work for you if you made some assumptions above wheels per car or the time between wheel detections.

have you tried a emitter mounted between the rails with an detecter on a pole just off the track that won't be blocked by a coupler?

greg - Philadelphia & Reading / Reading

  • Member since
    September, 2003
  • From: Omaha, NE
  • 9,417 posts
Posted by dehusman on Friday, February 08, 2019 2:11 PM

If you are using an IR detector that "bounces" light off the cars, then the color matters.  If you use an IR detector "gate" then that's not a problem.  You put the IR emitter on one side of the tracks/car and the IR receiver on the other.  The physical object blocks the IR beam.

You probably won't be able to use commercial circuits because most of them are designed for occupancy, so the detection is "on" for a few seconds, rather than just when the beam is blocked.

Dave H. Painted side goes up. My website : wnbranch.com

  • Member since
    November, 2016
  • 416 posts
Posted by j. c. on Friday, February 08, 2019 2:28 PM

several years back i had a car counting system that used dark on ldr that turned a transistor on that was  wired to a relay type counter. worken ok as long as the train was going slow , was going to try upgrade it to a electronic counter , but that got lost in the other projects that were more important.

  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Friday, February 08, 2019 3:24 PM

I would go with an over head to between the rails IR beam break detector.  Off set the beam so it misses the couplers.   It could even be angular from the middle of the track to the side, enough so that it would catch the bottom of each car.
 
I’m going to be using the Arduino FC-51 IR Obstacle Detectors (reflective) for my signal system.  I only have one block installed and the detectors would count cars.  All of my rolling stock and locomotives are black on the bottom and so far it’s working great.  I have the modules pointed up an inch below the ties through the ties reflecting off the bottom of the cars.  I spaced them at 16” for higher detector resolution, I’m using one second delay on each Arduino detector input.  The FC-51 has no delay so it's very fast.   So far so good.
 
I have a few detectors mounted vertically with the LEDs bent 90° pointed across the track reflecting off the cars 2” from track center at coupler level, they work great that way in hidden areas where they can't be seen . . . much easier too.
 
I use a three pin female Arduino type connector so that they just plug in.  I mount the hidden sockets in an elongated ⅛" hole in the layout plywood base.
 
 
Simple installation, three wires, +5 Volts, Ground and switched ground Detected output
 
I originally bought a package of 10 off eBay to experiment with ($5), everything works great so I ordered a 50 pack last week for $20.
 
They have a sensitivity adjustment so you can tweak them to fit your needs.  I also tried remoting the emitter and using one as a beam break beam detector and it worked pretty good at 4’, touchy alignment at 4’ but reliable.
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    June, 2003
  • From: Greer, SC USA
  • 99 posts
Posted by mrnimble on Saturday, February 09, 2019 3:50 PM

Thanks, jr, for your reply.  Had considered RFID a couple of years ago and it got a bit pricy and complex.  A quick look around today shows a lot of additional variety in micro-chips, and readers as well, which could be worth another look.  Main drawback is applying chips throughout my roster and needed benchwork mods for mounting readers.  Also concerned about proximity of other chips in cars on adjacent tracks being read.  Doesn't appear to be an ap for near field reads.

Thanks, too, Mel for your update on the FC-51 based IR detection with Arduino.  Looks like tricky geometry as well.  Trying to avoid cross-track methods in visible scenery areas to have to hide.  Like your under track reflective mode for car under surfaces.  Concern would be tricky sensitivity to sense cars overhead but ignore the coupler as it goes by.  How could I get somethingto "see" just the trip pins?  Maybe paint the tips silver or grey (somewhat prototypical) and look for color capable detector?

  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Saturday, February 09, 2019 5:02 PM

The FC-51 module has a sensitivity pot and the specs say up to 30cm but for my use max is about 3” between the ties.  I tweak the pot sensitivity to a bit more than tripping on an Athearn passenger car.  The two LED/Emitter are centered between the rails and at that setting it doesn’t see the couplers.  The modules don’t have a built in delay so they’re very fast, easily count cars.
 
I used a 9/64” bit to drill four holes between the ties (code 83) then wobbled it to elongate the hole (¾" plywood).  I then used a Dremel 194 bit to enlarge the bottom of the hole to except the LED/Emitter.
 
 
Installation is very easy, paint the inside of the hole black (I use black ballast) a 1” angle bracket from a big box store, a single screw and some double sided tape and it’s in and working.
 
 
You could buy a 10 pack off eBay ($5) to make sure they will work for you.  I’m very happy with them and the low cost is a benny.
 
 
 
EDIT:
 
They don’t see the Walthers diaphragms either.
 
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    June, 2003
  • From: Greer, SC USA
  • 99 posts
Posted by mrnimble on Sunday, February 10, 2019 4:07 PM

Great stuff, Mel.  Thanks.  Perhaps there is still an opportunty to use IR.  I'll sure experiment with one of these.  Did you have to bend the emitter / receiver toward each other at all or do they both point straight up?  I see the beam width is 35 degrees.  Also, why couldn't I run the output lead right over to an adjacent Digitrax DS64 input for detection since the output goes low and skip the Arduino?

  • Member since
    February, 2002
  • From: Reading, PA
  • 25,548 posts
Posted by rrinker on Sunday, February 10, 2019 4:35 PM

 Depends on how fast the DS64 reacts - there will be only a very short time between cars that the IR sensor will be clear. That's also goign to generate a lot of Loconet messages, possibly causing bus issues - like when using repeated on/off packets to make a signal indication flash. It's fine if you are monitoring a spot to see if a car is set out there, but for counting - I would keep that off the Loconet. We had to run a second Loconet just for signals ont he club layout, because of all the flashing aspects (guy who runs the signal department on a local regional set it all up, following current NORAC rules) and with old Loconet signal boards, the hardware was mostly dumb and did little more than listen for Loconet messages in a given address range, so to make a signal indication flash, JMRI literally had to send on-off-on-off continuously until the signal went dark or changed to a different aspect. 4 or 5 places of this happening caused noticeable delays in throttle response, so the signal system was split out to a dedicated Loconet. Modern interfaces has built in flashing aspects, so you just tell the board "flashing yellow over red" and the board does it, without a constant stream of Loconet commands. 

                                       --Randy


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Sunday, February 10, 2019 5:09 PM

The FC-51 module is pretty flexible.  Out of the package it looks like the picture above but it’s easy to bend both the sensor and emitter 90°.  If one wants break beam type detection the emitter is easily remoted with two wires but remember the output will be inverted.
 
I went with 1N914 diodes (price) so that I can use the detectors for other things as well as my signals.  They work very good as a parking indicator for my hidden sidings and a clearance indicator for hidden turnouts.
 
The thing I like the best about the FC-51 module is their simplicity, essentially they are plug and play.  I power them of a +5 volt bus and bring the switched output back to my controller.  Add in that they just plug in to a standard three pin Arduino type socket they’re great, and they only cost 50¢ each or even less in quantity.
 
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    June, 2003
  • From: Greer, SC USA
  • 99 posts
Posted by mrnimble on Monday, February 11, 2019 10:26 AM

Hey Randy - good to hear from you - you solved a problem for me several years ago.  Meanwhile, I have pretty good results now using the Azatrax devices which I had them modify for me for zero (0) time delay.  Given the interrupt driven software I use (TrainController) I've never had a problem with the DCC/Loconet side of the detection equation.  On the IR detection reliability / accuracy side, not so much.  I have my present IR devices trackside in reflective mode and hightly tuned and aimed and usually flawles until - you guessed it - I'm demoing automated coupling / uncoupling operations for others.  Usually its a previously untested car in the consist, a pair of too closely coupled box cars (unwanted reflections of IR off of the car ends), a depressed center flat car with no load passes by, etc.  You get the idea.  I had tried under the track IR before but couldn’t hide the coupler. I think the ability to adjust detection sensitivity with the FC-51 in Mel’s solution may be a breakthrough.  The Azatrax and home built devices I’m using now do not have that capability and the obstacle detectors available today weren’t available when I built my layout for sure.  I have generally dismissed ‘across the track’ sensing for a number of the same problems described above plus the fact the arrangement of emitters / detectors intefere with prototypical yard scenery.  You can only pile up so much foliage and busted up pallets to hide them.  Stay tuned – I’ll report my findings to this thread as I go.
  • Member since
    June, 2003
  • From: Greer, SC USA
  • 99 posts
Posted by mrnimble on Wednesday, February 13, 2019 8:16 PM

Well, still no joy.  I picked up an FC-51 and set it up breadboard style using the track on my workbench and have, so far, not found it to be any more effective than the Azatraz and home brew detectors I'm using now.  Using the under-track mounting arrangement Mel describes I found it to be extremely sensitive to positioning and sensitivity adjustment to detect just rolling stock vs. a coupler passing by.  Same trouble with box cars - lots or beam scatter bouncing off of car ends causes false indications. No sooner than I get it adjusted to work in that situation then I run a hopper car by and it fails because of all of the under car geometric shapes reflect the IR beam everywhere except back at the reciever.  Next, after more adjustments to compensate for that, I run a totally black tank car by and it never senses it at all.  I'm sure the FC-51 holds promise for some applications but the precise mounting required for my needs in difficult to reach layout areas doesn't seem practical at the moment.  Surely there is a better solution.  The brewery up the road sure doesn't have a problem counting bottles of product streaming past the capper at thousands per hour.

  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Wednesday, February 13, 2019 9:39 PM

The FC-1 will work as a break beam by remoting the emitter.  That will invert the output.  I have successfully hidden the emitters with the sensor between the ties and the emitter in a tree.
 
The break beam will work for quite a distance.  You could put the sensor at ground level pointed up at a 45° to 60° angle with the emitter a couple of feet away.  At 24” the alignment is very broad.
 
Early on I used IR beam break across the track detection at coupler level for my crossing gates.  I angled the beam across the track because I didn’t want it to drop between cars.  I got quite good at hiding them.
 
There are several pictures on this blog post of the way I hid them.
 
 
I used all kinds of things to hid them, but once installed they haven’t required any realignment.  My great grandkids think I’m a magician, I won’t tell them where they’re hidden and they can’t find them.
 
I didn’t try the FC-51s without painting the holes between the ties but I haven run into any problems with the eight I have operating between the ties.  They are mounted at a slight angle towards the right rail, maybe 15° and they do not see the couplers.  I hadn’t tried a hopper so this evening I ran several different cars past the FC-51 detection block and everything worked but my logging cars, I’ll have to work on that.  They caught the trucks but not the logs.
 
One of my projects is to replace the IR circuitry for my gate crossing detectors with the FC-51 module with the existing emitters and sensors.
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    June, 2003
  • From: Greer, SC USA
  • 99 posts
Posted by mrnimble on Thursday, February 14, 2019 8:42 PM

Thanks again Mel for your additional input.  Out of town for a couple of days but I'll get back to experimenting with more geometry next week.  You indicated in your 02/09 reply that the FC-51 was aimed straight up so I'll try the angled approach.  Still troubled about how to handle lack of reflectiveness of all black cars and locomotive underbodys.  Appreciate more details for across the track sensing but tough to do in desert scenery.  Else I need to add taller cactus. LOL  Also, the FC-51 uses 5mm LEDs while the ones I use now are 1.5mm and much easier to camouflage.

  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Thursday, February 14, 2019 9:54 PM

I have substituted 2mm emitters and sensors on the FC-51 and I can’t tell any difference, both work OK.
 
Actually they are pointed up, I’m not very agile and working under my layout isn’t easy.  I use a creeper and my layout is at 33”, working at arms length.  Looking closely they vary from straight to about 15°.  Like I said they see everything but my log cars.  I don’t have many cars, less than 50 total not counting my log cars.   I have several Athearn tank cars and a Walthers twelve car work set.  Eight Athearn cabooses and about a dozen miscellaneous freight cars.  As part of my old timers I have MDC 28’ shorty coaches, long and short log cars and six MDC 22' shorty hoppers.  They work great on twenty Athearn passenger cars.  All eight detectors mounted through the ties catch everything but the log cars.  None see the couplers.
 
Using my hand above the detectors they trip at about 3”.
 
I have 8 mounted vertically in hidden areas with the emitter and sensors bent at a 90° angle pointed across the track at coupler height and I had to crank them down so that they wouldn’t see the parallel track at 2” centers. 
 
I spent about an hour dinking around with all of my working rolling stock and the across the track detectors picked every car including the log cars and locomotives.  The between the ties detectors work on everything but my log cars.
 
I have the detector outputs connected to a 1N914 block matrix feeding a MEGA controller.  Because I’m still in test mode I have an LED connected to each detector to monitor each detector feeding the MEGA.
 
All of the undersides of all my cars and locomotives are black.
 
When I was bench testing the detectors I used a small piece of styrene (about 3” x 3”) painted (Testors spray can) flat black and I didn’t have any problems with reflection off black.  I was disappointed that none of the detectors worked at 30cm as stated in their specs.  About the most I could get reliably was 4½” inches, it didn’t make much difference what color I used.
 
My tests with break beam was using a pair of detectors pointed at each other and monitoring the on board LEDs on each detector.  My hobby room is 10’x 14’ so the furthest I tested them was about 8’ and they worked very good.  They would count my fingers as they broke the beam.
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
 
  • Member since
    July, 2009
  • From: somerset, nj
  • 2,328 posts
Posted by gregc on Friday, February 15, 2019 8:29 AM

have you tried an IR emitter/detector above/across the rails just above coupler height to detect the gap between cars, as well as the coupler assuming it's with the gaps?

i read that putting heat shrink tubing around detectors to minimize their aperature is sometimes required.

greg - Philadelphia & Reading / Reading

  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Friday, February 15, 2019 11:05 AM

You might try the FC-51 with 3mm IRs, I replaced the 5mm with 3mm in one and it increased the range from 4” to over 12” on my workbench.  My bone to bone knee isn’t doing good so I’ll have to wait until I can get my grandson to swap it out for me.
 
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Friday, February 15, 2019 12:25 PM

I have to apologize to everyone following this topic!  This morning I was running a night test on my layout and the FC-51 detectors didn’t work.  After about an hour I finally figured out that my LED room lighting was effecting the operation of the modules.  I cutover to LED lighting in our house last summer and they must putout a substantial amount of Infrared effecting the modules.
 
With the LED room lighting off the detectors do not reflect off black, they work great with anything other color than black with my overhead LED lighting off.
 
My night running mode is Moonlight from two 19 Watt 4100°K LED Floods and the IR sensors don’t see them at all.
 
The LED room lighting really affects the sensitivity of the modules.
 
Rather strange, I’ve been using IR detection on my layout for years without any problems.  When I cutover to LED room lighting it didn’t have any effect on my existing IR detectors.  Most are frequency modulated but I also have a few non modulated IRs and they work OK under the LED room lighting.
 
Sorry 
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Friday, February 15, 2019 1:13 PM

UPDATE
 
I have a FC-51 module working on my workbench with the LED room lighting off.  I use a 36” section of Flextrack on a 1” x 2” board to test my wheeled goodies at my workbench.  I had made an opening for the IR module for testing and by bending the emitter and sensor to have a better focal point at the bottom of the cars it reflects off black and trips the detector, good enough for a block occupancy detector but not a car counter.
 
This weekend I’ll have my grandson tweak the modules under my layout and report back.
 
Again, Sorry about that guys. 
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    March, 2012
  • 63 posts
Posted by crusader27529 on Saturday, February 16, 2019 8:51 AM

I'm the guy referenced here.....the detector consists of 2 tssp4038 IR detectors that work at 38KHZ, and an IR source driven at that frequency.

 

The way it works is that an Arduino NANO monitors the sensors and can tell the direction of the movement across the sensors, and knows if the count increases or decreases for any block. Obviously, both adjacent blocks need to be informed of the transition, and an individual count is maintained.

 

The system can detect anything going past the sensors, with the smallest size being detected based on the placement of the detectors, closer equals smaller detection. The detectors were initially at the side of the track, and because of the size if the detection surface, it actually counted trucks as they passed.

 

My current system uses Fiber Optic cable to link the detectors to the track, and the detectors are mounted close to and just above the railhead. It works flawlessly.

 

Like ALL my work for model railroad use, it's all open source/DIY. I'm setting up a web site to sell the bare PCBs if anyone wants them. The complete system including HW & SW is included, but most won't want to get their own PCBs made, so that's the reason for the web site.

 

The system requires soldering, and I'm considering offering pre-soldered PCBs. Every part that can be socketed is socketed, allowing easy installation and troubleshooting/parts replacement.

 

I'm not in this to make any money, but I certainly don't want to lose money, so prices will be LOW. Hopefully, I'll get this all done in the next few months.

 

I put some video of my prototypes on YouTube. Please ignore the quality of the video. Enjoy" https://www.youtube.com/channel/UCGxniu22N3COHRWq_gfEpsw

 I forgot to mention that there are NO modifications required for any cars to be detected, which was the primary goal for this design.

 

  • Member since
    January, 2009
  • 3,394 posts
Posted by RR_Mel on Saturday, February 16, 2019 7:52 PM

I had better luck using some 3mm emitters and sensors I bought off eBay for an earlier project.  I bought them in a ten pack paired 3mm 940nm.  I swapped out the 5mm that came on the FC-51 modules, I left the leads long enough to extend to the bottom of the ties or the top of the cork roadbed and they will clear a 5/32” hole.  Using ¾” plywood base and Midwest cork roadbed, the lenses are level with the roadbed with ¾” leads off the module board making the total length 1” off the board. 
 
I drilled a ⅛” pilot hole for each emitter and sensor then sized it with a 5/32” bit.  The code 83 tie spacing is just a hair under 5/32” but by being careful I didn’t ding either tie.  I slightly angled the holes so that the IR beam focuses at car bottom to get max reflection.
 
With the emitter and sensor about 1/32” apart at the cork the module sees the entire car and by tweaking the sensitivity pot it doesn’t see the couplers.  I don't care about the couplers so I increased the sensitivity setting for insurance.
 
Using the above method my overhead LED room lighting doesn’t effect the FC-51 module.
 
Installing the test module was much easier than my earlier version that wouldn’t work with LED room lighting.
 
I was thinking (that usually gets me in trouble) that the smaller diameter lens might help with the room lighting and focus better for reflecting off the bottom of the cars.
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    February, 2003
  • From: Finger Lakes
  • 531 posts
Posted by TBat55 on Sunday, February 17, 2019 7:44 AM

Barcodes, inexpensive & proven technology. For smallest size use 2D Data Matrix (looks like a messed up checkboard) which has automatic error correction for damaged images.  Free download fonts online for Excel, etc, and simply enter the car number. Place barcode on car bottom and "keyboard wedge" type scanner underneath layout.

Actually Data Matrix is overkill for a simple 4-5 digit number so might as well enter other data like price, type of car, etc.  You get 3000 characters.

Terry

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!