How to set up smartphones and PCs. Informational portal
  • home
  • Safety
  • Reading and writing RFID tags. RC522 module for Arduino

Reading and writing RFID tags. RC522 module for Arduino

This project was made at the request of a friend for installation on a door to a warehouse. In the future, several more were made at the request of friends and acquaintances. The design turned out to be simple and reliable. This device works like this: it lets through only those RFID cards that were previously entered into the device's memory.

Key features of the access controller:

RFID card format EMmarin 125kHz

Microcontroller ATtiny13

The number of cards / keychains is 10.
The "OPEN" button is normally open, protected from sticking.
Lock control output, high-current field-effect transistor, latch mode (switched on for a while).

Food - 12c.
Consumption in standby mode - 35 mA.
Number of access cards / key fobs - 10 pcs.
The communication length with the "OPEN" button is 10 meters.
Lock control output type - open drain (powerful field-effect transistor, current up to 2A).

Schematic diagram of an access restriction controller on 125KHz RFID cards (Em-Marin) for 10 cards (on an ATtiny13 microcontroller):

If it is necessary to operate an electromagnetic lock, it is required to install an output relay with the required contact group.

Appearance of the assembled RFID validator:

Setting Fuse Bits in PonyProg:

Operation of the device, download the video recorded by the author.
Also, one of the readers published a video of the assembled device:

Programming instructions

Operating mode - when 12V is supplied to the controller, the LED flashes 1Hz.
Programming mode - LED flashes 2Hz.
When the "OPEN" button is pressed, a series of short beeps during the opening of the lock.

Sound signals

1 short signal - the card or key fob is saved in the controller's memory.
2 short beeps - the card or key fob is already stored in the controller's memory.
5 short signals - exit from the programming mode.
1 long beep - the key card memory has been erased from the controller.
Continuous short beeps - card / key memory is full, max. 10 pcs. (requires power off the controller).

Recording the MASTER CARD and the time of opening the lock

1 - Turn off the controller power supply.
2 - Press the "OPEN" button
3 - While holding the button, connect the power to the controller, after 5 sec. controller "PISKNET", the LED will blink at a frequency of 2 Hz.
4 - Release the button.
5 - Bring the card or key fob into the reading zone, a single beep will be heard, the Master card or key fob is RECORDED, while the time of opening the lock 1 sec will be recorded.

6 - Holding the card or key fob in the reading zone - we read the sound signals. Quantity determines the required time for opening the lock, increment of 1 sec., But not more than 32 sec.
7 - Turn off the power to the controller or pause for 30 seconds.

Erasing All Keychain Memory

1 - Working mode.
2 - Press the "OPEN" button and holding it, bring the MASTER card or key fob to the reader and hold it, after 5 seconds a long beep will be heard - the memory of cards / key fobs has been erased.
3 - Release the button and take away the card or key fob.

Today I will tell you about the RFID module RC522, based on the MFRC522 chip. 3.3V power supply, detection range up to 6cm. Designed for reading and writing RFID tags with a frequency of 13.56 MHz. Frequency is very important in this case, since RFID tags exist in three frequency ranges:


  • LF band labels (125-134 kHz)

  • HF band markers (13.56 MHz)

  • UHF band labels (860-960 MHz)

Specifically, this module works with labels of the HF range, in particular with the MIFARE protocol.

To work with the module, you can use the standard RFID library included in the Arduino IDE, but there is another library written specifically for this module - MFRC522 (1 MB). Both libraries are quite convenient, but the MFRC522 has more special functions that allow you to minimize the final program code as much as possible.

Connection

Some people face a problem - the name of the pins in most tutorials and tutorials may not correspond to the pinout on your module. If the SS pin is indicated in the sketches, but it is not on your module, then most likely it is marked as SDA. Below I will give a table for connecting the module for the most common boards.

MFRC522 Arduino Uno Arduino Mega Arduino Nano v3

Arduino Leonardo / Micro

Arduino Pro Micro
RST 9 5 D9 RESET / ICSP-5 RST
SDA (SS) 10 53 D10 10 10
MOSI 11 (ICSP-4) 51 D11 ICSP-4 16
MISO 12 (ICSP-1) 50 D12 ICSP-1 14
SCK 13 (ICSP-3) 52 D13 ICSP-3 15
3.3V 3.3V 3.3V 3.3V stabilizer 3.3V stabilizer 3.3V stabilizer
GND GND GND GND GND GND

Control pins SS (SDA) and RST are set in the sketch, so if your board is different from the one I will use in my examples, and I am using UNO R3, specify the pins from the table at the beginning of the sketch:


#define SS_PIN 10 #define RST_PIN 9

Example # 1: Reading the card number

Let's look at an example from the RFID library - cardRead. It does not issue data from the card, but only its number, which is usually sufficient for many tasks.


#include #include #define SS_PIN 10 #define RST_PIN 9 RFID rfid (SS_PIN, RST_PIN); // Data about the card number is stored in 5 variables, we will remember them to check if we have already read such a card int serNum0; int serNum1; int serNum2; int serNum3; int serNum4; void setup () (Serial.begin (9600); SPI.begin (); rfid.init ();) void loop () (if (rfid.isCard ()) (if (rfid.readCardSerial ()) (// Compare the card number with the previous card number if (rfid.serNum! = SerNum0 && rfid.serNum! = SerNum1 && rfid.serNum! = SerNum2 && rfid.serNum! = SerNum3 && rfid.serNum! = SerNum4) (/ * If the card is new, then read * / Serial.println (""); Serial.println ("Card found"); serNum0 = rfid.serNum; serNum1 = rfid.serNum; serNum2 = rfid.serNum; serNum3 = rfid.serNum; serNum4 = rfid.serNum; // Print the card number Serial.println ("Cardnumber:"); Serial.print ("Dec:"); Serial.print (rfid.serNum, DEC); Serial.print (","); Serial .print (rfid.serNum, DEC); Serial.print (","); Serial.print (rfid.serNum, DEC); Serial.print (","); Serial.print (rfid.serNum, DEC); Serial.print (","); Serial.print (rfid.serNum, DEC); Serial.println (""); Serial.print ("Hex:"); Serial.print (rfid.serNum, HEX); Serial .print (","); Serial.print (rfid.serNum, HEX); Serial.pr int (","); Serial.print (rfid.serNum, HEX); Serial.print (","); Serial.print (rfid.serNum, HEX); Serial.print (","); Serial.print (rfid.serNum, HEX); Serial.println (""); ) else (/ * If this is already a read card, just print a dot * / Serial.print (".");))) rfid.halt (); )

Is the sketch filled up, the power LED on the module is on, but the module does not respond to the card? Do not panic, or run to look for "correct" examples of work. Most likely, there is simply no contact on one of the pins - the holes on the board are slightly larger than the thickness of the jumper, so you should try to rearrange them. Is the LED on the board off? Try to rearrange the 3.3V jumper and make sure it is connected to 3.3V on the board, supplying 5V power can easily kill your board.

Let's say everything works for you. Then, reading the tags by the RFID module, we will see the following in the serial port monitor:


Here I read 3 different tags, and as you can see all 3 he successfully counted.

Example # 2: Reading data from a card

Let's consider a more elaborated option - it will read not only the card number, but all data available for reading. This time, let's take an example from the MFRC522 library - DumpInfo.


#include #include #define RST_PIN 9 // #define SS_PIN 10 // MFRC522 mfrc522 (SS_PIN, RST_PIN); // Create MFRC522 instance void setup () (Serial.begin (9600); // Initialize the serial port monitor while (! Serial); // Do nothing until it is open (for Arduino on ATMEGA32U4 chip) SPI.begin () ; // Initialize the SPI bus mfrc522.PCD_Init (); // Initialize the RFID module ShowReaderDetails (); // Print data about the MFRC522 module Serial.println (F ("Scan PICC to see UID, type, and data blocks ..." ));) void loop () (// Looking for a new card if (! mfrc522.PICC_IsNewCardPresent ()) (return;) // Select one of the cards if (! mfrc522.PICC_ReadCardSerial ()) (return;) // Display data from the card mfrc522.PICC_DumpToSerial (& (mfrc522.uid));) void ShowReaderDetails () (// Get the version number of the module byte v = mfrc522.PCD_ReadRegister (mfrc522.VersionReg); Serial.RC5 (F ("MF Version 0 ")); Serial.print (v, HEX); if (v == 0x91) Serial.print (F (" = v1.0 ")); else if (v == 0x92) Serial.print (F (" = v2.0 ")); else Serial.print (F (" (unknown) ")); Serial.println (""); // When we receive 0x00 or 0xFF, data transfer is broken if ((v == 0x00) || (v == 0xFF)) (Serial.println (F ("WARNING: Communication failure, is the MFRC522 properly connected?")) ;))

If the previous example worked without errors, then this shouldn't be a problem either. Although, the metro pass, which gave out the card number in the previous example without any problems, turned out to be with an undetectable data type in this one, and the module could not read anything except the card number.

As a result, having read the data from the card, we get its type, identifier, and data from 16 memory sectors. It should be noted that MIFARE 1K cards consist of 16 sectors, each sector consists of 4 blocks, and each block contains 16 bytes of data.


Example # 3: Writing a new identifier to the card

In this example, we will look at changing the card identifier (UID). It is important to know that not all cards support changing the identifier. The card may be rewritable, but that only means rewritable data. Unfortunately, the cards I had in my hands did not support UID rewriting, but I will give the sketch code here just in case.


#include #include / * Set a new UID here * / #define NEW_UID (0xDE, 0xAD, 0xBE, 0xEF) #define SS_PIN 10 #define RST_PIN 9 MFRC522 mfrc522 (SS_PIN, RST_PIN); MFRC522 :: MIFARE_Key key; void setup () (Serial.begin (9600); while (! Serial); SPI.begin (); mfrc522.PCD_Init (); Serial.println (F ("Warning: this example overwrites the UID of your UID changeable card, use with care! ")); for (byte i = 0; i< 6; i++) { key.keyByte[i] = 0xFF; } } void loop() { if (! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial()) { delay(50); return; } // Считываем текущий UID 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.println(); // Записываем новый UID byte newUid = NEW_UID; if (mfrc522.MIFARE_SetUid(newUid, (byte)4, true)) { Serial.println(F("Wrote new UID to card.")); } // Halt PICC and re-select it so DumpToSerial doesn"t get confused mfrc522.PICC_HaltA(); if (! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial()) { return; } // Считываем данные с карты Serial.println(F("New UID and contents:")); mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); delay(2000); }

Example # 4: Writing data to a card

And finally, what it took us so long to get to - writing data to the card. The sweetest part of working with the module is the ability to make a copy of an existing card, add or change something, this is much more interesting than simple reading.

Let's change one of the data blocks on the map:


#include #include #define RST_PIN 9 #define SS_PIN 10 MFRC522 mfrc522 (SS_PIN, RST_PIN); MFRC522 :: MIFARE_Key key; void setup () (Serial.begin (9600); while (! Serial); SPI.begin (); mfrc522.PCD_Init (); // Prepare the key // use the key FFFFFFFFFFFFh which is the standard for empty cards for (byte i = 0; i< 6; i++) { key.keyByte[i] = 0xFF; } Serial.println(F("Scan a MIFARE Classic PICC to demonstrate read and write.")); Serial.print(F("Using key (for A and B):")); dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE); Serial.println(); Serial.println(F("BEWARE: Data will be written to the PICC, in sector #1")); } void loop() { // Ждем новую карту if (! mfrc522.PICC_IsNewCardPresent()) return; // Выбираем одну из карт if (! mfrc522.PICC_ReadCardSerial()) return; // Показываем подробности карты Serial.print(F("Card UID:")); dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); Serial.println(); Serial.print(F("PICC type: ")); byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); Serial.println(mfrc522.PICC_GetTypeName(piccType)); // Проверяем совместимость if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI && piccType != MFRC522::PICC_TYPE_MIFARE_1K && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { Serial.println(F("This sample only works with MIFARE Classic cards.")); return; } // В этом примере мы используем первый сектор данных карты, блок 4 byte sector = 1; byte blockAddr = 4; byte dataBlock = { // Данные, которые мы запишем на карту 0x01, 0x02, 0x03, 0x04, // 1, 2, 3, 4, 0x05, 0x06, 0x07, 0x08, // 5, 6, 7, 8, 0x08, 0x09, 0xff, 0x0b, // 9, 10, 255, 12, 0x0c, 0x0d, 0x0e, 0x0f // 13, 14, 15, 16 }; byte trailerBlock = 7; byte status; byte buffer; byte size = sizeof(buffer); // Аутентификация Serial.println(F("Authenticating using key A...")); status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid)); if (status != MFRC522::STATUS_OK) { Serial.print(F("PCD_Authenticate() failed: ")); Serial.println(mfrc522.GetStatusCodeName(status)); return; } // Показываем текущие данные сектора Serial.println(F("Current data in sector:")); mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); Serial.println(); // Читаем данные из блока Serial.print(F("Reading data from block ")); Serial.print(blockAddr); Serial.println(F(" ...")); status = mfrc522.MIFARE_Read(blockAddr, buffer, &size); if (status != MFRC522::STATUS_OK) { Serial.print(F("MIFARE_Read() failed: ")); Serial.println(mfrc522.GetStatusCodeName(status)); } Serial.print(F("Data in block ")); Serial.print(blockAddr); Serial.println(F(":")); dump_byte_array(buffer, 16); Serial.println(); Serial.println(); // Аутентификация Serial.println(F("Authenticating again using key B...")); status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid)); if (status != MFRC522::STATUS_OK) { Serial.print(F("PCD_Authenticate() failed: ")); Serial.println(mfrc522.GetStatusCodeName(status)); return; } // Записываем данные в блок Serial.print(F("Writing data into block ")); Serial.print(blockAddr); Serial.println(F(" ...")); dump_byte_array(dataBlock, 16); Serial.println(); status = mfrc522.MIFARE_Write(blockAddr, dataBlock, 16); if (status != MFRC522::STATUS_OK) { Serial.print(F("MIFARE_Write() failed: ")); Serial.println(mfrc522.GetStatusCodeName(status)); } Serial.println(); // Читаем данные снова, чтобы проверить, что запись прошла успешно Serial.print(F("Reading data from block ")); Serial.print(blockAddr); Serial.println(F(" ...")); status = mfrc522.MIFARE_Read(blockAddr, buffer, &size); if (status != MFRC522::STATUS_OK) { Serial.print(F("MIFARE_Read() failed: ")); Serial.println(mfrc522.GetStatusCodeName(status)); } Serial.print(F("Data in block ")); Serial.print(blockAddr); Serial.println(F(":")); dump_byte_array(buffer, 16); Serial.println(); Serial.println(F("Checking result...")); byte count = 0; for (byte i = 0; i < 16; i++) { if (buffer[i] == dataBlock[i]) count++; } Serial.print(F("Number of bytes that match = ")); Serial.println(count); if (count == 16) { Serial.println(F("Success:-)")); } else { Serial.println(F("Failure, no match:-(")); Serial.println(F(" perhaps the write didn"t work properly...")); } Serial.println(); // Выводим данные Serial.println(F("Current data in sector:")); mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); Serial.println(); mfrc522.PICC_HaltA(); mfrc522.PCD_StopCrypto1(); } void dump_byte_array(byte *buffer, byte bufferSize) { for (byte i = 0; i < bufferSize; i++) { Serial.print(buffer[i] < 0x10 ? " 0" : " "); Serial.print(buffer[i], HEX); } }

And as a result, we get a map with a changed data block:


Now that you know how to read and write blocks of card data, you can experiment with the labels that you most likely have - passes, public transport passes. Try to read and write data from these cards, a couple of duplicate passes never hurts, right?)

That's all, subscribe and follow the publications. Next time, I'll explain and show you how to add custom characters to a standard 1602 character display, effectively adding graphics to the display.

RFID (Radio Frequency Identification) uses electromagnetic fields to automatically identify and track tags attached to objects. Tags contain electronically stored information. Passive tags collect energy from radio signals from a nearby RFID reader. Active tags have a local power source (such as a battery) and can operate hundreds of meters from the reader. Unlike a barcode, the tag does not need to be within sight of the instrument, so it can be embedded in the tracked object. RFID is one of the methods for automatic identification and data collection.

Application

RFID tags are used in many industries. For example, an RFID reader attached to a vehicle during production can be used to track progress along a conveyor line. Labeled pharmaceuticals can be tracked through warehouses. Implanting RFID microchips into livestock allows for animal identification.

Because RFID tags can be attached to money, clothing and property, or implanted in animals and people, the ability to read personal information without the user's consent poses a serious privacy issue. These risks have led to the development of standard specifications regarding the security of personal data. Tags can also be used in stores to speed up checkout and prevent theft.

Story

In 1945, Leon Theremin invented a listening device for the Soviet Union that re-transmitted radio waves with added audio information. Sound vibrations during vibration affected the diaphragm, which slightly changed the shape of the resonator, which modulated the reflected radio frequency. Although this device was a covert listening device and not an identification tag, it is considered the predecessor of the USB RFID reader as it was activated by audio waves from an external source. Transponders are still used by most aircraft in operation. Previously, similar technology, such as an RFID tag reader, was regularly used by the Allies and Germany in World War II to identify aircraft.

Mario Cardullo's device, patented on January 23, 1973, was the first true precursor to modern RFID, as it was a passive memory radio. The original device was passive, powered by a polling signal. It was demonstrated in 1971 to the New York City administration and other potential users and consisted of a 16-bit memory transponder for use as a pay device. Cardullo's main patent covers the use of radio frequencies, sound and light as transmission media.

Scope of use

The original business plan presented to investors in 1969 showed the following RFID reader applications:

  • use in transport (vehicle identification, automatic payment system, electronic license plate, electronic manifest, vehicle routing, vehicle performance monitoring);
  • banking (electronic checkbook, electronic credit card);
  • personnel, automatic gates, surveillance); medical industry (identification, patient history).

An early demonstration of the reflected power (modulated backscatter) of RFID tags, both passive and semi-passive, was performed by Stephen Depp, Alfred Coelle and Robert Fraiman at Los Alamos National Laboratory in 1973. The portable system ran at 915 MHz and used 12-bit tags. This method is used by most modern UHFID and microwave RFID readers. In modern life, such devices are in great demand.

Specification

An RFID system uses tags attached to identifiable objects. When making an RFID reader with your own hands, it should be borne in mind that two-way radio transmitters-receivers, called interrogators or readers, send a signal to the tag and read its response. RFID tags can be passive, active, or passive. The active tag has a built-in battery and periodically transmits its ID signal. The passive battery (BAP) has a small battery on board and is activated when an RFID reader is present. The passive tag is cheaper and smaller because it has no battery. Instead, the tag uses the radio wave transmitted by the reader. However, for a passive tag to work, it must be illuminated with a power level about a thousand times stronger than for signal transmission. This affects interference and radiation exposure.

September 19, 2013 at 06:32 PM

Budget UHF RFID reader and its development

  • Wireless technology

Hello honorable ladies and gentlemen.
The cheapest UHF RFID reader or EPC Gen2 reader costs no less than 200 USD retail.

How you can make a workable UHF RFID reader out of parts for 10 USD, and how you could benefit from it, is described below.

Most modern EPC Gen2 RFID readers use specialized chips. They are produced by Impinj, AMS and Phychips. The cheapest microcircuits cost about 20 USD in lots of 1000 pieces. RFID readers are great - powerful, nimble, and long-range - but expensive.
In the spring of this year, an article "Simple Low Cost UHF RFID Reader" appeared on the Internet about how to assemble a working RFID reader from common radio components worth about 5 USD in retail. The idea seems to be simple, but it was only recently that it came to implementation. The premise for the development is based on the fact that very often, near the antenna, you need to slowly read a couple of three tags, and there is no need to pay a lot of money for a reader with a rate of fire of 200-500 tags per second. The block diagram of the reader is shown in the picture.


Its beauty is in simplicity. The basis is a conventional microcontroller, which generates EPC Gen2 signals on the GPIO leg, which are necessary for polling the tag. The signals are transmitted to the Melexis TH72035 transmitter microcircuit, then to the antenna through the Johanson 0910CF15B0100 coupler. The receiver is assembled on one MAX931 comparator according to the following diagram.


Logic signals from the receiver go to another GPIO pin of the microprocessor. We get a simple software UHF RFID reader. Of course, writing a software-based EPC Gen2 RFID reader is not a pound of raisins. But if you clearly define your goals and use only the desired subset of the EPC Gen2 protocol, then the task is greatly simplified.
The authors of the described project consider placing all RFID reader components on one board as one of the goals of its further development. But wouldn't it be more interesting to go in the opposite direction? That is, to divide the reader into physically separate functional modules and then build an RFID reader with the necessary characteristics from different modules. Everything below is just an idea, without a detailed study.

It is clear that the main module is microprocessor-based. Probably, it needs to be done on the Cortex-M0, brought out to the UART and USB connectors in order to control the reader. To connect the transceiver module, use the 6-pin connector: Rx, Tx, 2 to power the transceiver, 2 GPIOs. Such connectors can be made 2-4, as far as the outputs of the microprocessor are enough.
The transceiver module will be connected to the microprocessor module directly or through a short cable. Perhaps, it is necessary to make several variants of transceiver modules with different power and price, but the same connector. The 5th pin of the connector can be used to turn on the transceiver, and the 6th pin can be used for some kind of sensor if necessary. It makes sense to make a printed circuit board of the transceiver with metallized end half-holes. Then it can be soldered to PCBs with different antennas or PCBs with a coaxial SMA connector.
So, by connecting the microprocessor module and the transceiver module, we get an RFID reader. But just for the sake of this, it is not worthwhile to fence a garden. Let's go further. Let's plug a board with an RS422 driver and an RJ45 socket into the 6-pin connector of the microprocessor module instead of the transceiver (pair 1 - receive, pair 2 - transmit, 3 - power, 4 - GPIO). Let's stick the same one into the transceiver. It is clear that now you can connect the microprocessor module and the transceiver using any patch cord or use an office SCS for connection. In general, the antenna can be located very far from the microprocessor module. And no coax.
And that's not all :) RS422 is a bus. The transceiver can accommodate a D-flip-flop chip. Connect the transceiver modules in series with patch cords. True, you need a second RJ45 connector or a T-splitter, if you put a synchronous counter instead of a D-trigger. Using two GPIOs in the fourth UTP pair, you can select the desired transceiver. It turns out a distributed RFID reader, as in the picture.


Why do you need USB: but in order to be able to connect the reader to an Android tablet.

The solution is applicable where a high speed of reading tags and range is not needed.
1. Not suitable for grocery stores. These are the RFID shops of the future. And RFID shops of the present are department stores (shoes and clothes). There, RFID readers are already used in fitting rooms (together in an interactive display), at checkouts and smart shelves with goods.
2. Warehouses with Euro pallets (chain of transceiver modules where the left corners of the pallets are located).
3. Access system for various public events.
4. Surely somewhere else.

Schematic of an emulator of RFID transponder of the EM-Marine standard (EM4100).
Proximity cards of the Em-Marine standard are by far the most popular means of identification in our country and are used to identify users in access control systems (ACS).
The second, no less popular, field of application of Em-Marine cards is their use in logical access systems when authorizing users by card ID number in the computer operating system and work applications, etc.

Em-Marine cards and keychains.
Accordingly, such identification systems are very common and may be of interest for the implementation of your own identification and automation systems. Since the exchange protocol and hardware of such low-frequency systems is easier for the independent implementation of their own devices, most radio amateur designs on RFID topics are devoted to low-frequency systems.

The operating frequency of Em-Marine cards is 125 KHz. To read them, specialized readers of contactless cards (RFID readers) are used. The interaction of the identifier with such a reader is carried out remotely.
There are a huge number of options for the external design of these identifiers: Em-Marine passes are made in the form of thin and thick cards, bracelets for water parks, various key fobs, radio tags for integration into RFID products.
For the EM4100 transponder standard, the card contains 64 bits of data, and the cards are usually not rewritable. For the convenience of registering cards, the code written in the card is duplicated by printing on one of the sides of the card. The encoding of the data transmitted by the transponder is Manchester encoding. In this case, the periods of the signal transmitted by the transponder are multiples of the frequency 125KHz - the frequency of the signal from the transponder reader. The transponders themselves are implemented without external power supply (passive tag), power is supplied by the LC circuit (coil and capacitor) when the tag enters the field of the card reader. The transponder is also clocked by the reader's signal - 125KHz. Therefore, the parameters of the resulting signal in Manchester coding are multiples of the 125KHz signal.

Scheme of interaction between a transponder and an RFID reader.
For a more complete understanding, let us consider the structure of the RFID transponder package in the EMMarine EM4100 format. The description (in English, taken from annotations) of the transponder packet format is given.
“…… .EM4100 compatible RFID transponders carry 64 bits of Read Only memory. This means that information can be read from the Tag but no data can be changed, or new data written to the card once the card has been programmed with the initial data. The format of the data is as shown here.
1 1 1 1 1 1 1 1 1 9 bit header bits, all 1 "s
8 bit version number D00 D01 D02 D03 P0
or customer ID.
D04 D05 D06 D07 P1
D08 D09 D10 D11 P2 Each group of 4 bits
D12 D13 D14 D15 P3 is followed by an Even 32 Data Bits
D16 D17 D18 D19 P4 parity bit
D20 D21 D22 D23 P5
D24 D25 D26 D27 P6
D28 D29 D30 D31 P7
D32 D33 D34 D35 P8
D36 D37 D38 D39 P9
4 column Parity bits PC0 PC1 PC2 PC3 S0 1 stop bit (0)
The first 9 bits are logic 1 “.
Accordingly, we have 9 start bits of the packet (always logical 1), 11 groups of 4 data bits with 1 row parity bit, 4 column parity bits at the end of the packet, and a terminating bit (always 0).
For example, let's take a transponder with data number 06001259E3.
1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 1 1 0 0 1 0 00
0 6 0 0 1 2 5 9 E 3

The data byte 0x06 is considered the version number. On EM-Marine cards that I came across, decimal values ​​corresponding to the last 3 bytes of the packet are stamped. In any case, for the implementation, we will need to reproduce all 64 bits of the packet according to this description.
Now let's turn carefully to the description of transponder data modulation. Data taken from AN680 annotation. In the figure, I made the marks in red relative to the diagrams of interest to us.

Now let's describe in more detail the diagrams we need. The CLK clock signal is the RFID reader signal, as mentioned earlier. NRZ encoded data should be prepared for the transponder in accordance with the recorded packet data (64 bit). It can be seen that the implementation of NRZ coding based on the transponder packet is elementary and requires minimal resources. Actually, we parse the packet into a bitstream and change the logical values ​​of the signal by 0 and 1 in the data and that's it. To obtain the resulting signal, we programmatically XOR the current state of the signal in the NRZ format and CLK of the clock signal of the reader. As a result, we get Manchester encoding of the resulting signal. I will not describe in more detail about Manchester coding - the data can be found in separate annoutes. For a more detailed description of modulation methods, see the data from “Modulation Methods H.R. Walker Data Systems 05/01/04 (reviewed 4/18/10) ”, I studied these examples. The main thing is that with a minimum expenditure of resources, we can thus implement a transponder in the EM-Marine format. For example, you can take the tiny45 series AVR controller (you can do it on tiny13). Tested on tiny45 because this one was available for experimentation.
Now we will present a functional diagram of a transponder based on the model in Proteus for the tiny45 controller.

Functional diagram of the transponder in Proteus.

This is how the signal generated by the transponder looks like. The beginning of the packet is marked in red.
As you can see from the diagram, the controller pin T0 (PORTB.2) is used to supply the clock signal for the 8-bit timer TIMER0. The program implements a coincidence interrupt on the TIMER0 timer (TIM0_COMPA). Clocking is set from an external signal for this timer. For us, the clock signal is 125KHz from the card reader. In the diagram, everything related to the power supply of the controller and clock circuits from the reader has been removed. In a real circuit, the controller itself is clocked from a 4 MHz quartz crystal installed between the 2 and 3 legs of the controller. You can also add 22 pF quartz bypass capacitors on these controller pins.
The Proteus simulation settings for the controller are specified as follows:

When programming the tiny45 controller, set the fuses (configuration bits) in the same way as shown in the figure. 2. To clock the controller, 4 MHz quartz is used.
Regarding the implementation of the external controller piping scheme, we will consider this issue in more detail. For examples, materials were taken RFID Handbook (E2E_chapter03-rfid-handbook), which describes the fundamental principles of building RFID systems. The document itself is attached to the article. Let's look at an example of a passive transponder diagram (part of the diagram on page 46). For understanding, I made notes on the diagram in red.
It can be seen that we have a receiving circuit on L1C1, which serves to power the transponder circuit and clock. We can safely throw out everything that concerns the counter-divider IC1 (4024), logic elements IC3 (7400) - we will not need it. The divider for the timer is implemented by the timer settings without external dividers - counters, the logic part is also implemented in software. However, this example allows a more complete understanding of the operation of the passive transponder circuit. The maximum reading distance for a transponder of this format is 200cm. In reality, most circuits work at distances of 2-10cm. The parameters of the capacitance and inductance circuit of the LC are selected as accurately as possible to the resonant frequency of 125KHz. As an example, we used a circuit with a capacity of 1nF and a coil of 60 turns on a mandrel with a diameter of 50 mm using a 0.2 PEV wire. You can calculate the desired contour in a special program (you can calculate the contour for a rectangular coil, printed, etc.). The main thing is to choose the exact ratings for the frequency of 125 KHz, otherwise the reading distance and the sensitivity of the circuit will significantly deteriorate. With poorly tuned circuits, it will work only when the transponder coil is brought close to the reader. The device operates on the Full Duplex (FDX) principle - generating transponder data continuously when the circuit is powered. Clocking of the circuit from the reader and data transfer is carried out continuously. Some transponder schemes use the HDX (Half Duplex) operation scheme - the reader emits in a pulse mode, the transponder transmits data in the intervals of these charging pulses from the reader. This applies, for example, to TIRIS transponders from Texas Instruments.

A passive transponder circuit based on a circuit from the RFID Handbook.


Taking into account the part of the circuit that we do not need based on the original circuit, we get the controller piping in this form.



How do you like this article?

Top related articles