Modbus chart with large variable values instead of negative ones

Hello everyone.
I am using modbus flex sequencer to read variable values from carel cpco driver. Everything works well as long as the temperature on the sensors does not drop below zero. Then the modbus instead of negative values sends a very large values, and the graph, of course, also starts to go crazy.
The value of 65533 is read thru modbus realy should be around -0.23 °C
What's the problem with large variable values instead of negative ones?
Thank you for any help!
Luke

...
          {
            "x": 1662412368211,
            "y": 0
          },
          {
            "x": 1662412428175,
            "y": 65535
          },
          {
            "x": 1662412488204,
            "y": 65535
          },
          {
            "x": 1662412548228,
            "y": 65535
          },
...

You are reading UINT (unsigned 16 bit integer) which is 0 to 65535
However you want a negative value which should be INT (signed 16 bit integer) which is -32768 to +32767

(UINT16) 65535 === (INT16) -1

What you need is to parse the data as INT16be (signed int, 16 bit, Big endian).

A node built specifically for this is node-red-contrib-buffer-parser - install that node, and then read the readme & try out the built in demos (CTRL-I --> examples --> node-red-contrib-buffer-parser) and search the forum for modbus buffer parser

1 Like

Thanks a lot for the tips.
Below I am sending a simple node with negative numbers, maybe it will help someone.

[{"id":"4ea3286873efc357","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"b0c68b42f3e7f27c","type":"buffer-maker","z":"4ea3286873efc357","name":"","specification":"spec","specificationType":"ui","items":[{"name":"negative_number","type":"int16be","length":1,"dataType":"msg","data":"payload"}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":410,"y":180,"wires":[["bc1d8ac2d1c21e37","8e1bfe5c91b66de1"]]},{"id":"724917f13e9ce27e","type":"inject","z":"4ea3286873efc357","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-123","payloadType":"json","x":250,"y":180,"wires":[["b0c68b42f3e7f27c"]]},{"id":"bc1d8ac2d1c21e37","type":"debug","z":"4ea3286873efc357","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":260,"wires":[]},{"id":"8e1bfe5c91b66de1","type":"buffer-parser","z":"4ea3286873efc357","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"negative_number","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":650,"y":180,"wires":[["1b0af9f988cc4af6"]]},{"id":"1b0af9f988cc4af6","type":"debug","z":"4ea3286873efc357","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":260,"wires":[]}]

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