Modbus TCP Server/Client

Introduction

Unlike Modbus serial link, Modbus TCP/IP is not based on a hierarchical structure, but on a client/server model.

The TM4ES4 module implements both client and server services so that it can initiate communications to other controllers and I/O devices, and to respond to requests from other controllers, SCADA, HMIs and other devices. By default, Modbus Server functionality is not active.

Without any configuration, the TM4ES4 module supports Modbus server.

The Modbus Server/Client is included in the firmware, and does not require any programming action from the user. Due to this feature, it is accessible in RUNNING, STOPPED and EMPTY states.

Modbus TCP Client

The Modbus TCP client supports the following function blocks from the PLCCommunication library without any configuration:

oADDM

oREAD_VAR

oSEND_RECV_MSG

oSINGLE_WRITE

oWRITE_READ_VAR

oWRITE_VAR

For further information, refer to the Function Block Descriptions.

Modbus TCP Server

The Modbus server supports the following Modbus requests:

Function Code

Dec (Hex)

Sub-function

Dec (Hex)

Function

1 (1h)

 

Read digital outputs (%Q)

2 (2h)

 

Read digital inputs (%I)

3 (3h)

 

Read holding register (%MW)

6 (6h)

 

Write single register (%MW)

8 (8h)

 

Diagnostic

15 (Fh)

 

Write multiple digital outputs (%Q)

16 (10h)

 

Write multiple registers (%MW)

23 (17h)

 

Read/write multiple registers (%MW)

43 (2Bh)

14 (Eh)

Read device identification

Diagnostic Request

The table contains the Data Selection Code list:

Data Selection Code

Description

0x00

Reserved

0x01

Basic Network Diagnostics

0x02

Ethernet Port Diagnostic

0x03

Modbus TCP/Port 502 Diagnostics

0x04

Modbus TCP/Port 502 Connection Table

0x05 - 0x7E

Reserved for other public codes

0x7F

Data Structure Offsets