Jump to content

ModBus TCP: 2 connections 1socket


Recommended Posts

Good day, 

 Due to lack of ethernet sockets (v570) we need to set up modbus TCP communication with 2 Omron PLC's through the same socket. When connecting separately all works fine, but can't figure out principle to get them work together.. Tried different ways: after configuration, there is command to connect socket to one of PLC's IP (indirect IP and port), then after some time there is command to close socket and to connect to another IP. Nothing happens, conection to only one IP. Maybe something wrong with timing or connect socket commands. Maybe someone could share working example how to organize such connection that would be fast and robust. Thank you in advance. Happy hannukah :)

Link to comment
Share on other sites

  • MVP 2023

I do this all the time due to the 4 socket limitation of the Vision products. Simply use indirect addressing for the IP (use can use the same port number if you wish), as you are doing. You also must re-initialize the configuration block with the new IP and re-connect the socket. Perform your data communications and after a short period of time, close the socket and repeat with the other PLC IP address. I use about 300ms timing between data communications and allow an additional 100ms for the close socket to complete.

Link to comment
Share on other sites

  • MVP 2023

I checked my code and see that I mis-remembered the timing. I allow 300ms for the complete cycle of a single PLC connection, communication, & close. I check for socket connection and wait 100ms for data communications to complete then perform socket close. When the self-resetting 300ms timer triggers I start the next cycle.

 

I also use a bit which is toggled so I keep track of which PLC is currently connected.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...