Modbus: How to read 32 bit signed numbers

How to read 32 signed numbers over modbus ?
I was using
var msg1 = {payload:(msg.payload[1]<<16)+msg.payload[0]};
code to create 32 bit numbers and toFloat function to convert it to float. However it's not showing the correct value (the output of msg1).
I tried msg.payload=(msg.payload[0])+(-msg.payload[1] << 32) as well with no luck.
Any suggestions

The simplest way is with node-red-contrib-buffer-parser

Search this forum for node-red-contrib-buffer-parser modbus there are quite a few examples.

If you don't want to or can't then look at the nodejs Buffer functions.

1 Like

I tried that, but not getting the negative numbers. Any scripts available to convert two registers to float( including negative) numbers ?

Did you chose int32xx ?
image

uint32 == unsigned int (0 ~ 4bn)
int == signed int (-2bn ~ 2bn)

Show me the output of the modbus node (use debug node)

1 Like