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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.