RS485/ Modbus 2x 16Bit Buffer conversion to signed 24Bit Datatype from Finder-Meter 7M38

Hi all,
I got help here already with a similar problem but now i got stuck again.

I'm reading values from a finder energymeter with modbus into node-red. That's ok.

But now I'm not able to convert the two incomming 16bit register into one signed 24bit value. There is a description out of the manual which says the incomming data need to be transvered into a signed 24bit number. Until now I converted the incomming modbus-data with an buffer-parser. This worked perfekt for unsigned 24bit, because we could use the 32bit one. (Many thanks to Steve-Mcl!)

This ist the description of the manual:

The example of the manual works with 0xFE1DC0. Divided into two 16bit Words ist (FE1D, 00C0). This into decimal is (65053, 192). Thats what I'm injecting into my example:

[{"id":"0a6cee1938af483e","type":"tab","label":"Flow 10","disabled":false,"info":"","env":[]},{"id":"545bde1568fd7ba7","type":"inject","z":"0a6cee1938af483e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[65053, 192]","payloadType":"json","x":150,"y":400,"wires":[["c716d07040b3e1b6"]]},{"id":"c716d07040b3e1b6","type":"buffer-parser","z":"0a6cee1938af483e","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int32be","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":"0x0ffffff"},{"type":"int8","name":"item2","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":370,"y":400,"wires":[["e2f9f5f802c0358c"]]},{"id":"e2f9f5f802c0358c","type":"debug","z":"0a6cee1938af483e","name":"debug 321","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":400,"wires":[]}]

Thank you!

BR
Chris

Hi,
I got a workarround for the problem.

In the buffer-parser i'm passing the relevant 4 Bytes with a "Buffer" size 4. Next there comes a function-node. Within this I call these two functions. One for the 24Bit Value and one for the Finder specific exponent:

function extractT6Value(buffer) {
    if (buffer.length !== 4) {
        throw new Error('Der Buffer muss genau 4 Bytes lang sein');
    }
    const value = buffer.readIntBE(1, 3); // Liest 3 Bytes als signed Big-Endian Integer
    return value;
}
function extractT6Exponent(buffer) {
    if (buffer.length !== 4) {
        throw new Error('Der Buffer muss genau 4 Bytes lang sein');
    }
    const exponent = buffer.readInt8(0); // Liest das 8-Bit Dezimal-Exponenten-Feld
    return exponent;
}

BR
Chris

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.