Jump to content

Best practice to handle communication lost


egoltzman

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?  

 

Link to comment
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).

 

 

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

 

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...