| 
		
	
	
	
		
	Posts: 394 
	Threads: 84 
	Joined: Jun 2017
	
 Reputation: 
9 
	
	
		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
 
		
	 
	
	
	
		
	Posts: 8410 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
481 
	
	
		Set bus_datatype to float32, value_multiplier to 0.1. Then make sure that your object also has 4 byte floating point data type.
	 
		
	 
	
	
	
		
	Posts: 394 
	Threads: 84 
	Joined: Jun 2017
	
 Reputation: 
9 
	
	
		Hi Admin, 
unfortunatelly such way not working for me :   
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
        
		
	 
	
	
	
		
	Posts: 5283 
	Threads: 29 
	Joined: Aug 2017
	
 Reputation: 
237 
	
	
		Set datatype to int32
	 
------------------------------Ctrl+F5
 
		
	 
	
	
	
		
	Posts: 394 
	Threads: 84 
	Joined: Jun 2017
	
 Reputation: 
9 
	
	
		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    )
 
In simple math foolish question, but not so easy with datatype formats for me    
Alex
	
		
	 
	
	
	
		
	Posts: 5283 
	Threads: 29 
	Joined: Aug 2017
	
 Reputation: 
237 
	
	
		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
	 
------------------------------Ctrl+F5
 
		
	 
	
	
	
		
	Posts: 394 
	Threads: 84 
	Joined: Jun 2017
	
 Reputation: 
9 
	
	
		Daniel,
 so bus datatype should be : 13. 4 byte signed integer = int32 ??
 
 Alex
 
		
	 
	
	
	
		
	Posts: 5283 
	Threads: 29 
	Joined: Aug 2017
	
 Reputation: 
237 
	
	
		No    
"datatype": "int32", "bus_datatype": 14,
http://openrb.com/docs/modbus.htm
------------------------------Ctrl+F5
 
		
	 
	
	
	
		
	Posts: 394 
	Threads: 84 
	Joined: Jun 2017
	
 Reputation: 
9 
	
	
		
  
AAA my brains    
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
	 
		
	 
	
	
	
		
	Posts: 5283 
	Threads: 29 
	Joined: Aug 2017
	
 Reputation: 
237 
	
	
		This is already happening. Do you have any errors?
 
------------------------------Ctrl+F5
 
		
	 
	
	
	
		
	Posts: 394 
	Threads: 84 
	Joined: Jun 2017
	
 Reputation: 
9 
	
	
		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
 
		
	 
	
	
	
		
	Posts: 8410 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
481 
	
	
		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.
	 
		
	 
	
	
	
		
	Posts: 394 
	Threads: 84 
	Joined: Jun 2017
	
 Reputation: 
9 
	
	
		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
 
		
	 
	
	
	
		
	Posts: 8410 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
481 
	
	
		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]](https://forum.logicmachine.net/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.
	
		
	 
	
	
	
		
	Posts: 394 
	Threads: 84 
	Joined: Jun 2017
	
 Reputation: 
9 
	
	
		Thanks, 
 will check today later.
 
 Alex
 
		
	 |