Read data from a modbus/tcp device (3003) – FANUC Robotics America GFK-1541B User Manual

Page 126

Advertising
background image

GFK-1541B

Chapter 4 Programming Modbus/TCP Channel Commands

4-11

4

Read Data from a Modbus/TCP Device (3003)

The Read Data from a Modbus/TCP Device COMMREQ requests a data transfer from a
Modbus/TCP device to the PLC. The Read Data COMMREQ must reference an active
Modbus/TCP channel previously established with the Open Modbus/TCP Client Connection
COMMREQ.

Registers, Coils or Exception Status data may be read from the remote Modbus/TCP device. The
Modbus Function Code specifies the data type. Valid Function Codes for the Read Data

COMMREQ are presented in the following table

:

Function

Code

Description

Base Address

Data Unit Size

Maximum Data

Units

1

Read Coils

00001

Bit

2000

2

Read Input Discretes

10001

Bit

2000

3

Read Multiple
Registers

40001

Register

(16-bit Word)

125

4

Read Input Registers

30001

Register

(16-bit Word)

125

7

Read Exception
Status

Not Applicable

Byte

Not Applicable

An Address and Length specify the location of the data in the remote device and the number of
data units to transfer. The Length is the number of Registers or Coils to transfer. Modbus
Function Code 7, Read Exception Status does not require the address as the remove device
retrieves the exception status from an internal location.

Coil data is always padded with zeros when less than an even multiple of 16 bits of coil data is
returned to the PLC.

Data returned from the remote device is stored in the PLC data area specified in the Read
Modbus/TCP Device COMMREQ. Data can be stored in any of the PLC data areas. Refer to page
4-14 for the list of data areas and identification codes for the PLC. Note that the first item
referred to in each data area is item 1 not item 0.

The COMMREQ Status Word (CSR) indicates the success or failure of the Read Data
COMMREQ. If the COMMREQ requests an invalid channel number or any other field is invalid
the COMMREQ fails and the CSR is set to a non-zero value to identify the failure. See the section
“Status Data” later in this document for detailed CSR failure codes.

www.cadfamily.com EMail:[email protected]
The document is for study only,if tort to your rights,please inform us,we will delete

Advertising