Application note
Integrated Modbus support
AN00198
ABB Motion control products
3
new.abb.com/motion
A typical message frame is shown below.
START
ADDRESS
FUNCTION
DATA
CRC
CHECK
END
8 bits
8 bits
n * 8 bits
16 bits
{delay}
[STX]
[ETX]
[NUL][SOH][NUL][SOH] Õ ù
{delay}
ADDRESS
8 bits
[STX]
The
address
field of a RTU message frame contains one character (8 bits). Valid Server device
addresses are in the range of 0
– 255 decimal.
When the Server sends its response, it places its own address in the address field of the
response to let the Client know which Server is responding. Address 0 is used for the broadcast
address, which all Server devices recognize.
When configuring a Mint controller for use as a Modbus Server it is therefore advisable to avoid
setting this controller up as Mint Node 0 (note that the Client can only use the broadcast
address for write transactions).
FUNCTION
8 bits
[ETX]
The
function
code field of a RTU message frame contains one character (8 bits). Valid codes
(from the Client) are in the range of 1
– 127 decimal.
When a message is sent from a Client to a Server device the function code field tells the Server
what kind of action to perform. Examples are to read the ON/OFF states of a group of discrete
inputs; to read the data contents of a group of registers; to read the diagnostic status of the
Server or to write to designated registers.
When the Server responds to the Client, it uses the function code field to indicate either a
normal (error
–free) response or that some kind of error occurred (called an exception
response). For a normal response, the Server simply echoes the original function code. For an
exception response, the Server returns a code that is equivalent to the original function code
with its most
–significant bit set to a logic 1.
DATA
n * 8 bits
[NUL][SOH][NUL][SOH]
The
data
field is constructed using sets of two hexadecimal digits, in the range of 00 to FF
hexadecimal that are then packed into a single ASCII character. The data field of messages
sent from a Client to Server devices contains additional information which the Server must use
to take the action defined by the function code. This can include items like discrete and register
addresses, the quantity of items to be handled, and the count of actual data bytes in the field.
For example, if the Client requests a Server to read a group of holding registers (function code
03), the data field specifies the starting register and how many registers are to be read. If the
Client writes to a group of registers in the Server (function code 16 decimal), the data field
specifies the starting register, how many registers to write, the count of data bytes to follow in
the data field, and the data to be written into the registers.
If no error occurs, the data field of a response from a Server to a Client contains the data
requested. If an error occurs, the field contains an exception code that the Client application can
use to determine the next action to be taken.
CRC
CHECK
16 bits
Õ ù
When RTU mode is used for character framing, the error checking field contains two ASCII
characters. The error check characters are the result of a
Cyclic Redundancy Check
(CRC)
calculation that is performed on the message contents.
The CRC characters are appended to the message as the last field.