General Form of Message Frames
Message Frames in Serial Communication
A message frame is built up as follows in serial communication:
|
Address |
Function |
Data |
CRC Check |
|---|---|---|---|
|
8 bits |
8 bits |
8 bits |
16 bits |
-
Address
Indicates the address of the receiver
-
Function
Indicates the purpose of the data transfer. The functions are standard functions in the Modbus protocol.
-
Data
Contains the actual information that is to be transferred. The data is always transferred as a multiple of 16-bit registers.
The Data field is subdivided into the following:
-
Register
-
Number of registers to be transferred
-
Division of the information into read information or information to be stored
-
-
CRC Check
Specifies the check sum. The sender calculates the check sum from all bytes. The receiver calculates the value again and compares both results. The check is used to detect any transfer errors.
-
Sending Message Frames
There needs to be a silent interval of at least 3.5 characters between two message frames to separate the message frames from each other. In other words, the time between two sent message frames should be at least as long as is required for sending 3.5 characters. You define this interval in the Silent Interval field in the Serial Communication area. (See also: Settings for Serial Communication.)
The data stream should not be interrupted within a message frame. The individual characters must not be more than 1.5 characters apart, that is, the maximum time distance between two sent characters of a message frame must not last longer than is required for sending 1.5 characters. If there is a longer interval within a message frame, the message frame is regarded as incomplete and an error message is issued. You can define this maximum permitted interval in the Read Timeout field in the Serial Communication area.
Message Frames in TCP Data Transfer
A message frame is built up as follows when TCP is used:
|
MBAP Header |
Function code |
Data |
|---|---|---|
|
7 bytes |
1 byte |
n bytes |
-
MBAP Header
The MBAP Header (Modbus Application Protocol Header) contains the header data of the message frame, such as transaction ID, protocol ID, number of subsequent data bytes, unit ID.
-
Function code
Specifies the function code of the standard Modbus protocol, that is, the receiver is informed which action is to be performed.
-
Data
Contains the information that is to be transferred.