Combine Modbus High Byte and Low Byte - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10) +--- Thread: Combine Modbus High Byte and Low Byte (/showthread.php?tid=2891) |
Combine Modbus High Byte and Low Byte - savaskorkmaz - 07.10.2020 Hi, We are trying to read a float 4 byte temperature point from a modbus tcp device. We can read via other modbus plc's like 32, 11 degree. But when we use LM we are getting high byte and low byte from different registers. Our temperature registers are 0 , 2, 4. But we are getting values from both 0 and 1. Example : Register 0 : 16896 Register 1 : 30915 We realized that those are high and low byte of our 4 byte point. If we combine them as a float manually in excel, it's : 3,2117931E+01 and that is our temperature. In our profile , point type float32 and point type register. What we can do ? How we can read as a single point ? Regards, RE: Combine Modbus High Byte and Low Byte - admin - 07.10.2020 There's a built-in conversion function that can be used. The more simple way is to use a profile and set "datatype" field to "float32". Code: require('luamodbus') RE: Combine Modbus High Byte and Low Byte - savaskorkmaz - 07.10.2020 Hi , we already use float32 in profile. But we will try one more time. RE: Combine Modbus High Byte and Low Byte - savaskorkmaz - 08.10.2020 Hi there, We can read the correct temperature value using modbus tool with display float32 - big endian mode. (Please see Attached float32modbuspool.jpg ) Using your script, we can combine 2 values. But we dont want use 1000 scripts. Our modbus profile is : { "name": "Group1_BLine1_Node001_L2H_Temp", "bus_datatype": "float32", "type": "register", "address": 0 }, How we can read using only profile method ? Regards, RE: Combine Modbus High Byte and Low Byte - admin - 08.10.2020 You must set datatype field as well: Code: { "name": "V1", "bus_datatype": "float32", "datatype": "float32", "type": "register", "address": 0 }, |