- Home/
- Software/
- Software modules
- /URfid
LATEST VERSION 1.1 (23.05.2017)
Additionally, a module was tested using ISO-14443A S50 tags. The technology of these ISO-14443A tags was developed by NXP Semiconductors and the full technical specifications can be seen here LINK.
These tags are sold commercially as stickers, cards or keychain. There are ISO-14443A tags with 1 Kb and 4 Kb of EEPROM.
The tag basically contains two electronic components: a specialized microcontroller known as 'chip' and an antenna for transmission and reception of data at a frequency of 13.56 MHz, which is the standard used in RFID radio link systems.
The microcontroller or 'chip' contains a read-write EEPROM, which is where the tag information is stored. All tags have a serial number, known as NUID (Non Unique Identification Number) of 4 bytes which is factory prerecorded. Some recent manufactured tags feature a serial number of 7 bytes, called UID (Unique Identification Number).
The tags do not have their own power supply, and are energized from the electromagnetic field generated by RFID reader antenna to establish the radio link. To this end, it is necessary to bring the tag to a distance of about 2-4 cm of the RFID module and remain in that position until the read/write cycle of the tag has been concluded.
The communication between the tag and the RFID reader module is handled, as mentioned, by radio link, at a frequency of 13.56 MHz and through a proprietary protocol. During the exchange of data between two devices, 16-bit CRC protection codes are managed to ensure the integrity of the stored and read information from the EEPROM. The speed of data transmission between the tag and the RFID device reaches about 100 kbits/sec.
For the ISO-14443A 1 Kb tag, the total capacity in the EEPROM is 1024 bytes. However, because of the locations used for security codes, the number of user available locations for data storage is 768 bytes. The memory of the 1 Kb EEPROM is organized in 16 sectors of 4 blocks each, for a total of 64 blocks. Each block in turn is constituted by 16 bytes.
In sector 0, block 0, the first 4 bytes store the tag's serial number (NUID) and manufacturer information. This block is protected and can only be read. The byte number 4 is known as BCC (Block Check Character) and is a checking value for the serial number, calculated with the logical operation 'Exclusive OR' of the previous 4 bytes.
Each sector, as mentioned, has 4 blocks. The fourth block is called "Sector Trailer" and has the function of setting permissions and access codes for reading / writing data from that sector. In this block, 2 security codes called Key A and Key B are included as well as 4 bytes "Access bits" for configuration management to be given to the data in that sector. The Key A code can be written but not read.
The Key B code is optional and may be used or not, to the convenience of the system programmer. Data can only be read or modified in any sector only if the Key A and / or Key B are known. Both keys provide a safety mechanism for the protection and integrity of data in each sector.
The ISO-14443A purchase a new card, by default, both Key A and B have values
0xFFFFFFFFFFFF
and the "Access bits" have values
0x07 0x80 0x69 0xFF.
This initial settings in ISO-14443A tags, are called 'transport configuration'.
The 16 blocks called "Sector Trailers" are identified with the numbers:
3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59 and 63,
and can not be used by the user to store information, but only for the purposes outlined above, ie, select the configuration and security settings of each sector.
The so called "Access bits", are arranged as shown in the table below. The base is formed by 3 bits, C1, C2 and C3, which define permissions for each of the 4 blocks of the sector. To identify the function of each bit, subscripts are used, for example, for the configuration of block 3, bits C13, C23 and C33 would be used.
In total, 12 bits are used for the configuration of the 4 blocks. As shown in the figure, the 12 bits of access are stored, including its complement, to provide a verification of the integrity of this data.
The settings options of the access bits on read /write data of the tag are very numerous. For complete usage information of access bits for ISO-14443A tags, please read documentation LINK.
These tags are very similar to S50, but have bigger memory and slightly different memmory organization. The 4 kByte EEPROM memory is organized in 32 sectors with 4 blocks (as S50) and in 8 sectors with 16 blocks. One block consists of 16 bytes.
URfid.new(); - initialize module
URfid.IsCard(); - check if card exist, this function always fills cardSerial variable,
returns:
0 - no card,
1 - is card,
2 - is more than one card,
URfid.cardSerial; - card serial number, [sn0,...,sn3], read if IsCard() returns true;
URfid.requestMode; - set request mode,
0 - idle,
1 - all,
URfid.keyType; - set access key type,
0 - KeyA,
1 - KeyB,
URfid.SetBlockKey([key0,…,key5]); - set access key, key must be 6-size array.
URfid.ReadCard(startBlock, numberBlocks); - read data from card, returns true if success,
startBlock - 0..(cardMemorySize/16 - 1),
numberBlocks - 1..4,
URfid.cardData; - read data in array form, [data0, data1,..,data15],
URfid.cardString; - read data in string form, "text"
BE CAREFUL to not write Sector Trailer if not intend, recommend to write data block by block - size not longer than 16!
URfid.WriteCardData(startBlock, [data0, data1,..,data15]); - write data to card, returns true if success,
startBlock - 1..(cardMemorySize/16 - 1), 0 can NOT be written,
data - size must be 1..64, function writes multiple of 16, ie. [0,1,2,3,4,5,6,7,8,9] will write whole block [0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0]
URfid.WriteCardString(startBlock, "0123456789ABCDEF"); - write text to card, returns true if success,
startBlock - 1..(cardMemorySize/16 - 1), 0 can NOT be written,
text - size must be 1..64, function writes multiple of 16 characters, ie. "abcdefghij" will write whole block "abcdefghij\0\0\0\0\0\0"
URfid.Buzzer(freq, duration); - turn on buzzer,
URfid.LED(freq, duration); - turn on/off LED blinking.
loadModule("URfid"); var Global.Rfid = URfid.new(); Rfid.Buzzer(3, 2); Rfid.LED(10, 2); t:every (500ms) { if (Rfid.IsCard()) { Rfid.Buzzer(2, 1); Rfid.LED(10, 1); echo("[" + Rfid.cardSerial[0] + " " + Rfid.cardSerial[1] + " " +Rfid.cardSerial[2] + " " + Rfid.cardSerial[3] + "]"); Rfid.ReadCard(4,1); sleep(2); }; },
Optional tool: USB RFID reader v1.0 - simple application to read and write S50 cards.