Function description

The WRITE_REG_QX function is used to write registers in a Modbus slave connected to a Modicon M340 Modbus communication module (BMX NOM) located in an EIO drop.

When programming a WRITE_REG_QX function, you must be familiar with the routing procedures used by your network.

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.

Representation in FBD

Representation:

Representation in LD

Representation:

Representation in IL

Representation:

CAL WRITE_REG_QX_Instance (ENABLE:=WriteRegQxEnable, ABORT:=WriteRegQxAbort, ADDR:=ModuleAddress, NO_REG:=NbRegistersToWrite, REG_WRITE:=WriteData, SLAVEREG:=SlaveAddress, IEC:=IndexAdjust, DONE=>WriteRegQxSuccessfull, ACTIVE=>WriteRegQxActive, ERROR=>WriteRegQxFaulty, STATUS=>ErrorCode)

Representation in ST

Representation:

WRITE_REG_QX_Instance (ENABLE:=WriteRegQxEnable, ABORT:=WriteRegQxAbort, ADDR:=ModuleAddress, NO_REG:=NbRegistersToWrite, REG_WRITE:=WriteData, SLAVEREG:=SlaveAddress, IEC:=IndexAdjust, DONE=>WriteRegQxSuccessfull, ACTIVE=>WriteRegQxActive, ERROR=>WriteRegQxFaulty, STATUS=>ErrorCode)

Parameter description

Description of input parameters:

Parameter

Data type

Meaning

ENABLE

BOOL

Set to 1 to write 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 written to the Modbus slave.

REG_WRITE

ANY_ARRAY_WORD

Source data field

(A data structure must be declared as a located variable for the source file.)

SLAVEREG

DINT

Offset address of the first %MW register to be written in the Modbus salve.

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.