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.

Reading Modbus IP

I'm currently in a project that is working with modbus IP, I have searched here in the forum and in the examples of the page but I don't see if there is the possibility of using modbus IP.

My question is: can I use Modbus IP with a logic machine and if so, how could I use it?

thank you
The same way as ModBus RTU - create a profile and assign it to a device.
(30.10.2019, 13:26)admin Wrote: The same way as ModBus RTU - create a profile and assign it to a device.

Thank you very much, now I want to know how the script would be, because for example in modbus RTU one creates a script with the following code:

-- init modbus on first script execution
if not mb then
     mb = luamodbus.rtu()
     mb:open('/dev/ttyS2', 9600, 'E', 8, 1, 'H')

-- sets slave ID to read/write data from/to

-- read 3-phase system voltage from 32-bit register
r1, r2 = mb:readregisters(0x1000, 2)
result = bit.lshift(r1, 16) + r2

for the Modbus IP would I have to change something?

thank you very much
I suggest using profiles instead of scripts as it provides automatic re-connection and other features. For example, if you create a resident script with your code it will stop working if connection is lost. The only way to make it work again would be to restart the script via disable/enable.

TCP connection is created like this:
mb = luamodbus.tcp()
mb:open('', 502)

Forum Jump: