New Features of Modbus TCP V6.0 Simplify Polling!

【Introduction】MODBUS TCP instruction V6.0 adds Modbus client function code 23, which allows reading and writing one or more holding registers from the server in a single request operation, eliminating the programming workload of polling and improving work efficiency.
New Features of Modbus TCP V6.0 Simplify Polling!Join the exclusive group for electrical automation technology exchange
New Features of Modbus TCP V6.0 Simplify Polling!Join the exclusive group for electrical automation procurement and sales
New Features of Modbus TCP V6.0 Simplify Polling!Join the exclusive group for electrical automation project docking
New Features of Modbus TCP V6.0 Simplify Polling!Join the exclusive group for electrical automation personnel recruitment

Overview of Modbus Client Function Code 23

1. New Features of Modbus TCP V6.0
MODBUS TCP instruction V6.0 adds Modbus client function code 23, which allows reading and writing one or more holding registers from the server in a single request operation, eliminating the programming workload of polling and improving work efficiency. As shown in the figure below:

New Features of Modbus TCP V6.0 Simplify Polling!

Figure 1. MODBUS_TCP Instruction
2. Requirements for SIMATIC S7-1200
(1) TIA Portal V17 and above
(2) CPU firmware V4.2 and above

Testing Environment and Content for Modbus Client Function Code 23

In this application example, the Modbus TCP V6.0 function 23 programming is implemented using the following products to read and write multiple holding registers from the server.
(1) Software:
(1) TIA Professional V17
(2) Hardware:
(1) CPU1217C DC/DC/DC V4.5
(2) CPU1215FC DC/DC/DC V4.4

Configuration and Programming of Modbus Client Function Code

(1) Client Instruction Invocation and Parameter Allocation

(1) Open TIA Portal V17 software, create a new project, add CPU1217C DC/DC/DC V4.5 to the project, create a subnet for the Ethernet interface, and set the IP address to “192.168.0.17”, as shown in Figure 2.

New Features of Modbus TCP V6.0 Simplify Polling!

Figure 2. Assigning Subnet and IP
(2) Invoke the client instruction and create a global DB for the instruction pin parameters, as shown in Figure 3.
When using Modbus function code 23, the value of the MB_MODE parameter must be 123, and the parameters MB_DATA_ADDR, MB_DATA_LEN, and MB_DATA_PTR must not be used, and these parameters must have default values; otherwise, an error will return STATUS value 16#818D.

New Features of Modbus TCP V6.0 Simplify Polling!

Figure 3. Client Instruction and DB Block Creation
When using Modbus function code 23, six new parameters will be used, as described in Table 1 below. Each of these parameters starts with “RD_” or “WR_” to indicate whether it belongs to a read or write task. These parameters are hidden by default; click the black triangle below the instruction to expand it. When using Modbus function code 23, all six parameters must be used. If other Modbus function codes are used, the values of these six parameters must be 0 or empty; otherwise, an error will return STATUS value 16#818D. Table 1 lists the pin parameters of Modbus function code 23.
Parameter Declaration Data Type Description

RD_MB_DATA_ADDR

Input

UInt

Starting address of the holding registers to be read from the server. Allowed values: 0 to 65535

RD_MB_DATA_LEN

Input

UInt

Number of holding registers to be read from the server. Allowed values: 1 to 125

WR_MB_DATA_ADDR

Input

UInt

Starting address of the holding registers to be written to the server. Allowed values: 0 to 65535

WR_MB_DATA_LEN

Input

UInt

Number of holding registers to be written to the server. Allowed values: 1 to 121

RD_MB_DATA_PTR

InOut

Variant

Pointer to the buffer of register data to be read from the Modbus server. Allowed data types: same as MB_DATA_PTR.

WR_MB_DATA_PTR

InOut

Variant

Pointer to the buffer of register data to be written to the Modbus server. Allowed data types: same as MB_DATA_PTR.

(2) Server Instruction Invocation and Parameter Allocation

(1) Add CPU1215FC DC/DC/DC V4.4 to the project, create a subnet for the Ethernet interface, and set the IP address to “192.168.0.15”.
(2) Invoke the server instruction and create a global DB for the instruction pin parameters, as shown in Figure 4. The “MB_SERVER” instruction supports using Modbus function code 23 to write and read holding registers in a single job, requiring the use of V4 and above versions of Modbus TCP blocks.

New Features of Modbus TCP V6.0 Simplify Polling!

Figure 4. Server Instruction and DB Block Creation

(3) Test Results

Download the two PLC programs separately, setting the starting address of the holding registers to be read from the server to “0”, length to “5”; and the starting address of the holding registers to be written to the server to “5”, length to “5”. Trigger a request, which first writes the register data and then reads the register data. The test results are shown in Figure 5.

New Features of Modbus TCP V6.0 Simplify Polling!

Figure 5. Test Results

What Everyone is Watching

New Features of Modbus TCP V6.0 Simplify Polling![Video] How German Engineers Make PLC Cabinets?

New Features of Modbus TCP V6.0 Simplify Polling![Video] How German WITRON Electrical Cabinets are Produced?

New Features of Modbus TCP V6.0 Simplify Polling![Video] What is the Office Environment of German Engineers Like?

New Features of Modbus TCP V6.0 Simplify Polling![Video] Why is PROFINET Better than PROFIBUS?

Leave a Comment