Long Distance 134.2Khz Modbus Card Reader

1,Communication and Protocol Description

Serial port (8 bits):

Baud rate 19200Bps
Check 1 Parity Check
Stop Bit 1bit

System Configuration Content(16hex)

1,Antenna switch and response mode. In the following content (active transmission from the slave), the reader will actively send tag data after reading the card. (Master-slave mode) means that the card reader will not actively return data until the host accesses it. (This configuration data is not saved when power is cut off. It needs to be configured once every time power is turned on.(16hex communication)

Host sends commands Configuration content Return Remarks
02 06 00 00 00 03 C9 F8 Open antenna, active transmission from slave 02 06 00 00 00 03 C9 F8 Usually used in one master-slave communication
02 06 00 00 00 02 08 38 Antenna open, master-slave mode 02 06 00 00 00 02 08 38
02 06 00 00 00 01 48 39 Antenna Close, slave active transmission 02 06 00 00 00 01 48 39
02 06 00 00 00 00 89 F9 Antenna close, master-slave mode 02 06 00 00 00 00 89 F9

2,The length of data and the address of the reader in the back of the card. Back-band data means that some cards send data with other data besides the card number and country code. Current products support maximum access 20 bytes of data (160bit) This configuration data is saved without loss of power.(16hex Communication)

Host sends commands Configuration content Return Remarks
02 06 00 01 A0 02 21 F8 A0(160)bit Address 0x02 (1-247) 02 06 00 01 A0 02 21 F8 Read with data 160 Bit, address Set as 0x02
02 06 00 01 00 02 59 F8 No additional data (range:0-160)address 0x02 (1-247) 02 06 00 01 00 02 59 F8 When the configuration value is out of range, the return value is normal, but the system ignores it.

Read data: (16hex communication)

1. Read the antenna switch and response mode information. (hexadecimal communication)

Host sends commands Configuration content Return Remarks
02 03 00 00 00 01 84 39 Read back 0x00 address info 02 03 02 00 03 BC 45 Open antenna, active transmission from slave

2. After reading, the data length, address, and version number information are included. (hexadecimal communication)

Host sends commands Configuration content Return Remarks
02 03 00 01 00 04 15 FA Read back 0x01-0x04 address info 02 03 08 A0 02 17 05 B1 FA 00 01 BA C1 After adding data length 0xA0, address: 0x02, version information:17 05 B1 FA 00 01

3. Read system tuning status information (hexadecimal communication)

Host sends commands Configuration content Return Remarks
02 03 00 05 00 09 95 FE Read back 0x05-0x0D address info 02 03 12 B5 3F 50 62 81 9C B9 B6 98 8A 70 60 52 4A 41 3C 37 05 26 AA System tuning status information, used to view the working status of the module, usually do not need to read

4, reading card data read: (hexadecimal communication)

Host sends commands Configuration content Return Remarks
02 03 00 0E 00 07 65 F8 Read back 0x0E-0x15Address information, length 0x07 02 03 0E 02 62 07 B6 60 CB 53 00 80 00 00 00 00 3E DC F6 Read card information such as card number
02 03 00 0E 00 11 E4 36 Read back 0x0E-0x1F address information, length 0x11 02 03 22 02 62 07 B6 60 CB 53 80 80 00 00 00 11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43 FF 20 D5 CF Read card number information and data information

The read data can be read from 0x07-0x11 (that is, the readback information address can be from (0x0E-0x15) to (0x0E-0x1F)).

Send command analysis(02 03 00 0E 00 07 65 F8)

02: Slave address

03: Read function(MODBUS-RTU);

000E:Read register address

0007: read data length (7 words 14 Bytes);

65F8:All previous data (02 03 00 0E 00 07) CRC check value,Low byte first.

Receive command analysis: (1)02 03 0E 02 62 07 B6 60 CB 53 00 80 00 00 00 00 00 00 3E DC F6)

02: slave address;

03: Read function (MODBUS-RTU);

0E: readback data length (14 Bytes);

0262: Country code (10 hex)

07B660CB53: Card number data (10-digit 33124567891)

00:0000 0000 The lowest bit represents whether the post-add data is valid (0 is invalid, 1 is valid), and the other 7 bits are undefined data.

80:1000 0000 The highest digit represents the animal logo, and the other 7 digits are undefined data.

000000: Other data in the card, no data is defined.

00: Data transfer supplements enough for even digital sections (14 Bytes), meaningless

3E: The current data read time (0x3E*0.2s) proved to be read before 12.4s, up to 51s.

DCF6: CRC check of the entire previous packet (02 03 0E 02 62 07 B6 60 CB 53 00 80 00 00 00 00 3E). DC is the low byte and F6 is the high byte.

Receive command analysis: (02 03 22 02 62 07 B6 60 CB 53 80 80 00 00 00 11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43 FF 20 D5 CF)

02 03 22 02 62 07 B6 60 CB 53 80 80 00 00 00: Consistent with the above analysis.

11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43: 20 bytes of post added data.

FF: Data transfer supplements enough for even digital sections (34 Bytes), meaningless.

20: The current data reading time (0x20*0.2s) proved to be read before 6.4s, up to 51s.

D5CF: CRC check of the entire previous packet, D5 is the low byte and CF is the high byte.

The slave sends the message actively: the machine will send a frame of data immediately after reading the card. If the card does not leave the data, it will not be sent repeatedly. If the card leaves 0.2s or more and then enter the machine, it will send another frame of data (each card enters Will send a frame of data to the bus in real time)

When the card reader is configured as the slave active transmission mode, the card reader will send the card number information to the bus immediately after reading the card. The length of the information can be configured. For example, we will configure the post-added data length to 30 bits (16 bits or less). Do not send data after sending, the data is valid from 16-160), 35 bits are 4 bytes, 3 bits need 5 bytes to send, so the string data length is 12 (card number information length) +5=17 words Section, but since the data length number is even (word), it is necessary to add a random number, that is, 18 pieces. So the composition of the string is 0xxx (slave address) + 0x03 (function) + 0x12 (18 bytes) + 18 bytes of data + 2 bytes of CRC. A total of 23 bytes. (After adding data, if there is no need, it is better to match 0, which is good for data transmission)

For example, add data configuration A0 (160 bits, 20 bytes). The data received when the card has data added is:03 03 20 02 62 07 B6 60 CB 53 01 80 00 00 00 11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43 C1 26

03: slave address;

03: Read function (MODBUS-RTU);

20: read back the data length (32 Bytes);

0262: Country code (10 hex)

07B660CB53: Card number data (10-digit 33124567891)

01:0000 0001 The lowest bit represents whether the post-add data is valid (0 is invalid, 1 is valid), and the other 7 bits are undefined data.

80:1000 0000 The highest digit represents the animal logo, and the other 7 digits are undefined data.

000000: Other data in the card, no data is defined.

11 11 11 11 22 22 22 22 33 33 24 55 25 25 45 53 55 84 53 43: Yes, add 20 bytes of data.

C126: CRC check.

After the post-add data is configured as 0, the data is read: 02 03 0C 02 62 07 B6 60 CB 53 01 80 00 00 00 17 35

02: slave address;

03: Read function (MODBUS-RTU);

0C: readback data length (12 Bytes);

0262: Country code (10 hex)

07B660CB53: Card number data (10-digit 33124567891)

01:0000 0001 The lowest bit represents whether the post-add data is valid (0 is invalid, 1 is valid), and the other 7 bits are undefined data.

80:1000 0000 The highest digit represents the animal logo, and the other 7 digits are undefined data.

000000: Other data in the card, no data is defined.

1735: CRC check

Factory default configuration: slave address 02 plus data length 0

Reset configuration: standard master-slave mode

So if you want the card reader to read the card, send the data: after the boot, send the command: 02 06 00 00 00 03 C9 F8

This protocol complies with the MODBUS-RTU standard and supports the 0-address broadcast monitoring function (can be used to configure the slave address and other information). However, the broadcast command does not respond to the slave.

CRC Check function:

unsigned int CRC16_MB(unsigned char *cBuffer, unsigned int iBufLen)

{

unsigned int i, j;

unsigned int wPolynom = 0xa001;

unsigned int wCrc = 0xffff;

for (i = 0; i < iBufLen; i++)

{

wCrc ^= cBuffer[i];

for (j = 0; j < 8; j++)

{

if (wCrc &0x0001)

{

wCrc = (wCrc >> 1) ^ wPolynom;

}

else

{

wCrc = wCrc >> 1;

}

}

}

return wCrc;

}

Device address command Register address content Functions
02 06 00 00

(The configuration is not saved after power off)

b15-

b3:No definition, (power-on default:00 02)

b0==1: Slave active transmission is usually used in one master- one slave communication
b0==0:Master-slave mode
b1==1:Antenna on
b1==0:Antenna off
b2==1:the slave active transmission mode, the card is sent the data continuously.
b2==0:In the slave active transmission mode, the card enters the field to send data once.
00 01

(saved after power off)

A0 02 After reading, add data 160 (0xA0) bit, device address is configured as 0x02
00 02 No data added, device address 0x02
03 00 00 00 01 Returns 0x00 address information, ie antenna status and transmission mode
00 01 00 04 Add data length and address and version information
00 05 00 09 System tuning status information, used to view the working status of the module, usually do not need to read
The above commands only support reading and writing in the above format.
02 03 00 0E 00 01

~

00 11

Read card number information and post-band data information
20th Dec 2023

Recent Posts