4 function code 02 - read digital input status – Honeywell HC900 User Manual

Page 37

Advertising
background image

Modbus/TCP & Modbus RTU Function Codes

Function Code 02 - Read Digital Input Status

Revision 10

HC900 Hybrid Controller Communications User Guide

29

12/07

4.4 Function Code 02 - Read Digital Input Status

Description

Function code 02 (1X references) is used to read a digital input’s ON/OFF status using 16 bit addressing
for DI access and data is returned in a binary format mapped into bytes.

The Modbus Comm Digital I/O Channel to address mapping is shown starting on page 26.

Broadcast is not supported.

Query

The query message specifies the starting input and the quantity of inputs to read. The DI address in the
message is based on the slot and channel number of the digital input being read.

Example: Read inputs for channels 1 to 16 in Rack #1, Slot 1, from the controller with slave address 1.

Query message format for function code 02

Slave

Address

(00 for TCP)

Function

Code

Starting

Address

High

Starting

Address

Low

Number

Inputs

High

Number

Inputs Low

CRC

(RTU)

CRC

(RTU)

TCP

Example

00 02 00 00

00 10

RTU

Example

01 02 00 00

00 10

CRC

CRC

Response

The input status in the response message is packed as one input per bit of the data field. Status is indicated
as: 1 = ON; 0 = OFF. The LSB of the first data byte contains the input addressed in the query. The other
inputs follow toward the high order end of this byte, and from low order to high order in subsequent bytes.

If the returned input quantity is not a multiple of eight, the remaining bits in the final data byte will be
padded with zeros (toward the high order end of the byte). The byte count field specifies the quantity of
data bytes returned.

Example: Inputs for channels 2 and 6 in Rack #1, Slot 1 are on, all others are off.

Response message format for function code 02

Slave

Address

(00 for TCP)

Function

Code

Byte Count

Data

Data

CRC

(RTU)

CRC

(RTU)

TCP

Example

00 02 02 22

00

RTU

Example

01 02 02 22

00

CRC

CRC

In the response the status of inputs 1 - 8 is shown as the byte value 22 hex, or 0010 0010 binary. Input 8 is
the MSB of this byte, and input 1 is the LSB. Left to right, the status of input 6 through 1 is: OFF-OFF-
ON-OFF-OFF-OFF-ON-OFF. The status of inputs 9-16 are shown as 00 hex, or 0000 0000 with the same
bit ordering.

Advertising