egoltzman Posted September 13, 2016 Report Share Posted September 13, 2016 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 More sharing options...
Saragani Posted September 18, 2016 Report Share Posted September 18, 2016 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 More sharing options...
egoltzman Posted September 18, 2016 Author Report Share Posted September 18, 2016 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 More sharing options...
Saragani Posted September 18, 2016 Report Share Posted September 18, 2016 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). Link to comment Share on other sites More sharing options...
egoltzman Posted September 18, 2016 Author Report Share Posted September 18, 2016 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? Link to comment Share on other sites More sharing options...
Saragani Posted September 18, 2016 Report Share Posted September 18, 2016 The code that sends the data to the PLC on the Ethernet channel, will connect automatically if the socket is closed. Link to comment Share on other sites More sharing options...
egoltzman Posted September 18, 2016 Author Report Share Posted September 18, 2016 Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now