Introduction
Installation and
Safety Guidelines
1–4
Introduction
Introduction to MODBUS
MODBUS RTU (Remote Terminal Unit) Protocol is a messaging structure used to
establish master–slave communications between intelligent devices. When a
MODBUS master sends a message to a MODBUS slave, the message contains the
address of the slave, the function, the data and a check sum. The slave’s response
message contains fields confirming the master’s request, any data requested and
an error–checking field.
A typical MODBUS RTU frame consists of the following fields:
ADDRESS
FUNCTION
DATA
CHECKSUM
The address field of a message contains 8 bits. Valid slave addresses are in the
range of 0– 247 decimal. The individual slave devices are set in the range of 1 – 247
decimal (address 0 is the broadcast to all slaves address). The master specifies a
slave by placing the slave address in the address field of the message. When the
slave responds, it places its own address in the address field to identify to the master
which slave is responding.
The function code field of a message contains 8 bits. Valid function codes are in the
range of 1 – 255 decimal. The function code instructs the slave what kind of action to
take. Some examples are to read the status of a group of discrete inputs; to read the
data in a group of registers; to write to an output coil or a group of registers; or to read
the diagnostic status of a slave.
When a slave responds to the master, it uses the function code field to indicate either
a normal response or that some type of error has occurred. For a normal response,
the slave echoes the original function code. In an error condition, the slave echoes
the original function code with its MSB set to a logic 1.
The data field is constructed using sets of two hexadecimal digits in the range of 00
to FF. According to the network’s serial transmission mode, these digits can be made
of a pair of ASCII characters or from one RTU character.
The data field also contains additional information that the slave uses to execute the
action defined by the function code. This can include internal addresses, quantity of
items to be handled, etc.
The data field of a response from a slave to a master contains the data requested if
no error occurs. If an error occurs, the field contains an exception code that the
master uses to determine the next action to be taken. The data field can be
nonexistent in certain types of messages.
The checksum field is used for error checking. Standard MODBUS serial networks
use two types of error checking.
Parity checking (even or odd) totals the number of logical 1 bits in the data field and
sets the parity bit to a 0 or 1 representing an odd or even total of logical 1 bits. Cyclical
Redundancy Check (CRC) checks the entire message and is applied regardless of
any parity check method used. The CRC field consists of two bytes, creating a 16 bit
binary value. The CRC is calculated in the transmitting device and is recalculated
and compared by the receiving device.
Both the character check and the message frame check are generated in the master
device and applied to the message before transmission. The slave device checks
each character and the entire message frame during receipt.