PN532 NFC/RFID reading multiple tags
Moderators: adafruit_support_bill, adafruit

PN532 NFC/RFID reading multiple tags

by paulofloresjunior on Fri Dec 07, 2012 2:28 pm

Hi,

I have one PN532 NFC/RFID and I need to read multiple tags to know how many objects are near to PN532.
In reading program example (from Arduino SDK) I can reading 2 tags in same time, but I want to read all tags, how can I do that?

Thanks in advanced,
Paulo
paulofloresjunior
 
Posts: 2
Joined: Fri Dec 07, 2012 1:52 pm

Re: PN532 NFC/RFID reading multiple tags

by ktownsend on Wed Dec 12, 2012 12:47 pm

You can only physically read max two cards. The spec and HW is defined tha way.
User avatar
ktownsend
 
Posts: 355
Joined: Thu Nov 05, 2009 2:18 am

Re: PN532 NFC/RFID reading multiple tags

by paulofloresjunior on Thu Dec 13, 2012 8:48 am

ktownsend wrote:You can only physically read max two cards. The spec and HW is defined tha way.


Do you know another hardware that can do that?

Thanks,
Paulo
paulofloresjunior
 
Posts: 2
Joined: Fri Dec 07, 2012 1:52 pm

Re: PN532 NFC/RFID reading multiple tags

by ktownsend on Fri Dec 14, 2012 9:46 am

It's not a HW problem in terms of the chip, it's a limitation of the NFC and appropriate ISO standards. Being able to read two cards at once is already an added feature ... I don't see how you can read a stack of cards, so no ... I don't know anything that can do that.
User avatar
ktownsend
 
Posts: 355
Joined: Thu Nov 05, 2009 2:18 am

Re: PN532 NFC/RFID reading multiple tags

by gordiegii on Fri Feb 01, 2013 11:45 pm

This card seems to be able to handle up to 15 at a time (http://www.dlpdesign.com/dlp-rfid2-ds-v10.pdf) so I don't see how it could be a limitation of the protocol...

So is it a limitation of the chip or the library?

Gordie.
Logic is the art of going wrong with confidence. -- Morris Kline
User avatar
gordiegii
 
Posts: 29
Joined: Fri Jan 04, 2013 8:26 pm
Location: Toronto, Canada

Re: PN532 NFC/RFID reading multiple tags

by dennisma on Sat Feb 02, 2013 12:58 am

There is no RFID limitation in the spec that I have ever heard of. On the contrary there are readers that can read tens/hundred RFID tags simultaneously.

Here is a post from the RFID Journal that briefly discusses this http://www.rfidjournal.com/article/view/7853. It states:

One way to understand this is to think of a teacher trying to take attendance in a room containing a lot of students, but with no list of the children's names. The instructor might announce, "If your last name begins with the letter A, stand up." If five children stand up, he or she might say, "If your last name starts with AA, remain standing. If not, sit down." That might leave one child to communicate with. Then the teacher can say, "If your last name starts with AB, please stand up." And so on.

RFID systems have a variety of different means of doing this as rapidly as possible. But essentially, they all come down to the same processes of polling the tags, and narrowing down the requests until the reader can communicate with one tag at a time. It happens very quickly, so it appears you are reading 50 or so tags at the same time, when, in fact, the reader is communicating with only one tag in any given interval.
...
I have seen the firm read 100 tags on documents stacked one on top of another. I have also witnessed NXP Semiconductors interrogate tags on 90 drug vials without a problem.
User avatar
dennisma
 
Posts: 31
Joined: Fri Feb 01, 2013 5:39 pm

Re: PN532 NFC/RFID reading multiple tags

by gordiegii on Sat Feb 02, 2013 5:31 pm

OK. I'm new here. How does one get a decisive answer from Adafruit re this subject.
Does the chip / board(s) / library support 'simultaneously' reading from more than two tags?

Gordie.
Logic is the art of going wrong with confidence. -- Morris Kline
User avatar
gordiegii
 
Posts: 29
Joined: Fri Jan 04, 2013 8:26 pm
Location: Toronto, Canada

Re: PN532 NFC/RFID reading multiple tags

by adafruit_support_bill on Sun Feb 03, 2013 7:20 am

How does one get a decisive answer from Adafruit re this subject.
Does the chip / board(s) / library support 'simultaneously' reading from more than two tags?

Ktownsend is the designer of the board. His answer was at the top of the thread:
You can only physically read max two cards. The spec and HW is defined tha way.
User avatar
adafruit_support_bill
 
Posts: 30796
Joined: Sat Feb 07, 2009 10:11 am

Re: PN532 NFC/RFID reading multiple tags

by gordiegii on Mon Feb 04, 2013 1:38 am

Oops! Didn't realize. Please accept my apologies.

Then ktownsend is the right person to ask.

So as I understand it, the limitation must be that the chip is designed for phones, not inventory readers, and therefore has only implemented resources enough to keep track of two tags at a time (but can chat with other phones). Hacking the library isn't going to help. So if I want to be able to read more than 2 tags at a time, then, unless there is a more (or differently) capable chip that could be subbed onto this shield I will have to get something else. (...like the DLP-RFID2)

Does that sound accurate?

BTW: Is the library for this card open source? I wouldn't want to write an interface from scratch if I could modify an existing one. (...by which I mean "I wouldn't want to get my son to write an interface from scratch if I could get him to modify an existing one." I'm more of a hardware guy.)

Gordie.
Logic is the art of going wrong with confidence. -- Morris Kline
User avatar
gordiegii
 
Posts: 29
Joined: Fri Jan 04, 2013 8:26 pm
Location: Toronto, Canada

Re: PN532 NFC/RFID reading multiple tags

by adafruit_support_bill on Mon Feb 04, 2013 7:51 am

I'll let Kevin answer your questions about the chip.
But to answer your last question: Yes, all our libraries are open source : https://github.com/adafruit/Adafruit_NFCShield_I2C
User avatar
adafruit_support_bill
 
Posts: 30796
Joined: Sat Feb 07, 2009 10:11 am

Re: PN532 NFC/RFID reading multiple tags

by ktownsend on Mon Feb 04, 2013 8:14 am

As stated, you can only ever read two tags at most with this chip. It's a fixed in stone HW limit that no amount of firmware hacking will get around.

RFID is a very big field and there are many solutions for many problems (different protocols, different frequencies, etc.) ... NFC is intended for very short range communication, not something like inventory control where other RFID frequencies and standards are a much better match.

Based on your description, this probably isn't the chip that you want or need.

Kevin
User avatar
ktownsend
 
Posts: 355
Joined: Thu Nov 05, 2009 2:18 am

Re: PN532 NFC/RFID reading multiple tags

by ktownsend on Mon Feb 04, 2013 8:18 am

dennisma wrote:There is no RFID limitation in the spec that I have ever heard of. On the contrary there are readers that can read tens/hundred RFID tags simultaneously.

The discussion was specifically for the PN532 shield and NFC, which does have a very specific fixed 2-tag limit.

Talking about generic RFID isn't particularly useful ... the possibilities are all over the map. But NFC is a very specific segment of the (very wide) RFID landscape, with very specific limitations and possibilities.
User avatar
ktownsend
 
Posts: 355
Joined: Thu Nov 05, 2009 2:18 am

Re: PN532 NFC/RFID reading multiple tags

by uniapa on Tue May 28, 2013 12:19 pm

I found a 'solution' to this problem. I needed to read more than two tags at the same time, and while searching I found that we can 'hold' tags. When you hold a tag, you're just telling him "Do not answer anymore until you leave my range and enter again", so if you use the hold command immediately after reading each tag, you can read lot's of tags "at the same time".

To do that, I added these lines at the end of the readPassiveTargetID function in the nfc arduino library:
Code: Select all | TOGGLE FULL SIZE
    // Test to deselect the last read tag
    byte bTestDeselect[2];
    bTestDeselect[0] = PN532_COMMAND_INDESELECT;
    bTestDeselect[1] = pn532_packetbuffer[8];
    sendCommandCheckAck(bTestDeselect,2);
    Serial.print("Tried to disable tag");


The code is far from being complete, but it worked as a proof of concept. I dropped five tags on the shield, and it gave me five different id's (but only once, since you told the tags to stop answering after the first read). After holding a tag, you can even unhold it, with it's id, but I didn't explore that functions (yet). If someone does something interesting with this, please let me know!

Paulo (yes, my name it's the same as OP!)
uniapa
 
Posts: 2
Joined: Tue May 28, 2013 12:09 pm

Re: PN532 NFC/RFID reading multiple tags

by jarkesia on Sat Jun 29, 2013 5:18 pm

If you are using Mifare tags PN532 API has a command to call for known tags. So if you are building the system that is using a known set of tags, it is possible to just call tags repeatedly by their address. With this approach it is also possible to scan when tags are taken away from antenna. readPassiveTargetID is the command to search from the datasheet. Totally works with hand full of tags on antenna. Other option is halting of tags proposed in earlier mail.
jarkesia
 
Posts: 1
Joined: Sat Jun 29, 2013 5:11 pm

Re: PN532 NFC/RFID reading multiple tags

by ashtonmarkson on Mon Jan 20, 2014 11:37 pm

Just wanted to leave this here as I struggled with this for some time on a pi.
When trying to run the libnfc:anticol example, I couldn't get it to actually work with two adafruit provided cards. Some BCC error which I couldn't for the life of me figure out.


To read many at once, or at least serially in a loop as outlined above I simply had to add
Code: Select all | TOGGLE FULL SIZE
nfc_initiator_deselect_target(pnd);

to a loop which gets invoked when
Code: Select all | TOGGLE FULL SIZE
nfc_initiator_select_passive_target(..)

gets called.

So an example derived from /libnfc/libnfc-1.7.0/examples/doc/quick_start_example1.c

Code: Select all | TOGGLE FULL SIZE
//add loop, in my case 100...
for (totalCards = 0; totalCards <= 100; totalCards++) {
//this was here before...
  const nfc_modulation nmMifare = {
    .nmt = NMT_ISO14443A,
    .nbr = NBR_106,
  };

  if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) {
    printf("The following (NFC) ISO14443A tag was found:\n");
    printf("    ATQA (SENS_RES): ");
    print_hex(nt.nti.nai.abtAtqa, 2);
    printf("       UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1'));
    print_hex(nt.nti.nai.abtUid, nt.nti.nai.szUidLen);
    printf("      SAK (SEL_RES): ");
    print_hex(&nt.nti.nai.btSak, 1);
    if (nt.nti.nai.szAtsLen) {
      printf("          ATS (ATR): ");
      print_hex(nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
    }
  }
//simply add this
   nfc_initiator_deselect_target(pnd);
}


Now when I read, I can have a deck of cards and one by one I read and "work-with" multiple tags.

Pretty cool...
ashtonmarkson
 
Posts: 4
Joined: Tue Dec 24, 2013 5:23 pm