Scaled value while reading Modbus

Hey,

I tried to find some answers here in the forum but without sucsess.

I am reading a value from a dosingpump. I manage to get the raw (DEZ) value. For example as in the image below: 26032. But this value is somehow scaled to another value, which is correctly displayed on the pump: The pump display here 878 ml/ h, which is the corret value
Here is a small image from the software of the dosing pump:

Here is my flow:

[
    {
        "id": "40353ef1cf303d73",
        "type": "modbus-flex-getter",
        "z": "776cf9194f6008fb",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "logIOActivities": false,
        "server": "0e3ec676f3e39293",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "x": 560,
        "y": 240,
        "wires": [
            [
                "57de69c1fdcc80b9",
                "1a39356543e7b1ea"
            ],
            []
        ]
    },
    {
        "id": "57de69c1fdcc80b9",
        "type": "modbus-response",
        "z": "776cf9194f6008fb",
        "name": "",
        "registerShowMax": 20,
        "x": 570,
        "y": 280,
        "wires": []
    },
    {
        "id": "eb5d2c0cd8ba7a73",
        "type": "function",
        "z": "776cf9194f6008fb",
        "name": "R_207_Batchvolume",
        "func": "msg.payload =\n{ value: msg.payload, \n'fc': 3, \n'unitid': 0, \n'address': 110, \n'quantity':1 \n    \n} ;\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 320,
        "y": 280,
        "wires": [
            [
                "40353ef1cf303d73"
            ]
        ]
    },
    {
        "id": "e92a8786fb25e7d8",
        "type": "inject",
        "z": "776cf9194f6008fb",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "2",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 280,
        "wires": [
            [
                "eb5d2c0cd8ba7a73"
            ]
        ]
    },
    {
        "id": "3990b57a3e45d703",
        "type": "debug",
        "z": "776cf9194f6008fb",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 240,
        "wires": []
    },
    {
        "id": "1a39356543e7b1ea",
        "type": "buffer-parser",
        "z": "776cf9194f6008fb",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "uint16be",
                "name": "Batchvolume",
                "offset": 0,
                "length": 1,
                "offsetbit": 0,
                "scale": "0",
                "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": 830,
        "y": 240,
        "wires": [
            [
                "3990b57a3e45d703"
            ]
        ]
    },
    {
        "id": "0e3ec676f3e39293",
        "type": "modbus-client",
        "name": "CIM500",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "tcpHost": "10.240.6.39",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": "1",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": true,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true
    }
]

I am asking myself if it is some buffer parser related problem or did the company scaled this value with a function?

Anyone an idea?

Thank you

What do the docs for the device say?

Hello.

Unfortunly i cant find any mentions in the docu about that.
Ive got a bit suspicious about the factor 0.1 that is present in the software. See image attached.

I have no idea how the number 9464 (that i can read from the modbus register) converts to 7500.

thank you

Some background:

  • Modbus Registers are always 16 BIT
  • That image shows you that 2 registers make up the HI and LO parts of the DosingCapicty
    • This leads me to think the data is either 32bit FLOAT or 32bit UINT
  • Most manufacturers of Modbus devices store 32bit data in Big Endian - so I chose the Buffer-Parser type UINT32BE meaning take 8 bytes (aka 2x16 bit values aka 32bits) of data from the incoming data & convert them to a 32Bit Unsigned Integer using Big Endian format

When you convert the 2 16 bit values [1, 9464] into a 32Bit number (Big Endian) you get 75000

When you scale that by 0.1 (or more accurately divide it by 10) you get 7500

Demo...

Buffer Parser

Demo Flow

[{"id":"37600721f03d9680","type":"inject","z":"08c327c2653de72a","name":"fake mobus data R300~R303","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[0, 0, 1, 9464]","payloadType":"json","x":1720,"y":100,"wires":[["d250bf3bda890004"]]},{"id":"d250bf3bda890004","type":"buffer-parser","z":"08c327c2653de72a","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"R300","offset":0,"length":1,"offsetbit":0,"scale":"/ 10.0","mask":""},{"type":"uint32be","name":"DosingCapacityMax","offset":4,"length":1,"offsetbit":0,"scale":"/ 10.0","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":1680,"y":160,"wires":[["4c6fa20bd13e4f9d"]]},{"id":"4c6fa20bd13e4f9d","type":"debug","z":"08c327c2653de72a","name":"debug 152","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1880,"y":160,"wires":[]}]
2 Likes

Here comes a (very) long shot:

You're reading a 2 register value ... thus the calculation is like:

65536 * [Reg 302] + [REG 303] = 75000

[edit] ... as Steve explained by far better than I did!

1 Like

thank you very much @Steve-Mcl and @ralphwetzel. it was exactly what you mentioned.

best regards

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