Modbus TCP float to value

can you set your modbus to read from Register 0 for Length 16

Then use the "Copy Value" button in the debug sidebar to copy the exact payload - post that in a reply please?

image


I have managed to get 237 from your earlier data but i suspect the data is 2 byte off because I had to SWAP16 and use float LE function - this is in contradiction to your manual.

[19017,17258]

that is not 16 long & it is not a copy of the payload like I asked otherwise it would look something like...

{
  "data": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],
  "buffer": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
}

I don't get that values, can you maybe send your script?

I don't have any script. Did you set modbus read to Reg 0 and the Length to 16?

Do you have debug node attached to modbus read?

When you read modbus data, do you get entry in debug sidebar?

Use the copy value button as I have shown.


this is what I have

You haven't set the modbus node to read more items. It's still set to read 2 items.

Can you please set the register to 0 and the length to 16 and capture the data as I explained.

[47513,17255,44234,17255,43211,15956,49509,15873,6404,16006,39183,15947,54165,17255,50869,17255]

Milan .. also set your Debug node (that is wired to Modbus node) to complete message in order to see and more easily copy the value of the buffer which should be in msg.responseBuffer.buffer

image

{"topic":"polling","payload":[1432,17256,64922,17255,63669,15958,46993,15878,8440,16007,35711,15951,8520,17256,6466,17256],"responseBuffer":{"data":[1432,17256,64922,17255,63669,15958,46993,15878,8440,16007,35711,15951,8520,17256,6466,17256],"buffer":[5,152,67,104,253,154,67,103,248,181,62,86,183,145,62,6,32,248,62,135,139,127,62,79,33,72,67,104,25,66,67,104]},"input":{"topic":"polling","from":"","payload":{"unitid":"61","fc":3,"address":"0","quantity":"16","messageId":"620cebbcc893dad1cfa8649e"},"queueLengthByUnitId":{"unitId":61,"queueLength":0},"queueUnitId":61,"unitId":61},"sendingNodeId":"7d810a3e3e7d705f","_msgid":"a9d5b88e2ddf90b5"}

I get this:
grafik

[
    {
        "id": "579d064f73357cb4",
        "type": "inject",
        "z": "9fc0f809.f00518",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[5,152,67,104,253,154,67,103,248,181,62,86,183,145,62,6,32,248,62,135,139,127,62,79,33,72,67,104,25,66,67,104]",
        "payloadType": "bin",
        "x": 330,
        "y": 1160,
        "wires": [
            [
                "bbd8805693f01e58"
            ]
        ]
    },
    {
        "id": "bbd8805693f01e58",
        "type": "buffer-parser",
        "z": "9fc0f809.f00518",
        "name": "test",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "floatle",
                "name": "item1",
                "offset": 0,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item2",
                "offset": 4,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item3",
                "offset": 8,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item4",
                "offset": 12,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item5",
                "offset": 16,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item6",
                "offset": 20,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item7",
                "offset": 24,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item8",
                "offset": 28,
                "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": 450,
        "y": 1160,
        "wires": [
            [
                "6ac769f038435cd4"
            ]
        ]
    },
    {
        "id": "6ac769f038435cd4",
        "type": "debug",
        "z": "9fc0f809.f00518",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 590,
        "y": 1160,
        "wires": []
    }
]

you would have gotten this too if you used my example flow: Modbus TCP float to value - #8 by Becker

How did you do that?
Which node did you use and which settings?

copy&paste my last example and test yourself with live data

In case you don't know then you can import a flow from here using the menu Import feature.
If you didn't know that then I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

1 Like

that was the data I needed.

So, my point was to demonstrate how you get all the values in one go and convert them to the right format.

Demo...

Demo flow (import using CTRL+I)

[{"id":"36222b89d1539d62","type":"inject","z":"150d20998fc7fe72","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1980,"y":200,"wires":[["52e1a776e983b3f8"]]},{"id":"52e1a776e983b3f8","type":"function","z":"150d20998fc7fe72","name":"fake modbus data","func":"\nmsg = {\n    \"topic\": \"polling\",\n    \"payload\": [\n        1432,\n        17256,\n        64922,\n        17255,\n        63669,\n        15958,\n        46993,\n        15878,\n        8440,\n        16007,\n        35711,\n        15951,\n        8520,\n        17256,\n        6466,\n        17256\n    ],\n    \"responseBuffer\": {\n        \"data\": [\n            1432,\n            17256,\n            64922,\n            17255,\n            63669,\n            15958,\n            46993,\n            15878,\n            8440,\n            16007,\n            35711,\n            15951,\n            8520,\n            17256,\n            6466,\n            17256\n        ],\n        \"buffer\": Buffer.from([\n            5,\n            152,\n            67,\n            104,\n            253,\n            154,\n            67,\n            103,\n            248,\n            181,\n            62,\n            86,\n            183,\n            145,\n            62,\n            6,\n            32,\n            248,\n            62,\n            135,\n            139,\n            127,\n            62,\n            79,\n            33,\n            72,\n            67,\n            104,\n            25,\n            66,\n            67,\n            104\n        ])\n    },\n    \"input\": {\n        \"topic\": \"polling\",\n        \"from\": \"\",\n        \"payload\": {\n            \"unitid\": \"61\",\n            \"fc\": 3,\n            \"address\": \"0\",\n            \"quantity\": \"16\",\n            \"messageId\": \"620cebbcc893dad1cfa8649e\"\n        },\n        \"queueLengthByUnitId\": {\n            \"unitId\": 61,\n            \"queueLength\": 0\n        },\n        \"queueUnitId\": 61,\n        \"unitId\": 61\n    }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2055.5555572509766,"y":245.55552864074707,"wires":[["a80bc70fb3ddbe19","c53f4232eb527410"]]},{"id":"a80bc70fb3ddbe19","type":"debug","z":"150d20998fc7fe72","name":"modbus data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2255.5555572509766,"y":245.55552864074707,"wires":[]},{"id":"c53f4232eb527410","type":"buffer-parser","z":"150d20998fc7fe72","name":"","data":"responseBuffer.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"L1_RMS_V","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L1_RMS_FV","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L2_RMS_V","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L2_RMS_FV","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L3_RMS_V","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L3_RMS_FV","offset":20,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L1L2_RMS_V","offset":24,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L1L2_RMS_FV","offset":28,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","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":2075.5555572509766,"y":325.55552864074707,"wires":[["70cca1b71057c8e0"]]},{"id":"70cca1b71057c8e0","type":"debug","z":"150d20998fc7fe72","name":"parsed data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2255.5555572509766,"y":325.55552864074707,"wires":[]}]

but the values are illogical... L1-L2 should be about 400V.
:face_with_monocle:

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