Jump to content
egoltzman

Best practice to handle communication lost

Recommended Posts

My development environment is C# and Unitronics .Net driver.

My program control several PLCs over the the local network (Ethernet), those PLCs are independent from each other and I need to handle situations of communication lost with one of the PLCs (Cable disconnected, PLC restarted etc.) without restart my program and interfering the work with the other PLCs that are still connected.

What would be the best practice for that?  

 

Share this post


Link to post
Share on other sites

If the PC is in Listen then you can work with ListenerServer, where you get events when a PLC got connected on disconnected.

 

If the PLC is in Listen, then you will get an error when you try to communicate with a disconnected PLC, and what do do depends on how you wrote your code.
I would rather wrap the PLC, and what I need from it in a class that handles it all (For example, that class will contain the list of Operands that I need to read and/or write, and the communication parameters. Once there is an error, the class will catch and handle it, and will also handle the retires, for example waiting for a minute and then trying to connect again).

 

Practically, I would go with the 1st option, since in that case, all the PLCs connects to 1 known IP address, rather than the PC knowing to which PLCs it needs to connect.
Each PLC will connect the server and the server will do what it needs to do. This off course not always easy, since from one PLC you need X and from the other Y (so you will have to identify them somehow, by either PLC name, or something else).

 

 

Share this post


Link to post
Share on other sites

Hello Saragani and thank you for your detailed answer, 

My program is working with the PLCs listen to the PC, and as you wrote, the PLC is wrap in a class as describes.

My problem is actually how to handle disconnect events, I catch them but I did not succeed to reestablish connection.

Should I disconnect the Ethernet connection (Unitronics.ComDriver Ethernet : Channel)? How to reestablish the plc that was first created with   plc = PLCFactory.GetPLC(ethernet, 0)?

Should I use plc.Dispose(), plc.Disconnect()? I tried several strategies with no luck, I had to restart the PLC and restart the program in order to reconnect to it and this is not practical.

 

Share this post


Link to post
Share on other sites

You should be able to use the current PLC object (without creating a new one) for reconnecting.

Maybe the socket in the PLC is left opened. You can automatically close it on the PLC side if no communication was made for a defined amount of time (There is a System Integer, or a system operand for that).

Share this post


Link to post
Share on other sites

If so, then after the socket at the PLC will be closed I can just continue to use the plc that was created before with PLCFactory.GetPLC(ethernet, 0) as if there was no problem? No need to reconnect somehow actively?

 

Share this post


Link to post
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...