PreviousNext
Help > Modbus Steps Reference > Standard Functions > Mask Write Registers (F22)
Mask Write Registers (F22)

This function is used to modify the contents of a specified holding register using a combination of an AND mask, an OR mask, and the register's current contents. The function can be used to set or clear individual bits in the register.

You can specify the holding register to be written, the data to be used as the AND mask, and the data to be used as the OR mask. Registers are addressed starting at zero. Therefore registers 1-16 are addressed as 0-15.

The function’s algorithm is:

Result = (Current Contents AND And_Mask) OR (Or_Mask AND (NOT And_Mask))

For example:

 

Hex

Binary

Current Contents =

12

0001 0010

And_Mask =

F2

1111 0010

Or_Mask =

25

0010 0101

(NOT And_Mask)=

0D

0000 1101

Result =

17

0001 0111

To configure this step open the Edit Step window from Sequence editor.

In the configuration dialog box, you can change the following settings:

·          Connection Name: connection used to communicate with the device.

·          Address: starting address of the registers to set.

·          AND Mask: And_Mask register value used for calculation.

·          OR Mak: Or_Mask register value used for calculation.

 

Tip  The configuration dialog box display the result of (Or_Mask AND (NOT And_Mask)) to help the user to edit this step.

Tip  To help editing this step, the user who configures this step can change the representation of masks control and indicator to see it in hexadecimal, binary, decimal or octal representation of the two masks, thanks to the radix control into the left part of the masks (And_Mask, Or_Mask) numeric control.

Note  If the Or_Mask value is zero, the result is simply the logical ANDing of the current contents and And_Mask. If the And_Mask value is zero, the result is equal to the Or_Mask value.

 

Note  The contents of the register can be read with the Read Holding Registers function (function code 03). They could, however, be changed subsequently as the controller scans its user logic program.

 

Note  Please read Execution Trace and Steps Variables chapter to learn more about accessing configuration of this step.

 

See Also

Open/Close Functions

Custom Functions