Function Description

This function block reads a register area continuously. It reads data from an addressed node via Modbus Plus, TCP/IP Ethernet, or SY/MAX Ethernet.

EN and ENO can be configured as additional parameters.

CREAD_REG, CWRITE_REG, READ_REG, WRITE_REG, and MBP_MSTR function blocks use one data transaction path and require multiple cycles to complete an operation. The number of transaction paths available by module and by MAST cycle depends on the communication port used:

  • Modbus Plus embedded port or NOM modules support up to 4 blocks at the same time.

  • TCP/IP Ethernet embedded port support up to 4 blocks at the same time.

  • TCP/IP Ethernet NOE, NOC, and 140 CRP 312 00 modules support up to 16 blocks at the same time.

More communication function blocks may be programmed on the same communication port. However, a communication block exceeding the maximum number on that port is not serviced until one of the transaction paths is available. Then, the next block on the same port becomes active and begins using an available path.

NOTE: When programming a CREAD_REG function, you must be familiar with the routing procedures used by your network. Modbus Plus routing path structures are described in detail in the communication architectures manual and the Modbus Plus Network Planning and Installation Guide (Reference 31003525). If TCP/IP or SY/MAX Ethernet routing is implemented, standard Ethernet IP router products must be used.
NOTE: Several copies of this function block can be used in the program. However, multiple instancing of these copies is not possible.

Representation in FBD

Representation:

Representation in LD

Representation:

Representation in IL

Representation:

CAL CREAD_REG_Instance (SLAVEREG:=OffsetAddress,    NO_REG:=NumberOfRegisters, ADDRFLD:=DataStructure,    REG_READ=>RegisterToRead, STATUS=>ErrorCode)

Representation in ST

Representation:

CREAD_REG_Instance (SLAVEREG:=OffsetAddress,    NO_REG:=NumberOfRegisters, ADDRFLD:=DataStructure,    REG_READ=>RegisterToRead, STATUS=>ErrorCode) ;

Parameter Description

Description of input parameters:

Parameter

Data Type

Description

SLAVEREG

DINT

Offset address of the first %MW register in the slave to be read from.

NO_REG

INT

Number of addresses to be read from slave.

ADDRFLD

WordArr5

Data structure describing the Modbus Plus address, TCI/IP address, or SY/MAX IP address.

Description of output parameters:

Parameter

Data Type

Description

REG_READ

ANY

Data to be read

For the file to be read a data structure must be declared as a located variable.

STATUS

WORD

If an error occurs while the function is being executed, an error code remains at this output for one cycle.

Runtime Error

Table of error codes for the Communication Library