This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

correct math for energy metering
#1
Hi,

how correctly make math for my power meter device's data:

I receive 2 byte sighned integer 2083 kWh. But real is 208.3kWh. If I use value myltiplayer for modbus mapper I have only integer part - 208 kWh.

If I just divide 2083 /10 anyway I have only 208. 

So how correctly convert value to floating point to have integer and 2 digits after point for more accurate power metering data??

BR,

Alex
Reply
#2
Set bus_datatype to float32, value_multiplier to 0.1. Then make sure that your object also has 4 byte floating point data type.
Reply
#3
Hi Admin,

unfortunatelly such way not working for me :Sad

In attachment pictures with different datatypes I used with modbus LM reader... As I think my device - Gavazzi PM 340 gives out int32 format - as example 2341 (this is L1 phase voltage, real should be 234.1V). If I use float32 type I see something wrong...

But from documentation - I see smething not correct, in real received data should be divided by 10 not multiplied..

300001 0000h 2 V L1-N INT32 Value weight: Volt*10

What you can recommend?

Alex


.pdf   3-phase Modbus serial protocol EM and ET-rev.2.11.pdf (Size: 164.62 KB / Downloads: 4)                
Reply
#4
Set datatype to int32
Reply
#5
Daniel,

big thanks, I did so. But I receive only integer part of whole meaning. But customer wants see also data after point - I need as example have 243.1. But I don't know how correctly rearrange received 2341 int32 type to 234.1 (float32??). If I just divide 2341 /10 I have only integer part = 234 (customer wants see 234.1 Sad )

In simple math foolish question, but not so easy with datatype formats for me Sad

Alex
Reply
#6
datatype and bus_datatype are two different things. Set datatype to int32 and bus_datatype to float32. First one is modbus dpt and second KNX
Reply
#7
Daniel,

so bus datatype should be : 13. 4 byte signed integer = int32 ??

Alex
Reply
#8
No Smile
"datatype": "int32", "bus_datatype": 14,
http://openrb.com/docs/modbus.htm
Reply
#9
   
AAA my brains Smile

Anyway I am wrong somewhere..

part of my .json file:

{
    "product_code": "Gavazzi EM-340",
    "mapping": [
        {
            "bus_datatype": 14,
            "address": 0,
            "type": "register",
            "units": "V",
            "value_multiplier": 0.1,
            "name": "Voltage L1-N",
            "datatype": "int32"
        },
        {
            "bus_datatype": 14,
            "address": 2,
            "type": "register",
            "units": "V",
            "value_multiplier": 0.1,
            "name": "Voltage L2-N",
            "datatype": "int32"
        },
        {
            "bus_datatype": 14,
            "address": 4,
            "type": "register",
            "units": "V",
            "value_multiplier": 0.1,
            "name": "Voltage L3-N",
            "datatype": "int32"
        },
        {
            "bus_datatype": 14,
            "address": 6,
            "type": "register",
            "units": "V",
            "value_multiplier": 0.1,
            "name": "Voltage L1-L2",
            "datatype": "int32"
        },
but at modbus mapper again formats not correct.. Maybe because from register 0 I need read 2 words by length??

   

Alex
Reply
#10
This is already happening.
Do you have any errors?
Reply
#11
No, no any errors.

I think it could be modbus speed, but I use middle - 38.4 and now only one device. So may be just try to do changes mathematically? By the way, what is last modbus lua library? I using this:

genohm-scada-modbus 20180822
Reply
#12
You need to set correct read_swap field value. Use RTU read test to find correct swap value when reading registers using int32 data type.
Reply
#13
Admin,

thanks, but how correctly to add read_swap to .json:

Is it right way: "read_swap": "0xCDAB",

And where in between I should insert additional arguments??

BR,

Alex
Reply
#14
0xCDAB is swap w which is the default, you probably need swap type n.
Here you have read correct value via read test:
[Image: attachment.php?aid=1367]

Code:
{
    "product_code": "Gavazzi EM-340",
    "read_swap": "n",
    "mapping": ...
After updating the profile you need to delete the device and create it again.
Reply
#15
Thanks,

will check today later.

Alex
Reply


Forum Jump: