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 that you accept these cookies being set.

w4k fails reading modbus rtu float32
#1
I've a eastron sdm72d modbus meter and I use the following lua code: 
Code:
require('luamodbus')
mb = luamodbus.rtu()

mb:open('/dev/RS485', 9600, 'N', 8, 1, 'H')   -- SDM72 nutzt 8N1
mb:setslave(20)
mb:connect()


local r1, r2 = mb:readinputregisters(70, 2)
local value = mb:readregistervalue(70, "float32")
log(r1, r2, value)


mb:close()

I get the following result:
Code:
* arg: 1
  * number: 16967
* arg: 2
  * number: 57672
* arg: 3
  * number: 0

So in general the code seems to work. Why do I get a 0 for value? 
The modbus register can be found here: https://data.xn--stromzhler-v5a.eu/manua...72dmv2.pdf
Reply
#2
Use mb:readinputregistervalue(). It's highly recommended to use profiles instead of scripts.
Reply
#3
Using a profile was my first try, but it didn't work. So I tried so solve it with this script. 

Code:
{
  "manufacturer": "Eastron",
  "description": "3-phasiger Energiezähler SDM72D-M",
  "mapping": [
    {
      "name": "Frequency",
      "address": 70,
      "type": "inputregister",
      "bus_datatype": "float32",
      "unit": "Hz"
    }
  ]
}

With this profile I get the value 16967.000. Which is wrong, it should be around 50. 

readinputregistervalue() - seems to be the problem. 
Code:
require('luamodbus')
mb = luamodbus.rtu()

mb:open('/dev/RS485', 9600, 'N', 8, 1, 'H')
mb:setslave(20)
mb:connect()



local r1 = mb:readregistervalue(70,"float16")
local r2 = mb:readregistervalue(71,"float16")


local value = mb:readregistervalue(70, "float32")
log(r1, r2, value)


mb:close()

log:
Code:
* arg: 1
  * number: 0
* arg: 2
  * number: 0
* arg: 3
  * number: 0
Reply
#4
Your profile is missing "datatype": "float32"
Reply
#5
Thank you verry much. Now I can use the profile.
Reply


Forum Jump: