beautypg.com

Contents of the data field – Watlow CLS200, MLS300 and CAS200 User Manual

Page 30

background image

24 Communications Specification

Chapter 2: Modbus-RTU Protocol

When a message is sent from a master to a slave device, the function
code field tells the slave what kind of action to perform. Examples are to
read the On/Off states of a group of discrete coils or inputs; to read the
data contents of a group of registers; or to read the diagnostic status of a
slave.

When the slave responds to the master, 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
slave simply echoes the original function code. For an exception
response, the slave returns a code that is equivalent to the original
function code with its most significant bit set to a logic 1.

For example, a message from the master to slave to read a group of
holding registers would have the following function code:

0000 0011

x3

If the slave device takes the requested action without error, it returns the
same code in its response. If an exception occurs, it returns:

1000 0011

x83

In addition to its modification of the function code for an exception
response, the slave places a unique code into the data field of the
response message. This tells the master what kind of error occurred, or
the reason for the exception.

The master device’s application program has the responsibility of
handling exception responses. Typical processes are to post subsequent
retries of the message, to try diagnostic messages to the slave, and to
notify operators.

Contents of the Data Field

The data field is constructed using sets of two hexadecimal numbers, in
the range of x00 to xFF.

The data field of messages sent from a master to slave devices contains
additional information that the slave must use to take the action defined
by the function code. This can include items like descrete and register
addresses, the quantity of items to be handled, and the count of actual
data bytes in the field.

For example, if the master requests a slave 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 no error occurs, the data field of a response from a slave to a master
contained the data requested. If an error occurs, the field contains an
exception code that the master application can use to determine the next
action to be taken.