Scaled value while reading Modbus

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