Logic Machine Forum
kWh modbus to KNX convertion? - 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: kWh modbus to KNX convertion? (/showthread.php?tid=4734)



kWh modbus to KNX convertion? - ClausP - 25.04.2023

Hello everyone.

I've been using this code to convert an int16 modbus to an float16 knx.
Code:
    {
      "address": 52,
      "datatype": "int16",
      "bus_datatype": "float16",
      "name": "Total import kWh",
      "value_multiplier": 0.1,
      "type": "register"
    },
it has been working flawless until the total kwh counter reached 3276.7 kwh.
Then it stopped working.
I prosume that the problem is that i run out of data in the 16 bit signed integer. 

Then I tried to change the datatype to int32 an the bus_datatype to 14 (4-byte floating point).
But still no succes. 
Any sugestions on what to do to get the propper readout in KNX? 

The last code I tried is copied from another modbus profile for a powermeter:
Code:
    {
      "address": 52,
      "read_count":20,
      "read_offset":2,
      "datatype": "float32",
      "bus_datatype": "14",
      "name": "Total import kWh",
      "value_multiplier": 0.1,
      "type": "register"
    },
The powermeter I use is a Carlo Gavazzi EM340.
Link to modbus manual: https://gavazzi.se/app/uploads/2020/11/em330_em340_et330_et340_cp.pdf


RE: kWh modbus to KNX convertion? - admin - 25.04.2023

datatype must be set to int32. You might need use a different read_swap. Use Read test to find correct parameters.


RE: kWh modbus to KNX convertion? - ClausP - 25.04.2023

(25.04.2023, 08:05)admin Wrote: datatype must be set to int32. You might need use a different read_swap. Use Read test to find correct parameters.
Can you specify the read test? How do I do that?


RE: kWh modbus to KNX convertion? - admin - 25.04.2023

Read test is in the Modbus tab / bottom toolbar.


RE: kWh modbus to KNX convertion? - ClausP - 25.04.2023

Okay, i've done the read test, and it has to be set as follows:
Read Swap: None (ABCD)
Datatype: int32
How do I specify the readswap in the .json file? Smile


RE: kWh modbus to KNX convertion? - admin - 25.04.2023

Add "read_swap":"n" to your profile entry. It is all described here: https://openrb.com/docs/modbus.htm