如何在UHF RFID标签上写入数据?

8

我正在开发一个基于RFID的库存控制项目,希望能够创建一个写入器,通过它可以将数据写入每个被动RFID标签。请问如何实现?

7个回答

8
根据你的预算,购买一个RFID读写器可能比自己制作更简单。市面上有许多好的读写器,并且API易于使用。大多数主要的UHF RFID读写器都使用称为LLRP(低级读取器协议)的通用标准,因此,您可以编写一组代码,并可与支持LLRP的任何读写器一起使用。绝大多数UHF RFID标签都在gen2协议(ISO 18000-6C)上工作,所以只需确保您的读写器也是如此。
假设您正在使用gen2 RFID标签,则向标签编码非常简单。您只需通过命令告诉读写器要对标签进行编码即可。当然,有一些注意事项需要注意,例如编码必须采用十六进制格式,并且标签上有一些不同的存储块-EPC,Reserved,TID和用户。(注意:您无法对所有存储块进行编码。有关此主题的更基本信息,请参见此博客文章:http://blog.atlasrfidstore.com/types-of-memory-in-gen-2-uhf-rfid-tags
另一个需要考虑的问题是要编码多少数据到标签中。您将使用的两个主要存储块是EPC(通常为96位,但在某些标签上,此数字可能更高)和用户(标准为约512位,但市场上有一些具有更高用户存储器的gen2标签)。

3
RFID的读写仍然取决于标签技术、硬件读写器和软件设备驱动程序。目前,没有通用的Windows API适用于RFID。但是,有一个名为UnifiedPOS的标准,它提供了一个包装器,使所有RFID扫描仪都具有相同的行为。您只需一次编写应用程序到UnifiedPOS接口,然后就可以使用任何具有UnifiedPOS兼容服务对象的RFID扫描仪。它可通过Windows OPOS和Java的“JavaPOS”获得。此外,还有Microsoft的.Net POS

在选择标签和读写器的硬件时,请考虑制造商是否提供兼容的服务对象。这将使读写操作更加简单。



0

0

RFID是一种磁性标签,所以如果你对这个主题有很好的知识,你可以制作它,但我认为(我不知道确切的过程),这是相当困难的...

然而,我知道有一种Arduino NFC Shield,可能可以帮助你。类似于这样:http://www.adafruit.com/products/789


3
楼主要求使用电磁辐射的超高频RFID技术,NFC则是基于感应耦合的高频RFID技术。这两种技术在所涉及的电子元件方面完全不同。 - corvairjo

0

我不确定您所说的“writer”是指硬件(+软件),还是只需要软件就能满足您的需求。@Gp2mv3提到了NFC,因此,如果您的标签属于RFID的NFC类型子集,则最简单的方法是拿起手机,下载一个免费的NFC写入应用程序并使用它。

如果您想编写自己的软件,在Android平台上有很多示例,我认为其他平台也是如此。我可以想象甚至可以设置一种方案,在这种方案中,您将手机通过USB连接到PC上,并使用它与混合PC +移动应用程序伴侣软件一起作为编写器。


0
#include <SPI.h>
#include <MFRC522.h>
/*Using Hardware SPI of Arduino */
/*MOSI (11), MISO (12) and SCK (13) are fixed */
/*You can configure SS and RST Pins*/
#define SS_PIN 10  /* Slave Select Pin */
#define RST_PIN 7  /* Reset Pin */
/* Create an instance of MFRC522 */
MFRC522 mfrc522(SS_PIN, RST_PIN);
/* Create an instance of MIFARE_Key */
MFRC522::MIFARE_Key key;          
/* Set the block to which we want to write data */
/* Be aware of Sector Trailer Blocks */
int blockNum = 2;  
/* Create an array of 16 Bytes and fill it with data */
/* This is the actual data which is going to be written into the card */
byte blockData [16] = {"Hi Ozzy"};
/* Create another array to read data from Block */
/* Legthn of buffer should be 2 Bytes more than the size of Block (16 Bytes) */
byte bufferLen = 18;
byte readBlockData[18];
MFRC522::StatusCode status;
void setup() 
{
/* Initialize serial communications with the PC */
  Serial.begin(9600);
/* Initialize SPI bus */
  SPI.begin();
/* Initialize MFRC522 Module */
  mfrc522.PCD_Init();
  Serial.println("Scan a MIFARE 1K Tag to write data...");
}
void loop()
{
/* Prepare the ksy for authentication */
/* All keys are set to FFFFFFFFFFFFh at chip delivery from the factory */
for (byte i = 0; i < 6; i++)
  {
    key.keyByte[i] = 0xFF;
  }
/* Look for new cards */
/* Reset the loop if no new card is present on RC522 Reader */
if ( ! mfrc522.PICC_IsNewCardPresent())
  {
return;
  }
/* Select one of the cards */
if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
return;
  }
  Serial.print("\n");
  Serial.println("**Card Detected**");
/* Print UID of the Card */
  Serial.print(F("Card UID:"));
for (byte i = 0; i < mfrc522.uid.size; i++)
  {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
  }
  Serial.print("\n");
/* Print type of card (for example, MIFARE 1K) */
  Serial.print(F("PICC type: "));
  MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
  Serial.println(mfrc522.PICC_GetTypeName(piccType));
/* Call 'WriteDataToBlock' function, which will write data to the block */
   Serial.print("\n");
   Serial.println("Writing to Data Block...");
WriteDataToBlock(blockNum, blockData);
/* Read data from the same block */
   Serial.print("\n");
   Serial.println("Reading from Data Block...");
ReadDataFromBlock(blockNum, readBlockData);
/* If you want to print the full memory dump, uncomment the next line */
//mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
/* Print the data read from block */
   Serial.print("\n");
   Serial.print("Data in Block:");
   Serial.print(blockNum);
   Serial.print(" --> ");
for (int j=0 ; j<16 ; j++)
   {
     Serial.write(readBlockData[j]);
   }
   Serial.print("\n");
}
void WriteDataToBlock(int blockNum, byte blockData[]) 
{
/* Authenticating the desired data block for write access using Key A */
  status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, blockNum, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK)
  {
    Serial.print("Authentication failed for Write: ");
    Serial.println(mfrc522.GetStatusCodeName(status));
return;
  }
else
  {
    Serial.println("Authentication success");
  }
/* Write data to the block */
  status = mfrc522.MIFARE_Write(blockNum, blockData, 16);
if (status != MFRC522::STATUS_OK)
  {
    Serial.print("Writing to Block failed: ");
    Serial.println(mfrc522.GetStatusCodeName(status));
return;
  }
else
  {
    Serial.println("Data was written into Block successfully");
  }
}
void ReadDataFromBlock(int blockNum, byte readBlockData[]) 
{
/* Authenticating the desired data block for Read access using Key A */
  byte status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, blockNum, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK)
  {
     Serial.print("Authentication failed for Read: ");
     Serial.println(mfrc522.GetStatusCodeName(status));
return;
  }
else
  {
    Serial.println("Authentication success");
  }
/* Reading data from the Block */
  status = mfrc522.MIFARE_Read(blockNum, readBlockData, &bufferLen);
if (status != MFRC522::STATUS_OK)
  {
    Serial.print("Reading failed: ");
    Serial.println(mfrc522.GetStatusCodeName(status));
return;
  }
else
  {
    Serial.println("Block was read successfully");  
  }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接