Chapter 9. Modbus/TCP Client158 PACSystems* RX7i & RX3i TCP/IP Ethernet Communications User Manual GFK-2224QMask Write Register Request to a Modbus Server Device (3009)The Mask Write Register Request to a Modbus Server Device COMMREQ is used to modify the contents of aspecified remote device register using a combination of an AND mask, OR mask and the current register’svalue. This function is used to set or clear individual bits in a register. The register is modified per the followingalgorithm:Register value = ((Current register value) AND (And Mask Value)) OR((OR Mask Value) AND (NOT(And Mask Value)))Command 3009, Example – Mask Write RegisterModify register at address 200 in the remote Modbus/TCP server and clear all bits except bit 0. Return theCOMMREQ Status word to %R10. Use channel 6, a channel previously opened with the Open Modbus/TCP ClientConnection COMMREQ.Dec (Hex)Word 1 00008 (0008) Length of Channel command Data BlockWord 2 00000 (0000) Always 0 (no-wait mode request)Word 3 00008 (0008) Memory type of CRS word (%R)Word 413 00009 (0009) CRS word address minus 1 (%R10)Word 5 00000 (0000) ReservedWord 6 00000 (0000) ReservedWord 7 03009 (0BC1) Mask Write Register to a Modbus/TCP Server DeviceWord 8 00006 (0006) Channel number (6)Word 9 00022 (0016) Modbus Function Code – Write Mask RegisterWord 10 00200 (00C8) Address in the Remote DeviceWord 11 00001 (0001) AND MaskWord 12 00000 (0000) OR MaskWord 13 00001 (0001) Unit Identifier(Word 7) Channel Command Number: Word 7 identifies the COMMREQ as a Mask Write Register operation onremote Modbus/TCP device.(Word 8) Channel Number: Word 8 identifies the channel number previously allocated for communication withthe remote Modbus/TCP server.(Word 9) Modbus Function Code: Word 9 specifies Function Code 22, Mask Write Register.(Word 10) Remote Device Address: specifies the destination register in the remote device.(Word 11) AND Mask: Word 11 specifies the AND mask to be used in the Mask Write operation. For thisexample, all bits are cleared except bit 0.(Word 12) OR Mask: Word 12 specifies the OR mask to be used in the Mask Write operation. In this example,no bits are to be set.(Word 13) Unit Identifier: This field is typically used by Ethernet to Serial bridges to specify the address of aModbus Slave on a multi-drop link. The Modbus/TCP Unit Identifier is a special control code used in aModbus/TCP message block.