Function description

With a rising edge at the REQ input, this function block reads a register area from an addressed slave via Modbus Plus, TCP/IP-Ethernet or SY/MAX-Ethernet.

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 READ_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 READ_REG_Instance (REQ:=StartReadOnce,
    SLAVEREG:=OffsetAddress, NO_REG:=NumberOfRegisters,
    ADDRFLD:=DataStructure, NDR=>SetAfterReadingNewData,
    ERROR=>SetInCaseOfError, REG_READ=>RegisterToRead,
    STATUS=>ErrorCode)

Representation in ST

Representation:

READ_REG_Instance (REQ:=StartReadOnce,
    SLAVEREG:=OffsetAddress, NO_REG:=NumberOfRegisters,
    ADDRFLD:=DataStructure, NDR=>SetAfterReadingNewData,
    ERROR=>SetInCaseOfError, REG_READ=>RegisterToRead,
    STATUS=>ErrorCode) ;

Parameter description

Description of input parameters:

Parameter

Data Type

Meaning

REQ

BOOL,

With a rising edge at the REQ input, this function block reads a register area from an addressed slave via Modbus Plus, TCP/IP-Ethernet or SY/MAX-Ethernet.

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, TCP/IP address or SY/MAX-IP address.

Description of output parameters:

Parameter

Data Type

Meaning

NDR

BOOL

Set to 1 for one cycle after reading new data

ERROR

BOOL

Set to 1 for one cycle if an error occurs

STATUS

WORD,

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

REG_READ

ANY

Writing data

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

Runtime error

For a list of all block error codes and values, see the table of error codes.