4

Write Data to a Modbus/TCP Device (3004)

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

Registers or Coils may be written to the remote Modbus/TCP device. The Modbus Function Code specifies the data type. Valid Function Codes for the Write Data COMMREQ are presented in the following table:

Function

Code

Description

Base

Address

Data Unit Size Maximum Data Units

5

Write Coil

00001

Bit

1

 

 

 

 

 

6

Write Single Registers

40001

Register

1

 

 

 

 

 

16

Preset Multiple Registers

40001

Register

100

 

 

 

 

 

An Address Offset and Length specify the location in the Modbus/TCP device and the number of data units to transfer. The Address Offset is the offset from the Base Address. The Length is the number of Registers or Coils to transfer.

A PLC data area is the source for the data written to the Modbus/TCP device. The source of data can be any of the PLC data areas (see page 4-14).

Function Code 5, Force Single Coil, is the only coil operation supported by the Modbus/TCP Client. This function forces a Coil On or Off. To force a coil off, the value zero (0) is used as the COMMREQ data value. To force a coil on, the value one (1) is used as the COMMREQ data value.

The COMMREQ Status Word (CSR) indicates the success or failure of the Write Data COMMREQ. If the COMMREQ specifies an invalid channel number or any other invalid field 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.

4-16

TCP/IP Ethernet Communications for the Series 90™ PLC User's Manual– May 2002

GFK-1541B

Page 131
Image 131
GE GFK-1541B manual Write Data to a Modbus/TCP Device