UHF Reader Modbus Protocol Development Manual v2.21
UHF Reader Modbus Protocol Development Manual v2.21
Dpment Man
Dpment Man
Table of Contents
1. Introduction.....................................................................................................................................................................2
1.1.Document specification.......................................................................................................................................2
1.2.Scope of application............................................................................................................................................2
1.3.Notice before use.................................................................................................................................................2
2. Error code table..............................................................................................................................................................3
3. Basic parameters...........................................................................................................................................................5
4. Relay control...................................................................................................................................................................9
5. Automatic / Trigger mode read label.........................................................................................................................11
5.1. Mode introduction.............................................................................................................................................11
5.2. Read a single label (automatic / trigger mode)............................................................................................13
5.3. Read multiple labels (automatic / trigger mode)..........................................................................................14
5.3.1 List label data (96bit)..............................................................................................................................14
5.3.2 List label data (336bit)...........................................................................................................................16
6. Command mode read label........................................................................................................................................17
6.1. Mode introduction.............................................................................................................................................17
6.2. Read a single label EPC(command mode)..................................................................................................17
7. Fast write label EPC....................................................................................................................................................19
7.1. Label mask........................................................................................................................................................19
7.2. Fast write label EPC.........................................................................................................................................21
8. Read label EPC/TID/USER/PASSWORD................................................................................................................22
8.1. Read label EPC/TID/USER/PASSWORD.....................................................................................................22
8.2.Read label result flag bit and Label data display..........................................................................................23
9. Write label EPC/USER/PASSWORD........................................................................................................................25
9.1. Write label EPC/USER/PASSWORD.............................................................................................................25
9.2.Write label result flag bit...................................................................................................................................27
10. Clear label data..........................................................................................................................................................28
11. PLC(Modbus TCP protocol)example application..................................................................................................29
11.1. Preparation stage...........................................................................................................................................29
11.2. Function description.......................................................................................................................................29
11.3. Introduction to PLC configuration (Botu V15.1 SP1 as an example)......................................................30
11.3.1. Create project...................................................................................................................................... 30
11.3.2. PLC address formation.......................................................................................................................30
11.3.3. Communication between PLC and reader.......................................................................................33
11.3.4. Data monitoring...................................................................................................................................35
11.3.5. PLC and host computer communication establishment................................................................36
12. Example application of PLC (Modbus RTU protocol)...........................................................................................38
12.1. Preparation stage...........................................................................................................................................38
12.2. Introduction to PLC configuration (Botu V15.1 SP1 as an example)......................................................38
12.2.1. Create a project...................................................................................................................................39
12.2.2. Communication between PLC and reader......................................................................................39
13. Attached: Modbus protocol.......................................................................................................................................43
13.1. Protocol frame format....................................................................................................................................43
13.2. (0x03)Read holding register PDU..............................................................................................................44
13.3. (0x06)Write a single register PDU.............................................................................................................44
13.4. (0x10)Write multiple register PDU.............................................................................................................45
14. Appendix.....................................................................................................................................................................46
1
UHF Reader Modbus Protocol development manual
Dpment Man
1. Introduction
1.1.Document specification
For the data in document, decimal numbers are directly represented by numbers, such as 1,247. The
hexadecimal number is represented by 0x, such as 0x12, 0x34. The 03 function code of Siemens PLC
starts from 40001, and the readers 5000 and 5001 correspond to 45001 and 45002 of Siemens PLC
respectively, and so on.
1.2.Scope of application
The document applies to our UHF readers that support Modbus protocol. The target readers of
document are: reader developers, API interface developers, system integration developers, reader
technical support personnel.
The default baud rate of our UHF reader RS232/RS485 interface is 115200, data bit 8, stop bit 1, no
check, slave station address 1; The default IP address of the network port is 192.168.0.128, and the
Modbus TCP connection port number is 502. If you need to modify the corresponding parameters,
please operate through the rfid-manager management software (the Modbus TCP connection port is
the default value of 502, so there is no need to modify it). When using Modbus protocol for
communication, please set it according to "Mode Introduction" in subsection 5.1 or 6.1 of this
document.
The "Equipment Address" column in the Modbus protocol format frame introduced in this document
takes effect when Modbus RTU(RS485 interface) protocol is used, and can be filled in arbitrarily when
Modbus RTU(RS232 interface) and Modbus TCP protocol are used.
2
UHF Reader Modbus Protocol development manual
Dpment Man
3
UHF Reader Modbus Protocol development manual
Dpment Man
0x25 When setting the baud rate, the baud rate is out of range
0x26 When setting the 485 address, the 485 address is out of range
0x27 When setting the relay status, the relay status is wrong
0x28 Wrong relay number
The relay is under automatic control, please turn off the automatic control
0x29
relay first
0x2A Filter mode error
0x2B TID length is out of range
0x2C USER area length is out of range
0x2D Need to switch the reader to command mode
0x2E Protocol error, only supports UDP or TCP reporting
0x2F RFID module returned an error
0x30 Heartbeat packet length error
0x31 The length field in the frame does not match the total length of the frame
The parameter length is inconsistent with the allowed length of the
0x32
command
0x33 Does not support the custom report of this route
0x34 The length of the reported parameter is out of range
The antenna is out of range, the device does not support so many
0x35
antennas
0x36 file size too big
0x37 Key error
0x38 File number verification error
0x39 File write error
0x3A File number sequence is wrong
0x3B IAP needs to be reinitialized
0x3C Other unknown errors
0x3D The number of downloaded data bytes does not match
0x3E Has entered IAP mode
0x3F File size check error
0x40 Flash erase failed
0x41 This register does not support this command code
0x42 The Bootloader does not support permanent exit from the upgrade mode
0x43 Jump to APP is not supported under APP
The frequency range of European frequency is 0-6, the frequency range
0x44 of US frequency is 0-52, and the frequency range of China is 0-10. The
minimum frequency cannot exceed the maximum frequency.
0x45 The region parameter range is 1-7
0x46 Does not support this trigger
0x47 Wiegand output is not supported
0x48 The switch value can only be 0 or 1
0x49 Failed to set power
0x4A Failed to set frequency band
0x4B Failed to set antenna
0x4C Buzzer parameter error
4
UHF Reader Modbus Protocol development manual
Dpment Man
0x4D Card reading mode error
0x4E Trigger level error
0x4F Report mode error
0x50 Relay parameter error
0x51 Wrong label recognition area
0x52 TID address or length is not an integer multiple of 2
0x53 USER address or length is not an integral multiple of 2
0x54 The length of the read label is not an integral multiple of 8
0x55 Read TID function is not turned on
0x56 Read USER function is not turned on
3. Basic parameters
(This function is applicable to firmware versions of SW:1.1.8 and above. Firmware versions of
SW:1.1.8 and below can only access the 8000-8031 address field, and the device firmware version
number can be queried in the rfid-manager management software.)
Function description: If you set the relay 1 to be closed, you need to set the addresses of 8000 and
8001 to 0x01, if you set the relay 2 to be closed, you need to set the addresses of 8002 and 8003 to
0x01.
Note: 8000-8035 is a holding register, and the data of the whole register will be refreshed when the
instruction is issued. When modifying a certain parameter, to ensure that other parameters will not be
modified, please set the "set valid bit" of the parameter that does not need to be modified to 0.
address function
Dpment
(words)Attribute
Man
Register
status
value
Relay 1
8000 0x03/0x06/0x10 1 RW 0x00 invalid
valid
0x01 valid
0-
Register
status
value
8001 Relay1 0x03/0x06/0x10 1 RW
0x00 open
0x01 close
8002 Relay2valid 0x03/0x06/0x10 1 RW
Reference relay1
8003 Relay2 0x03/0x06/0x10 1 RW
8004 Relay3valid 0x03/0x06/0x10 1 RW
Reference relay1
8005 Relay3 0x03/0x06/0x10 1 RW
8006 Relay4valid 0x03/0x06/0x10 1 RW
Reference relay1
8007 Relay4 0x03/0x06/0x10 1 RW
S Register
y Working status
value
s 8008 mode valid
0x03/0x06/0x10 1 RW
t 0x00 invalid
e 0x01 valid
m
Register
Mode
p value
a 0x00 Command mode
r Working 0x01 Automatic mode
a 8009 mode
0x03/0x06/0x10 1 RW
m 0x02 Trigger mode
e Access door
t 0x03
mode
e
r Register
a status
Report value
r 8010 0x03/0x06/0x10 1 RW
mode valid 0x00 invalid
e
a 0x01 valid
Register
Report mode
value
0x00 Report directly
Report Regular reporting
8011 0x03/0x06/0x10 1 RW 0x01
mode method one
Regular reporting
0x02
method 2
0x03 Passive report
Register
status
Buzzer value
8012 0x03/0x06/0x10 1 RW
switch valid 0x00 invalid
0x01 valid
8013 Buzzer 0x03/0x06/0x10 1 RW Register
switch Status
value
0x00 close
6
UHF Reader Modbus Protocol development manual
Dpment Man
0x01 Open
Register
status
Output value
8014 0x03/0x06/0x10 1 RW
power valid 0x00 invalid
0x01 valid
Output The output power range is:
8015 0x03/0x06/0x10 1 RW
power 0~33dbm
Register
Filter status
value
8016 interval 0x03/0x06/0x10 1 RW
0x00 invalid
valid
0x01 valid
Filter label filtering time interval
8017 0x03/0x06/0x10 1 RW
interval setting, unit: second
Register
RS485 status
value
8018 Baud rate 0x03/0x06/0x10 1 RW
0x00 invalid
is valid
0x01 valid
Register
Baud rate
value
0x00 9600
RS485 0x01 19200
8019 0x03/0x06/0x10 1 RW
Baud rate
0x02 38400
0x03 57600
0x04 115200
Register
RS485 status
value
8020 Address is 0x03/0x06/0x10 1 RW
0x00 invalid
valid
0x01 valid
RS485 Address range: 0~247, 0 is the
8021 0x03/0x06/0x10 1 RW
Address broadcast address
Register
RS232 status
value
8022 Baud rate 0x03/0x06/0x10 1 RW
0x00 invalid
is valid
0x01 valid
Register
Baud rate
value
0x00 9600
RS232 0x01 19200
8023 0x03/0x06/0x10 1 RW
Baud rate
0x02 38400
0x03 57600
0x04 115200
8024 Whether to 0x03/0x06/0x10 1 R/W Register
save the state
value
parameters
Don't save when
0x00
power off
0x01 Power-down save
0-
7
UHF Reader Modbus Protocol development manual
register status
Set network value
8028 0x03/0x06/0x10 1 RW
parameters 0x00 not set
0x01 set
4 bytes, high byte in front, low
8029 IP address 0x03/0x06/0x10 2 RW
byte in the back.
Subnet 4 bytes, high byte in front, low
8031 0x03/0x06/0x10 2 RW
mask byte in the back.
Default 4 bytes, high byte in front, low
8033 0x03/0x06/0x10 2 RW
gateway byte in the back.
8035 reserve 0x03/0x06/0x10 1 RW ------
4. Relay control
Note: If you need to use relay control in the project configuration but do not need to use other basic
parameters, you can use the registers in this area to control the relay. The relay-related registers only
8
UHF Reader Modbus Protocol development manual
Dpment Man
support fixed address and length access. For example, the address accessed by relay 1 can only be
7000. The length can only be 1.
Relay control register
Reader Function Length(word R/W Power-down
Address(word) instruction
function code ) Attributes save
Relay 1 0x03/0x06 7000 1 RW ×
Relay 2 0x03/0x06 7001 1 RW ×
Relay 3 0x03/0x06 7002 1 RW ×
Relay 4 0x03/0x06 7003 1 RW ×
9
UHF Reader Modbus Protocol development manual
Dpment Man
Modbus TCP message frame:
10
UHF Reader Modbus Protocol development manual
Dpment Man
Response message format:
Explain Header (N Equipment Function code Number of Register value
bytes) address (1 byte) (1 byte) bytes (1 byte) (N bytes)
Messag ...... 01H 03H 02H ......
e
11
UHF Reader Modbus Protocol development manual
Dpment Man
Example: Set relay 1 status.
Send message format:
Explain Header Equipment Function code Address Register value
(N bytes) address (1 byte) (1 byte) (2 bytes) (N bytes)
Messag ...... 01H 06H 1BH 58H ......
e
12
UHF Reader Modbus Protocol development manual
Dpment Man
Response message format:
Explain Header Equipment Function code Address Register value
(N bytes) address (1 byte) (1 byte) (2 bytes) (N bytes)
Messag ...... 01H 06H 1BH 58H ......
e
1. Users can configure the reader's working mode as "automatic card reading mode" and the reporting
condition as "passive reporting mode" through rfid-manager management software. When the reader
works in "automatic card reading mode" and "passive reporting mode", it is only necessary to set the
polling antenna (if there is only a single antenna, it is not necessary to set it) and then take out the
label continuously.
13
UHF Reader Modbus Protocol development manual
Dpment Man
2. * Note: When using Modbus protocol to automatically read the label, the reader must be switched to
"passive reporting mode", otherwise the label will not be reported.
The trigger mode also belongs to the automatic mode, which requires the reader to access the external
trigger signal.
14
UHF Reader Modbus Protocol development manual
Dpment Man
Note: After setting as shown above, do not use "Read / Write Tag" to test the listed labels, otherwise
the working mode will be switched to "Command Mode".
15
UHF Reader Modbus Protocol development manual
Dpment Man
Function: The reader is in the automatic/ trigger reading mode, and returns the data of EPC, TID and
USER area of one label from the FIFO of the reader. The default reporting field of the reader is EPC
area. If you want to read TID and USER area, you need to check the corresponding areas in the
"Reporting Field" of rfid-manager. (This register area will automatically hold the read label data, and
whether the label is read or not can be judged by the label status)
16
UHF Reader Modbus Protocol development manual
Dpment Man
Function description: the reader is in the automatic/ trigger reading mode, and the data of tag EPC, TID
and USER area are returned from the FIFO of the reader. The default field reported by the reader is
EPC area. If you need to read TID area and USER area, you need to check the corresponding area
through the "Report Field" of rfid-manager.
Register address:5000(fixed)
One label takes up 22 register addresses, and at most 4 labels can be taken out at a time, that is, 88
register addresses. (If the reader reads only one label at a time, the label data will be displayed in the
first label, and the label data will not be automatically saved. If it is necessary to save the label data,
please do data transfer processing. )
Note: In automatic mode, the following labels will be cached, and the cache will be cleared after all the
labels are taken out.
The mapping relationship between the register label and the register label: (See Appendix: Figure 14-1
for detailed address description)
17
UHF Reader Modbus Protocol development manual
Dpment Man
Register address Register definition Register description
The first label
5000 High byte:Ant Ant indicates the antenna number that reads
Low byte:Fin the label.
18
UHF Reader Modbus Protocol development manual
Dpment Man
Modbus RTU message frame:
Register address:4900(fixed)
One label takes up 25 register addresses, and at most 4 labels can be taken out at a time, that is, 100
register addresses. (If the reader reads only one label at a time, the label data will be displayed in the
first label, and the label data will not be automatically saved. If it is necessary to save the label data,
please do data transfer processing. )
Note: In automatic mode, the following labels will be cached, and the cache will be cleared after all the
labels are taken out.
(This function is applicable to SW:1.1.8 and above firmware versions, and the firmware version number
of the equipment can be queried in the rfid-manager management software.)
19
UHF Reader Modbus Protocol development manual
Dpment Man
Register address Register definition Register description
The first label
4900 High byte:Ant Ant indicates the antenna number that reads
Low byte:Fin the label.
20
UHF Reader Modbus Protocol development manual
Users can configure the reader's working mode to "command card reading mode" through rfid-
manager management software. When the reader works in "command card reading mode", it can send
a specified command packet, and then take out the label EPC.
Note: If the reader has only one antenna, antenna 1 is used to read the label by default.
Function: The reader is in the command card reading mode, and returns the label EPC area data from
21
UHF Reader Modbus Protocol development manual
Dpment Man
the FIFO of the reader. This mode cannot return the label TID area and the USER area, and only one
label can be listed when a card reading command is issued. This register area will automatically store
the read label data, and whether the label is read or not can be judged by the label status.
5200:
5200 0x03 0-34(change) Antenna 2 Read 0x00 has no label.
Label EPC 0x01 has a label.
5201:EPC useful length,Unit (Bytes)
5202-5233:EPC number
5300:
5300 0x03 0-34(change) Antenna 3 Read 0x00 has no label.
Label EPC 0x01 has a label.
5301:EPC useful length,Unit (Bytes)
5302-5333:EPC number
5400:
5400 0x03 0-34(change) Antenna 4 Read 0x00 has no label.
Label EPC 0x01 has a label.
5401:EPC useful length,Unit (Bytes)
5402-5433:EPC number
22
UHF Reader Modbus Protocol development manual
Dpment Man
23
UHF Reader Modbus Protocol development manual
Dpment Man
7. Fast write label EPC
Note: This function can be used to quickly modify the EPC number of the label in command mode and
automatic mode.
Function description: This register can only be accessed from address 7100 and supports 03H and
10H function codes. The EPC mask of the label can be set through this register. When the length of the
mask is not 0, the reader will match before writing the label. Target label EPC; when the mask length is
set to 0, it means that the mask is not used. The mask is not saved when power off. The length of the
access address can be adjusted according to the actual length of the EPC.
24
UHF Reader Modbus Protocol development manual
Example: Set the label mask to lock the EPC length of the target label to 6 words.
Send message format:
Explain Equipment Function Address Write Data Write data CRC
address (1 code (1 (2 bytes) length: length: (N bytes) (2 bytes)
byte) byte) word (2 Byte (1
bytes) byte)
Messag 01H 10H 1BH BCH 00H 07H 0EH ...... Checksum
e
25
UHF Reader Modbus Protocol development manual
Dpment Man
Example: Set the label mask to lock the EPC length of the target label to 6 words.
Send message format:
Explain Header (N Equipment Function Address Write Data Write data
bytes) address (1 code (1 (2 bytes) length: length: (N bytes)
byte) byte) word (2 Byte (1
bytes) byte)
Messag ...... 01H 10H 1BH BCH 00H 07H 0EH ......
e
Note: If the reader has only one antenna, antenna 1 is used to write labels by default.
Function description: When the user writes the corresponding address, the EPC number of the label
will be rewritten. If the label mask is not set, a label will be rewritten randomly. If a label mask is set,
only labels that meet the mask conditions will be written. The length of the access address can be
adjusted according to the actual length of the EPC, with a maximum write length of 32 words.
Example: 1 write label EPC for antenna, the length of EPC area is 6 words, and write data.
Send message format:
Explain Equipment Function Address Write Data Write data CRC
address (1 code (1 (2 bytes) length: length: (N bytes) (2 bytes)
byte) byte) word Byte (1
(2 bytes) byte)
Messag 01H 10H 17H 70H 00H 06H 0CH ...... Checksum
e
26
UHF Reader Modbus Protocol development manual
Dpment Man
Modbus TCP message frame:
Example: 1 write label EPC for antenna, the length of EPC area is 6 words, and write data.
Send message format:
Explain Header (N Equipment Function Address Write Data Write data
bytes) address (1 code (1 (2 bytes) length: length: (N bytes)
byte) byte) word Byte (1
(2 bytes) byte)
Messag ...... 01H 10H 17H 70H 00H 06H 0CH ......
e
Register address:4138-4143(fixed)
Read EPC area: read the data in the specified area, and the starting address of reading starts from the
4th byte.
Read TID area: read the data in the specified area, and the starting address of reading starts from byte
0.
Read USER area: read the data in the specified area, and the starting address of reading starts from
byte 0.
27
UHF Reader Modbus Protocol development manual
Dpment Man
Register address Register definition Register description
4138 Write antenna 0x01-- write with antenna 1
0x02-- write with antenna 2
0x03-- write with antenna 3
0x04-- write with antenna 4
4139-4140 Label access password If the label is locked, an access password is
required to successfully write, 4 bytes.
4141 Read area 0x00-- password area
0x01-- EPC area
0x02-- TID area
0x03-- USER area
4142 Read address Must be a multiple of 2.Unit:bytes
4143 Read length Must be a multiple of 2.Unit:bytes
28
UHF Reader Modbus Protocol development manual
Dpment Man
This register area can be used to view the read result flag of "Read label EPC/TID/USER/PASSWOR"
and the read label data.
29
UHF Reader Modbus Protocol development manual
Function: The reader is in the "automatic card reading mode" or "command card reading mode", and
the data in EPC area and USER area of the label can be modified by issuing commands in this register
area.
30
UHF Reader Modbus Protocol development manual
Dpment Man
Write EPC area: only modify the data of the specified area, and the actual length of EPC will not be
changed. The write start address starts from the 4th byte.
Fast write EPC area : modifying the data of the whole EPC area will change the actual length of the
target label, The writing start address starts from the 0th byte.
USER area: only the data of the specified area will be modified, and the actual length of the USER
area will not be changed. The writing start address starts from the 0th byte.
Example: Write the label EPC, and write 3 words of data into the label EPC area (that is, write the
4100-4108 register).
31
UHF Reader Modbus Protocol development manual
Dpment Man
Example: Write the label EPC, and write 3 words of data into the label EPC area (that is, write the
4100-4108 register).
Send message format:
Explain Header (N Equipment Function Address Write Data Write data
bytes) address (1 code (1 (2 bytes) length: length: (N bytes)
byte) byte) word Byte
(2 bytes) (1 byte)
Messag ...... 01H 10H 10H 04H 00H 09H 12H ......
e
32
UHF Reader Modbus Protocol development manual
Description: This command can clear the label data read in automatic mode and command mode.And
33
UHF Reader Modbus Protocol development manual
34
UHF Reader Modbus Protocol development manual
The SIMATIC S7-1200 series PLC communicates with the reader through Modbus TCP protocol. If the
PLC model is different, please refer to the same parameter configuration.
The CPU module of the SIMATIC S7-1200 series PLC integrates the Profinet communication network
port, which is an open, standard, real-time Ethernet industrial standard, and supports multiple protocols
such as S7 and Modbus TCP for communication. The reader communicates with the SIMATIC S7-
1200 series PLC through the Modbus TCP protocol, which can transmit data and receive instructions
quickly and accurately.
The PLC reads/writes data to the reader, and the host computer reads/writes data to the reader
through the PLC.
1. Open the software -> create a project -> device and network management -> add a new device
(PLC) -> click on the device view -> set the subnet and IP address (if need to use the router, check the
use of router).
35
UHF Reader Modbus Protocol development manual
Dpment Man
1. Check the hardware identifier of the CPU, device configuration -> select interface -> properties ->
system constants.
2.Create the DB data block "ModbusTCP_CONNECT" in the PLC, create the "TCON_IP_v4"
background data area, and fill in the IP address, slave address, and port number of the corresponding
reader.
36
UHF Reader Modbus Protocol development manual
Dpment Man
3. Create the DB data block "Read_Config", uncheck "Optimized block access" in the properties, add
the data storage area "static", create the address area corresponding to the register table of the reader
in "static", use To collect the data of the reader and store it. For different types of data, the PLC reads
the data in the form of bytes or words. For holding registers, Siemens supports address ranges from
40001 to 49999 and 40001 to 465535.
37
UHF Reader Modbus Protocol development manual
Dpment Man
4.For the special register area set in the reader (only words or bytes of the corresponding length can
be read/written), the specific address area is also divided in the PLC.
5.Also create the DB data block "Write_Config", uncheck "Optimized block access" in the properties,
and add the data storage area "static" to write data to the reader.
38
UHF Reader Modbus Protocol development manual
Dpment Man
The PLC serves as the client, the reader as the server, and Modbus TCP communication is established
to realize the data transmission from the reader to the PLC, or the PLC to write data to the reader.
1.Instruction introduction
The "MB_CLIENT" instruction acts as a Modbus TCP client to communicate through a network
port connection. Through the "MB_CLIENT" instruction, you can establish a connection between the
client and the server, send Modbus requests, receive responses, and control the connection terminal
of the Modbus TCP client.
* When using a client connection, remember the following rules:
·Each "MB_CLIENT" connection must use a unique instance data block.
·For each "MB_CLIENT" connection, a unique server IP address must be specified.
·Each "MB_CLIENT" connection requires a unique connection ID.
·Each instance data block of this instruction must use its corresponding connection ID. The
connection ID and the instance data block are combined into a pair, and the combination pair must
be unique for each connection.
·Depending on the server configuration, the unique number of the IP port may or may not be
required.
2.Create FC1 block, select "MB_CLIENT" function block in Instruction Communication -> Others ->
Modbus TCP, drag it into the middle of the program segment to complete the configuration as shown in
the figure below
Main parameter configuration:
·DISCONNECT: 0=establish connection, 1=terminate connection;
39
UHF Reader Modbus Protocol development manual
(1)For example, the following figure configures the registers used to read the reader 5000 to 5087 in
the FC1 block, and stores them in the PP1 data area of the PLC's Read_Config.
40
UHF Reader Modbus Protocol development manual
Dpment Man
3.The other read/write addresses are constructed in FC1 in the same way. If the project needs to
access more register areas of the reader, it is recommended to increase the polling function to access
the "MB_CLIENT" function block. After the construction is completed, in the Main ( OB1) call the "FC1"
block.
1.After the compilation is correct, download the program to the PLC, connect the reader to
the PLC, and monitor the data of the reader in real time in the corresponding DB data
area.
41
UHF Reader Modbus Protocol development manual
Dpment Man
2.Stay online and check the PLC to read the data from the reader.
The PLC is used as the server, and the upper computer is used as the client , to establish Modbus
TCP communication to realize the transmission of data collected by the PLC to the upper computer for
display, and the upper computer to issue control commands to the PLC.
42
UHF Reader Modbus Protocol development manual
Dpment Man
1.Create the "ModbusTCP_Server" DB block, call the "TCON_IP_v4" background data area, fill in the
parameters of the PLC as the server; create a storage area for transmitting data to the host computer.
2.In Instruction -> Communication -> Others -> Modbus TCP, select the MB_SERVER function block
and drag it to the main program segment to configure the corresponding parameters.
43
UHF Reader Modbus Protocol development manual
Dpment Man
12. Example application of PLC (Modbus RTU
protocol)
Note: Examples of data block creation and communication between PLC and host computer have been
introduced in Section 6, and will not be detailed here.
Take Siemens' 1200 series CPU and CM1241 communication module with model 1214 as an example.
If the PLC model is different, please refer to the same parameter configuration. The Modbus RTU in
the Botu software TIA library contains three instructions (Modbus_Comm_Load, Modbus_Master,
Modbus_Slave). The CM1241 Modbus RTU master station uses two communication blocks,
"Modbus_Comm_Load" and "Modbus_Master". Among them, the "Modbus_Comm_Load" block only
needs to be called once to initialize the Modbus communication port, which is usually executed during
the first scan. The "Modbus_Master" block is used for the master to read and write the register data of
the slave modules.
44
UHF Reader Modbus Protocol development manual
Dpment Man
Note: The input parameter "MB_DB" when calling "Modbus_Comm_Load" is the instance data block
when calling "Modbus_Master" to establish.
1. Open the software -> create a project -> device and network management -> add a new device
(PLC) -> click on the device view -> open the hardware catalog -> communication module -> point to
point -> add the corresponding serial port module.
45
UHF Reader Modbus Protocol development manual
Dpment Man
1.View the hardware identifier, select the corresponding serial port to be added, and click Properties ->
System Constant. The hardware identifier of the RS485 communication module is 269. (The method of
viewing the hardware identifier of the RS232 module is the same).
3.Modbus_Comm_Load instruction instance data block configuration. The static variable "MODE" in
the Modbus_Comm_Load instruction instance data block is used to describe the working mode of the
PTP module. The valid working modes include:
46
UHF Reader Modbus Protocol development manual
Dpment Man
·0 = Full duplex (RS232)
·1 = Full duplex (RS422) four-wire mode (point-to-point)
·2 = Full duplex (RS422) four-wire mode (multipoint master station)
·3 = Full duplex (RS 422) four-wire mode (multipoint slave)
·4 = Half-duplex (RS485) two-wire mode
The default data of the static variable "MODE" is 0 (RS232 full-duplex mode), and the value
needs to be modified according to the actual configuration. Taking RS485 communication as an
example, the module working in RS485 half-duplex mode needs to modify the value to 4. (The
parameter configuration of RS232 and RS485, except for this difference, the other configuration
methods of RS232 and RS485 are the same.)
Click system block -> program resources -> Modbus_Comm_Load background data -> modify
the value of MODE.
4. PLC as the master station, the reader as the slave station, calling the Modbus_Master block to
realize the function
·MB_ADDR:Slave address;
·DATA_ADDR:Register address, the address of 03 read function code is 40001-49999 and 400001-
465535;
·DATA_LEN:Register length;
·DATA_PIR:Data storage area, used to set the storage length of the read data and store the read register
data.
47
UHF Reader Modbus Protocol development manual
Dpment Man
(1)For example, read the registers of the reader 5000 to 5087 and store them in the PP1 data area of
PLC's Read_Config.
5.The other read/write addresses are constructed in FC1 in the same way. If the project needs to
access more register areas of the reader, it is recommended to increase the polling function to access
the "MB_Master" function block. After the construction is completed, in Main (OB1 ) Call the "FC1"
block.
48
UHF Reader Modbus Protocol development manual
Dpment Man
49
UHF Reader Modbus Protocol development manual
Dpment Man
13. Attached: Modbus protocol
Table 13-1 and Table 13-2 are the frame formats of Modbus protocol applied to RS485/RS232 and
TCP protocol respectively. Their simple protocol data unit (PDU) is the same, which includes function
codes and data. The application data unit (ADU) varies according to the communication layer carried.
When the Modbus protocol is mounted on RS485/RS232, it is necessary to add the device address
and CRC check to form the ADU. When the Modbus protocol is mounted on the TCP protocol, the
MBAP header needs to be added to form the ADU, see Table 13-3.
50
UHF Reader Modbus Protocol development manual
Dpment Man
13.2. (0x03)Read holding register PDU
0x03 function code is used to read one or more registers. The start address of the register to be read
and the number of registers to be read need to be specified in the request PDU. The response
message contains the number of bytes returned and the register value.
Request:
Function code 1 byte 0x03
Start address 2 bytes 0x0000 to 0xFFFF
Number of registers 2 bytes 1 to 125(0x7D)
Response:
Function code 1 byte 0x03
Number of bytes 1 byte 2*N
Register value 2*N bytes Value
Error:
Error code 1 byte 0x83
Exception code 1 byte Error code comparison table
0x06 function code is used to write a single holding register. The request PDU needs to specify the
address of the register to be written and the value of the register. The response message contains the
written register address and register value.
Request
Function code 1 byte 0x06
Register address 2 byte 0x0000 to 0xFFFF
Register value 2 bytes Value
Response:
Function code 1 byte 0x06
Register address 1 byte 2*N
Register value 2*N bytes Value
Error :
Error code 1 byte 0x86
Exception code 1 byte Error code comparison table
51
UHF Reader Modbus Protocol development manual
Dpment Man
0x10 function code is used to write consecutive register blocks. The request PDU needs to specify the
starting address of the register block to be written, the number of registers to be written, the number of
bytes to be written, and the register to be written. The response message contains the start address of
the register to be written and the number of registers.
Request:
Function code 1 byte 0x10
Start address 2 bytes 0x0000 to 0xFFFF
Number of registers 2 bytes 0x0001 to 0x0078
Number of bytes 1 byte 2*N
Register value 2*N bytes Value
Response:
Function code 1 byte 0x10
Start address 2 bytes 0x0000 to 0xFFFF
Number of registers 2 bytes 1 to 123(0x7B)
Error:
Error code 1 byte 0x90
Exception code 1 byte Error code comparison table
52
UHF Reader Modbus Protocol development manual
Dpment Man
14. Appendix
53