Modbus 16bit words to doubleword problems

Hi Everyone,

I'm having problems converting modbus word registers (16 bits) to double (32 bits) format.
Modbus RTU Buffered using node-red-contrib-modbus (4.1.3)

I've tryed to use this (Buffer) in a function but it's not working fine:
let VL1= msg.payload.buffer.readDoubleLE(0,2)
Trying with BE and LE and it's not working fine. I think that with that buffer instruction it tooks 4 modbus words (4x 16bits)...

I don't know how to do it.
Sometimes in other technologies like industrial PLC's i've used SHL (shift left), and other options to do that.
In that ocasion I can't find the correct way to do it.

Can you help me please with it?

Thanks in advance

Hello again,

Changing readDoubleBE with readInt32BE I'm getting some values right (not all).
Working with it.

Hello again,

No way
:dizzy_face:

Someone knows how to do it?

Thanks

Just do it yourself.

Use JavaScript bitshift operators.

Try shifting 1 word 16 bits then add it to the next word.

1 Like

Thanks @Steve-Mcl,

It's working.
I've tested this before, but mybe with some typing errors because the result was NaN.

Thanks!!

1 Like