beautypg.com

ProSoft Technology MVI69-MCM User Manual

Page 144

background image

Reference

MVI69-MCM ♦ CompactLogix or MicroLogix Platform

User Manual

Modbus Communication Module

Page 144 of 167

ProSoft Technology, Inc.

March 22, 2011

5.6.11 MODBUS Exception Responses

When a Modbus Master sends a request to a slave device, it expects a normal

response. One of four possible events can occur from the Master's query:
If the slave device receives the request without a communication error and

can handle the query normally, it returns a normal response.

If the slave does not receive the request due to a communication error, no

response is returned. The Master program will eventually process a timeout

condition for the request.

If the slave receives the request but detects a communication error (parity,

LRC, CRC, ...), no response is returned. The Master program will eventually

process a timeout condition for the request.

If the slave receives the request without a communication error but cannot

handle it (for example, if the request is to read a non-existent address or read

too many points), the slave will return an Exception Response informing the

Master of the nature of the error by using a specific Exception Code in the

response.

An Exception Response message has two fields that differentiate it from a

normal response:
Function Code

Field: In a normal response, the slave echoes the Function Code

of the original request in the Function Code field of the response. All Function
Codes
have a most-significant bit (MSB) of 0 (their values are all below 80

hexadecimal). In an Exception Response, the slave sets the MSB of the Function
Code
byte to 1. This makes the Function Code value in an Exception Response

exactly 80 hexadecimal higher than the value would be for a normal response.
With the Function Code's MSB set, the Master application program can

recognize the Exception Response and can examine the data field for the
Exception Code.
Data Field: In a normal response, the slave may return data or statistics in the
data field (any information that was requested by the request). In an Exception
Response
, the slave returns an Exception Code in the data field. This tells what

slave condition caused the exception.
The following table shows an example of a Master request and slave Exception
Response
.

Request

Response

Field Name

(Hex)

Field Name

(Hex)

Function

01

Function

81

Starting Address Hi

04

Exception Code

02

Starting Address Lo

A1

Quantity of Outputs Hi 00

Quantity of Outputs Lo 01

In this example, the Master addresses a read request to slave device. The

Function Code (01) is for a Read Coil Status operation. It requests the status of

the output coil at address 1245 (04A1 hex). Note that only that one coil is to be

read, as specified by the numbers in the output fields (0001).