Logic Machine Forum
How to convert received modbus LM value? - 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: How to convert received modbus LM value? (/showthread.php?tid=5910)



How to convert received modbus LM value? - phongvucba - 05.03.2025

Hi! I have a little problem and need everyone's help.
I am using a power meter and it returns a 4byte value, but I see that the 4byte value of LM received is not quite correct, while I use Test mode it gives the correct value (for example here is 9600), but the actual value I receive is 17942.000.
Does anyone know why? I would appreciate it very much.


RE: How to convert received modbus LM value? - admin - 05.03.2025

You need to add "datatype":"float32" to all profile entries.

Do you have documentation for this meter? Data type might be integer not floating point.


RE: How to convert received modbus LM value? - phongvucba - 05.03.2025

(05.03.2025, 06:51)admin Wrote: You need to add "datatype":"float32" to all profile entries.

Do you have documentation for this meter? Data type might be integer not floating point.
Am I writing this right? Or am I missing something?
{
  "manufacturer": "Cảm biến đo điện",
  "description": "04 input registers,kết nối 9600,E,8,1",
  "mapping": [
    { "name": "Baud rate", "bus_datatype": "float32", "type": "register", "address": 0},
    { "name": "Check digit", "bus_datatype": "float32", "type": "register", "address": 2},
    { "name": "Address", "bus_datatype": "float32", "type": "register", "address": 8},
    { "name": "Điện áp V", "bus_datatype": "float32", "type": "inputregister", "address": 0, "units": "V" },
    { "name": "Dòng điện A", "bus_datatype": "float32", "type": "inputregister", "address": 8, "units": "A" },
    { "name": "Công suất Kwh", "bus_datatype": "float32", "type": "inputregister", "address": 18, "units": "W" },
    { "name": "Tần số Hz", "bus_datatype": "float32", "type": "inputregister", "address": 54, "units": "Hz" },
    { "name": "Tổng công suất Kwh", "bus_datatype": "float32", "type": "inputregister", "address": 256, "units": "Kwh" }
  ]
}


RE: How to convert received modbus LM value? - admin - 05.03.2025

Try this:
Code:
{
  "manufacturer": "Cảm biến đo điện",
  "description": "04 input registers,kết nối 9600,E,8,1",
  "mapping": [
    { "name": "Baud rate", "datatype": "float32", "bus_datatype": "float32", "type": "register", "address": 0},
    { "name": "Check digit", "datatype": "float32", "bus_datatype": "float32", "type": "register", "address": 2},
    { "name": "Address", "datatype": "float32", "bus_datatype": "float32", "type": "register", "address": 8},
    { "name": "Điện áp V", "datatype": "float32", "bus_datatype": "float32", "type": "inputregister", "address": 0, "units": "V" },
    { "name": "Dòng điện A", "datatype": "float32", "bus_datatype": "float32", "type": "inputregister", "address": 8, "units": "A" },
    { "name": "Công suất Kwh", "datatype": "float32", "bus_datatype": "float32", "type": "inputregister", "address": 18, "units": "W" },
    { "name": "Tần số Hz", "datatype": "float32", "bus_datatype": "float32", "type": "inputregister", "address": 54, "units": "Hz" },
    { "name": "Tổng công suất Kwh", "datatype": "float32", "bus_datatype": "float32", "type": "inputregister", "address": 256, "units": "Kwh" }
  ]
}



RE: How to convert received modbus LM value? - phongvucba - 05.03.2025

oh, it works fine!
thank so much !