Function description

The READ_REG_QX function is used to read registers in a Modbus slave connected to a Modicon X80 serial communication module located in an EIO drop.

When programming a READ_REG_QX function, you must be familiar with the routing procedures used by your network. Modbus Plus routing path structures are described in detail in chapter Addressing for a Modbus Plus Communication Entity and in the Modicon Modbus Plus Network Planning and Installation Guide.

NOTE: Several copies of this function block can be used in the program. However, multiple instancing of these copies is not possible.

The additional parameters EN and ENO can be configured.

The communication 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.

Representation in FBD

Representation:

Representation in LD

Representation:

Representation in IL

Representation:

CAL READ_REG_QX_Instance (ENABLE:=ReadRegQxEnable, ABORT:=ReadRegQxAbort, ADDR:=ModuleAddress, NO_REG:=NbRegistersToRead, SLAVEREG:=SlaveAddress, IEC:=IndexAdjust, DONE=>ReadRegQxSuccessfull, ACTIVE=>ReadRegQxActive, ERROR=>ReadRegQxFaulty, STATUS=>ErrorCode, REG_READ=>ReadData)

Representation in ST

Representation:

READ_REG_QX_Instance (ENABLE:=ReadRegQxEnable, ABORT:=ReadRegQxAbort, ADDR:=ModuleAddress, NO_REG:=NbRegistersToRead, SLAVEREG:=SlaveAddress, IEC:=IndexAdjust, DONE=>ReadRegQxSuccessfull, ACTIVE=>ReadRegQxActive, ERROR=>ReadRegQxFaulty, STATUS=>ErrorCode, REG_READ=>ReadData)

Parameter description

Description of input parameters:

Parameter

Data type

Meaning

ENABLE

BOOL

Set to 1 to read registers.

ABORT

BOOL

Set to 1 to abort the current operation.

ADDR

ANY_ARRAY_INT

Array containing the Modbus slave address, result of ADDMX function.

NO_REG

INT

Number of registers to be read in the Modbus slave.

SLAVEREG

DINT

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

IEC

INT

Index adjust applied to SLAVEREG parameter. IEC parameter can have 2 values:

  • 0: %MWx

  • 1: %MWx+1

IEC default value is 0 for a Modicon M340 target.

Description of output parameters:

Parameter

Data type

Meaning

DONE

BOOL

Set to 1 when the execution of the function is completed successfully.

ACTIVE

BOOL

Set to 1 when the execution of the function is in progress.

ERROR

BOOL

Set to 1 if an error is detected by the function block.

STATUS

WORD

Provides the error code if an error is detected by the function block.

REG_READ

ANY_ARRAY_WORD

Read data

(A data structure must be declared as a located variable to receive the response from the Modbus slave.)