Writing negative value in Modbus Write Node

Hello, Currently I'm doing a project where I need to write a Modbus-write node at the address 5801 with function code 6. The Modbus-write node's description says that the msg.payload must be a single value between 0- 65535. But I need to write a negative value here as an input. How can I write a negative value in the specific address with function code 6? Is there any alternative way of writing a
negative value as input in node-red Modbus write node?

This is because modbus registers are of WORD datatype (16-bit registers), which in IT world may be described as "unsigned 16 bit integer". The only way to write everything else in a modbus register is to "encode it".
You can try using node-red-contrib-buffer-parser or writing a little bit of code in a function node using this. Let me encourage you in using the first way if you're not familiar with all the modbus encoding nuances :).

1 Like