Hello,
I'm trying to make a connection with Modbus TCP slave device.
I tried to do so with scripts (you can see it below) and visual mapper.
In visual mapper I tried many different combinations in device profile, but couldn't get right value:
Full script (IP address of device is corrent - 192.168.1.210, port - 502, slave ID - 20):
I'm trying to make a connection with Modbus TCP slave device.
I tried to do so with scripts (you can see it below) and visual mapper.
In visual mapper I tried many different combinations in device profile, but couldn't get right value:
Code:
{ "name": "Input 1", "bus_datatype": "float16", "type": "register", "address": 128, "datatype": "float16", "value_multiplier": 1, "units": " C" },
{ "name": "Input 1", "bus_datatype": "uint16", "type": "register", "address": 128, "datatype": "float16", "value_multiplier": 1, "units": " C" },
{ "name": "Input 1", "bus_datatype": "int16", "type": "register", "address": 128, "datatype": "int16", "value_multiplier": 1, "units": " C" }
and etc..
Full script (IP address of device is corrent - 192.168.1.210, port - 502, slave ID - 20):
Code:
require('luamodbus')
if not mb then
mb = luamodbus.tcp()
mb:open('192.168.1.210')
mb:connect()
end
-- verbose output and select slave number 10
mb:setdebug(true)
mb:setslave(20)
-- read input from reg 1 to 5, get slave-specific data
local result = mb:readregistervalue(128, dt.float16)
grp.write('14/1/0', result, dt.float16)
local value = mb:reportslaveid()
alert(value)
-- close serial connection
mb:close()