If you mean combining bits to make a WORD value - its just basic math functionality of the programming language.
e.g....
//Get bit
function getBit(number, bitPosition) {
return (number & (1 << bitPosition)) === 0 ? 0 : 1;
}
//Set Bit
function setBit(number, bitPosition) {
return number | (1 << bitPosition);
}
//Clear Bit
function clearBit(number, bitPosition) {
const mask = ~(1 << bitPosition);
return number & mask;
}
//Update Bit
function updateBit(number, bitPosition, bitValue) {
const bitValueNormalized = bitValue ? 1 : 0;
const clearMask = ~(1 << bitPosition);
return (number & clearMask) | (bitValueNormalized << bitPosition);
}
You could use the code from these to update a WORD value and set / reset bits...
var plcValue = msg.payload;
//Set Bit 12
plcValue = plcValue | (1 << 12);
//reset Bit 3
const mask = ~(1 << 3);
plcValue = plcValue & mask;
msg.payload = plcValue; //(return this for next node to send it back to the PLC
Hope that helps.