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.

Modbus TCP Polling Delay
#4
(08.09.2022, 11:28)admin Wrote: If you want quick polling you need to use one resident script per each connection because Modbus mapper can only poll one TCP device at a time.
Use this example as a starting point. The connection is kept open between requests. Multiple registers are read at once to speed things up.
Code:
if not mb then
  require('luamodbus')
  mb = luamodbus.tcp()
  mb:open('192.168.0.9')
 
  res, err = mb:connect()
  if not res then
    mb:close()
    mb = nil
    log('connect failed', err)
  end
end

if mb then
  v1, v2, v3 = mb:readregisters(10, 3)

  if v1 ~= nil then
    grp.checkupdate('1/1/1', v1)
    grp.checkupdate('1/1/2', v2)
    grp.checkupdate('1/1/3', v3)
  else
    mb:close()
    mb = nil
    log('read failed', v2)
  end
end

Thank you admin, this sounds very interesting. What is the correct sleep interval for this resident script? If I set to 1sec is this going to poll data every 1sec from the slave?
Where can I define the registers I would like to read? I need register 0,1,2 and is it also possible to write to those register the value of the knx object when its changed? So in the end a bi-directional communication with the touch panel over modbus IP.

Until now I was using the following profile with mapped knx objects and worked in both directions. The only issue was the delay.

Code:
{
  "manufacturer": "Pro-Face",
  "description": "Touch Panel GP4301-T GM Blok 02->10 ",
  "mapping": [
    { "name": "Zone 1 On/Off", "bus_datatype": "1001", "type": "coil", "address": 0, "writable": 1, "write_only": 0 },
    { "name": "Zone 2 On/Off", "bus_datatype": "1001", "type": "coil", "address": 1, "writable": 1, "write_only": 0 },
    { "name": "Zone 3 On/Off", "bus_datatype": "1001", "type": "coil", "address": 2, "writable": 1, "write_only": 0 }
  ]
}
Reply


Messages In This Thread
Modbus TCP Polling Delay - by manos@dynamitec - 08.09.2022, 10:23
RE: Modbus TCP Polling Delay - by Daniel - 08.09.2022, 10:40
RE: Modbus TCP Polling Delay - by admin - 08.09.2022, 11:28
RE: Modbus TCP Polling Delay - by manos@dynamitec - 08.09.2022, 11:43
RE: Modbus TCP Polling Delay - by admin - 08.09.2022, 11:49
RE: Modbus TCP Polling Delay - by admin - 12.09.2022, 12:08
RE: Modbus TCP Polling Delay - by admin - 14.09.2022, 06:54

Forum Jump: