Fact finding mission on RFID

sachsr1 Apr 10, 2017

  1. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    I've been looking around for information about implementing RFID identification/sensor information. I've had a hard time finding good information on how RFID information is used in model railroads. I'm assuming the information is out there, and I'm surprised it's not easier to find. It would seem with the cheap Arduino and other online supplies someone would have come up with a DCC++ like version of an RFID sensor system. It seems like it would be an easy thing to setup, but my imagination exceeds my technical expertise. I guess I'm looking for some help brain storming the issue. I would split it into a few issues. Hardware, data collection/management, and finally how do I get JMRI to do what I want with the data. (i.e. what info do I want, and what the heck will I do with it).

    Hardware:
    I know there is commercially available RFID modules. I know CTI makes one, but I personally cannot get my CTI hardware to JMRI (seems to be an issue with other people too). I also know you can make an RFID reader with an Arduino. I'm assuming that you could attach multiple readers to one Arduino. I'm not real well versed in what type of RFID reader would work well for model railroads. There are different types, frequencies, etc.)
    Other thoughts on hardware?

    Data:
    Let's say you are able to build an RFID reader that can read tags at different places on a layout. What would you want to do with that data? Operations, block detection, tracking how long your loco has run between servicing? How do you get the RFID information back to JMRI? I really have no idea of the best way to do this, but it would seem that some type of sensor in JMRI would work??? I have a NCE AIU board in my system that works with block detectors and reed switches. Could I somehow it into that system or use the Arduino directly? It would seem to me that if I can get RFID card X to be read than I could get the Arduino to write a pin high, and report that data back to JMRI directly or through some other sensor method.

    JMRI processing:
    Let's say you've made the hardware, collected the data, and reported it back to JMRI...what's the method to get JMRI to do what I want. If I can track an individual train I would personally like to have an icon of that train move around my layout on my computer. I have NO IDEA if that can even be done, but it seems like something that could happen:). I'd also like to use RFID to do some type of automation, but so far I've had little luck doing this in JMRI. I know the program is capable, but so far I haven't been.

    Here's some links to RFID that I've found, but I can't find any good info on tying it into JMRI.


    http://www.pcrnmra.org/pcr/clinics/RFID-in-Model-Railroading-20130123.pdf
    (I'm guessing it's in German)


    Thoughts, ideas, anyone working on something like this already?
     
  2. brendanf

    brendanf TrainBoard Member

    62
    54
    7
    1. JMRI documentation is horrible to say the least.
    2. If it seems like it should be easy, by all means, blaze the trail and let us know your results.
    3. I am working on my own RFID system. I have started making my own readers since the commercial ones are NOT cheap. If you only need one or 2 then buy commercial, but I need a lot of them. The tags are cheap, you can get them for $1 ea online

    Keep us posted on your own findings with it..
     
  3. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    When I said, "It seems like it would be easy to setup", I meant for someone who understood what they were doing. That excludes me:)

    I'm looking at readers similar to this on eBay. I bought one in 13Mhz and one in 125Khz just to play around with, and had no intentions of using them for MRR. Is there a reason something like this wouldn't work?

    http://www.ebay.com/itm/Reader-IC-C...266833?hash=item25c7496891:g:LWQAAOSwal5YEbtK
     
  4. brendanf

    brendanf TrainBoard Member

    62
    54
    7
    What you should actually decide on first is the RFID tags.

    There are different frequencies used so you need to match the reader to frequency used by the tag. 125khz is more common.

    Find a tag that is the size you be able to use and make note of the frequency and work from there.
     
  5. dalebaker

    dalebaker TrainBoard Member

    1,495
    1,607
    36
    If you go to www.kcs3.webs.com, home website to the HO KCS 3rd Subdivision Steve Davis has posted a video on his main page detailing using RFID to sort cars in one of his yards. It's a good video and Steve will share a lot of information on what he does. I've operated with him in the past. He a very nice guy, just waaaay over my head!

    Good luck!
    Dale
     
  6. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    SUCCESSful failure. Got started on some testing and I learned what doesn't seem to work. The 13mhz RFID reader I have needs to have the tag basically make contact with the reader. I wouldn't read the tag when I rolled it over in a boxcar.

    On a programming note the Arduino sketch instructions lists the pins you should use for each type of board work with the reader, Uno, Mega...make sure you actually change the pins in the sketch. It will save you a lot of time.
     

    Attached Files:

  7. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    I've tried a few things out and so far I've got both the 13Mhz and the 125Khz readers to read the tags, but I'm not real happy with the reading range. The 13Mhz has to be really close to read, but seems to read the card faster than the 125Khz reader. I placed the 125Khz antenna under some road bed and track and rolled a boxcar with a key-fob tag inside of it. If I rolled past the reader with any real speed it didn't read it every time. If I stopped over the tag it would read it from about 3 inches away. The 13Mhz reader worked well if I taped the fob to the side of the boxcar, and placed the antenna vertically next to the rail, but this would be a lot less practical on a layout. It would work good if you had a lot of tunnels:)

    My next step is to write a sketch that lights an LED when the card is read, and place it under my layout to see if the tag is read reliably under "real world" conditions. My concern is that powering the rails may cause interference, and reduce range. I'm also looking at different tags i.e. grain of rice tags attached under the truck, but I don't have the hardware at this time.
    I really have no idea what I'm doing, so there's a pretty steep learning curve. I spent a long time just trying to get the reader to work on a Mega with no luck, and when I switched to an Arduino Nano it worked right away (that's an hour of time I'll never get back). There's not much more I can do until I can determine a location that will accurately read the tags. The readers I'm using are about $2-3 each, and I know there's better readers available. I'm not ready to spend more money until I have a better understanding of the whole process. Right now I have about a total $20 worth of Arduinos and RFID equipment, and if this project doesn't work I'll find a new project for them.
     
  8. brendanf

    brendanf TrainBoard Member

    62
    54
    7
    I was doing some reading on JMRI's website about ID Tags.. So it is implemented using Loconet equipment... Loconet has their own readers which interface with a sensor board..

    Anyway it may still be possible to do it opensource, since there are sketches online for the Arduino that support Loconet.
     
  9. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    From what I can tell it looks like MERG and CTI have readers, but I haven't seen documentation on how they work with JMRI. I don't quite understand how C/MRI works, but it looks like there is some type of Arduino component to that now as well. It's hard to digest all the info at once, you kind of have to understand one part or the next part is Greek.


    C/MRI
    http://www.utrainia.com/tag/cmri
     
  10. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    Well the first hardware test went well, but there was no clear winner. I used two cheap RFID systems that I bought on eBay, one is 13MHz and the other is 125KHz. My test consisted of using an Arduino sketch that turned on an LED if an RFID tag was detected. I basically added the LED code to basic RFID card reading sketches I found online. My first simple test showed that the ranges on both of these systems was very limited. For my layout tests I decided to place the antennas under the track on top of the roadbed. The only RFID tags that I have right now are key fob style. They fit easily inside HO size cars, but neither system would read them that far away from the antenna. I chose to place the RFID in the rolling stock not only due to space, but also to avoid electrical interference from the locomotive. For the purposes of this test I just taped the tags to the bottom of the cars. This test was SUPER fancy, it consisted of electrical tape, toilet paper, and beer. The beer and the tape are self explanatory, and the toilet paper was the closest thing I had to put between the track and the antenna.

    I ran the tags past the antenna numerous times in both directions at varied speeds. I placed tags on different cars on the same train. I ran multiple locomotives on the same track to see if there was any interference. It tried to throw as many variables into the test to identify problems. I'll continue to tests both systems, but I've ordered a smaller 13MHz antenna since that one had a better read rate. I also ordered smaller tags that will work better with HO scale.

    How did each system perform? The short answer is good...the long answer is, they each had their pros and cons. The 13MHz system read the card about 100% of the time even at full throttle. The 125KHz system had about a 100% read rate at slow speeds. That dropped to about 90% at normal run speeds, and dropped off pretty steep after that. it was about 0% after about 60% max speed.
    13MHz
    125KHz




    13MHz:
    Pros:
    Slightly cheaper
    faster card reading
    More consistent card reading regardless of train speed (100% even at wide open throttle WOT)
    Cons:
    Larger antenna mounted on PCB
    shorter read range
    IMG_1210.JPG IMG_1209.JPG

    125KHz:
    Pros:

    smaller antenna (could be hidden in HO roadbed)
    longer read range (when stopped)
    Cons:
    Slighty more expensive
    Read consistency decreases with train speed
    Read consistency varied with when located closer to some of my locomotives
    IMG_1207.JPG IMG_1205.JPG
     
    russtyb likes this.
  11. russtyb

    russtyb New Member

    1
    0
    7
    any news on getting multiple rc522 readers attached to one Arduino uno via I2c or spi protocol connected to jmri ?? 13.56 Mhz seems to be better at speed but just looking to identify engines in a hidden roundhouse using the jmri RFID reporter class. not sure if the rc522 has a unique id for the reader or not or if jmri can use the I2c protocol(less wires) ?
    any info would be great -- russtyb@yahoo.com
     
  12. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    I tried again this weekend after I got the new RFID tags in from China. I got the sticker kind for both frequencies. I also got the grain of rice type, but didn't get to try them. I first tested the 125KHz, because I like the form factor of the antenna. I put a sticker on the bottom of a loco, and it failed miserably. This sticker is so close to the rails that it rubs on the track in a few places, but I think there's too much interference with the motor. I put on on the bottom of a flat bed car, and it read it pretty reliably at normal speeds. It read reliably enough that I would be happy with the results for the speeds I run my trains at, but it dropped of sharply as train speed increases. I wanted to test the 13MHz tags on the train. I managed to short circuit the reader I was using, but I had ordered a different one that seemed easier to place under the tracks. I found that they solderer the header pins over the labels on the pins, and it took me hours of searching to find out the pinout. I hope to get it connected tonight, and I hope the Arduino code works with this RFID module.

    I still have no idea of how to get it connected to JMRI, because I'm such a novice. I haven't looked into this a lot, but I did find this... It looks like a version of C/MRI that's based on Arduino. It looks promising, but the info has been hard to come by and my brain fills up fast. I'm sure if I sat down and really focused on it I could get somewhere with it, but I got too many other fun projects to play with. Each step of this process has been a steep learning curve because it's all new to me.

    Arduino RS485 C/MRI:
    http://www.utrainia.com/65-arduinocmri-and-rs485

    RS485 adapter:
    http://www.ebay.com/itm/201673545064?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT
    RS485:
    http://www.ebay.com/itm/141975846485?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT



    Tags:
    http://www.ebay.com/itm/262330910503?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT

    13Mhz Reader:
    http://www.ebay.com/itm/262890557461?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT
     
  13. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    I think I'm going to look at the Arduino C/MRI hardware to connect to JMRI. I'm not sure exactly how I'm going to do that exactly, but it seems like the most promising route. I've ordered some RS485 parts, and have successfully connected one Arduino to JMRI. I can turn on and off one LED (woohoo, big start). The rough idea is to have the RFID Arduino turn on different outputs depending on which tag it senses. This will be routed to JMRI as a sensor input. I'm guessing it will have to be sent from an RFID Arduino to a C/MRI Arduino, and then to JMRI. I'm sure there is a simpler way to do this with software, but it's about my skill level.
     
  14. w8one

    w8one TrainBoard Member

    89
    109
    5
  15. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    I ordered one, I'll give it a try. I've had good luck with the Arduino based CMRI nodes. I've daisy chained three together and have been able to control lights and sensors.
     
  16. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    The antenna arrived, but it is the same size as the other one. I'm going to test it to see if it is better at picking up through the rails, and I'll also test it on the side of the car.
     
  17. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    6
    Hi

    I know I'm reviving a year old thread, but, I wonder if this proigressed any. I am about to experiment with an Arduino, JMRI and RFID so I thought I'd see if there was any success here. I have been looking at Railcom too, but, I think this is a better option for me.

    Thanks, Andrew
     
  18. mrp

    mrp TrainBoard Member

    21
    3
    11
  19. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    My initial test runs showed that the cheaper RFID tags and readers just didn't read reliably enough when I was testing them. I've moved on to other projects, because I still have no idea how I would write the code to interpret the data if I was able to collect it. There are higher quality RFID units out there, but I don't want to spend that much for this feature.
     
  20. GrahamCD

    GrahamCD New Member

    1
    0
    1
    I'm getting into this thread late, and there may be others that are more recent but I'm a new member and can't seem to navigate the various forums very well.
    I'm starting to look at Arduino - JMRI - NCE Powercab integration with a view to detecting rfid tag equipped locos then associating the tag id with a DCC loco id by matching a limited number (16) of tag ids with each of the bits in 2 bytes in a cmri message generated by an Arduino and sent to JMRI. JMRI jython scripts and/or logix statements then listen for the related sensor state changes (JMRI sensor per cmri bit) and construct dcc packets to control the detected loco via the USB connection to the Powercab.
    By spreading a few RFID readers around my layout I can then keep track of which loco id is in the "pseudo block" following that reader and perform more "fine-grained control" of the locos based on other sensors such as LRDs which are easier to interface to the JMRI automation logic. I.e., the RFID reader identifies the loco and places it within the "pseudo block" within which it can then be controlled by the more basic detection sensors.
    I have experimented with the Arduino - JMRI - logix - Arduino communication paths to familiarize myself with JMRI but have yet to tie in the RFID reader and DCC control pieces of the puzzle.
    Is anyone interested in this - or maybe already done it? I know there are commercially available products that can make this happen (e.g., using decoder feedback) but I would like to explore this cheaper DIY approach before resorting to that. I also have several old steam locos that are only equipped with basic decoders so don't lend themselves to this commercial approach. I think the vendors are more interested in getting us to buy more of their hardware!
     

Share This Page