Vidmas30 Posted December 14, 2015 Report Share Posted December 14, 2015 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 Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted December 14, 2015 MVP 2022 Report Share Posted December 14, 2015 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. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted December 14, 2015 MVP 2022 Report Share Posted December 14, 2015 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. Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted December 14, 2015 Report Share Posted December 14, 2015 I use UDP instead TCP and doesn´t need so long delays between devices because no need to open/close socket, only a short delay between devices (50 ms or so). 1 Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted December 15, 2015 MVP 2022 Report Share Posted December 15, 2015 I cobbled together some ladder code that shows what I do to connect to 2 devices using a single socket. This is just thrown together and hasn't been tested so there might be a typo or goof here or there, but it shows the basic algorithm. Comm with 2 Slaves on 1 Socket.vlp 1 Quote Link to comment Share on other sites More sharing options...
Vidmas30 Posted December 15, 2015 Author Report Share Posted December 15, 2015 Thank you, Flex, I'll try it and give you a feedback! Quote Link to comment Share on other sites More sharing options...
Vidmas30 Posted December 15, 2015 Author Report Share Posted December 15, 2015 Works like a charm! Thank you very much! What I did wrong in my code, was that I didn't reinitialized Modbus TCP configuration block every time whne changed IP address and played only with socket connect-disconnect blocks. Now its clear where the problem was Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.