Modbus Flex Getter -> Wrong value with Ferroamp!

I'm using modbus for my solar inverter and I cant get the correct values from it. Ive tried searching the forum and I cant get it to work.

Its this bit that I cant understand:

Data formats
The float data type can be accessed in two ways. The first two addresses use the single precision (32-
bit) floating point number as specified by IEEE 754 with the lower 16-bits at the lower address and
the higher 16-bits at the following address. The two consecutive addresses use two signed 16-bit
integers x, b such that the value represented is x * 10^b. For example, consider the grid voltage L1
located at Modbus number 32032, address 2031. At address 2031 and 2032 the data will be {f15,f14,
...,f0} and {f31,f30,...,f16} respectively, where fn is the n:th bit in the floating point representation. At
2033 and 32034 the data will be {x15,x14,...,x0} and {b15,b14,...,b0} respectively.
The uint16_t is a 16-bit unsigned integer and the int16_t is a signed integer represented in the
binary two’s-complement form.

Im using Modbus Flex Getter with a function node:

Function node:

msg.payload = { 'fc': 4, 'unitid': 1, 'address': 2032, 'quantity': 4 };
return msg;

And this is what I get to my debug node:

{"data":[62915,16967,4999,65534],"buffer":[245,195,66,71,19,135,255,254]}

The value should be ~230

Ferroamp Modbus pdf

Thankful for any help to point me in the right direction

No-one else has replied, so I will point you to node-red-contrib-buffer-parser, which I am sure will do what you want. Unfortunately I am not expert with that node, so you may still need input from someone else if you cannot work it out.

Yep as Colin says - instead of trying to decode in a function node use Steves excellent buffer parser node and then put a debug on the ouput of that - but it is pretty self explanatory

Craig

Hi,

what you are reading is the first 4 input registers starting from register 2032 (so Grid Voltage L1 and Grid Voltage L2); since you're reading 32 bit float data, these are stored over 2 16 bit registers each.
The "data" output is returning the 4 registers values in 16 bit uint.
The "buffer" output is returning the same, but expressed in bytes (each register is 2 bytes).

You can try with a function node wired to the "buffer" output of the modbus flex getter node, with this code (setup the function node in order to have 2 outputs):

let buffer = msg.payload.buffer;
var msg1 = {payload: buffer.readFloatLE(0)}; // first 32 bit float value (Grid Voltage L1 ?)
var msg2 = {payload: buffer.readFloatLE(4)}; // second 32 bit float value (Grid Voltage L2 ?)
return [msg1, msg2];

Some devices reverse the word order (big topic to explain here), so you might need to use

let buffer = msg.payload.buffer.swap16();

As others told you, you could go the easy way with the (awesome) buffer parser node.