Mask Write Holding Register VI
- Updated2024-11-20
- 3 minute(s) read
Writes values to one or more bits of a holding register.

Inputs/Outputs
![]() Modbus master in specifies the reference to the Modbus master instance. Use the Create Master Instance VI to create a Modbus master instance. ![]() address specifies the holding register address to which you want to write the values. Valid values are between 0 and 65,535, where 65,535 is the maximum number. The address that this VI writes is 0-based, meaning that the address numbering convention for the Modbus slave starts at 0. ![]() error in describes error conditions that occur before this node runs. This input provides standard error in functionality. ![]() AND mask specifies the AND mask you use to write bits of a holding register. Refer to the Details section of this topic for examples of specifying the AND mask. ![]() OR mask specifies the OR mask you use to write bits of a holding register. Refer to the Details section of this topic for examples of specifying the OR mask. ![]() Modbus master out returns a duplicate of Modbus master in. ![]() error out contains error information. This output provides standard error out functionality. |
Mask Write Holding Register Details
The Mask Write Holding Register VI uses the following algorithm to calculate the value to write to individual bits of a holding register:
updated value = (current value AND AND mask) OR (OR mask AND (NOT AND mask)) |
Based on the previous algorithm, you can specify values for AND mask and OR mask according to the following rules:
- To write a bit, specify 1 for AND mask for this bit. If you want to mask a bit, specify 0 for AND mask for this bit. When you specify 0 for AND mask, the value of the bit does not change regardless of what value you specify for OR mask.
- After you specify 0 for AND mask for a bit, you can specify 0 for OR mask to change the value of this bit to 0, regardless of the current value of the bit.
- After you specify 0 for AND mask for a bit, you can specify 1 for OR mask to change the value of this bit to 1, regardless of the current value of the bit.