This chapter mainly introduces the MODBUS TCP communication protocol and the content of free format communication protocols.
1. Overview of MODBUS TCP Communication
MODBUS TCP combines the Ethernet physical network and the network standard TCP/IP with MODBUS as the application protocol standard for data representation.
MODBUS TCP communication messages are encapsulated in Ethernet TCP/IP packets, and the maximum length of a data frame defined by the MODBUS protocol is 256 bytes.
In the MODBUS TCP/IP communication system, there are two types of devices: MODBUS TCP/IP clients and server devices.
MODBUS Client:
The client (TCP Client) actively initiates a connection request to the server (TCP Server). Once the connection is successfully established, only the client is allowed to actively initiate communication requests.
When the Ethernet device acts as a MODBUS TCP client, it establishes a TCP connection using the S_OPEN command and initiates a MODBUS request using the M_TCP command.
MODBUS Server:
The server actively listens on port 502, waiting for client connection requests. Once the connection is successfully established, it responds to data communication requests that comply with the Modbus TCP protocol specification.
The Ethernet device defaults to enabling this service upon power-up, with a maximum response limit of 4 TCP connections.
1. MODBUS Communication Function Codes
Taking the Xinjie PLC as an example: The Ethernet device supports the following Modbus communication function codes:
2. Free Format Communication Protocol
Free communication based on Ethernet is divided into two major categories: TCP and UDP. When the Ethernet device uses TCP for communication, it can act as a TCP client (TCP Client) or as a TCP server (TCP Server).
1. As a TCP client, it actively establishes a TCP connection with the TCP server and binds the socket ID.
2. As a TCP server, it waits for the TCP client to establish a TCP connection and binds the socket ID.
3. Using UDP, it listens on a specified local port and binds the socket ID.
Based on the above three forms, free communication over Ethernet can be achieved. Free format communication transmits data in the form of data blocks, limited by PLC caching, with a maximum single send and receive data volume of 1000 bytes.
Key parameters of free format communication:
Data buffering method: 8-bit, 16-bit
1. When selecting the 8-bit buffering format for communication, the high byte of the register is invalid during communication, and the PLC only uses the low byte of the register for sending and receiving data.
2. When selecting the 16-bit buffering format for communication, the PLC stores the received data first in the low byte and then in the high byte; when sending data, it sends the low byte first and then the high byte.
3. When the length of the received data packet exceeds the set receive length, the data is stored in a 16-bit storage format.

END