Control Logix PLC Connection Status

444 views
Skip to first unread message

Enes Aygün

unread,
Jul 27, 2022, 4:19:43 PM7/27/22
to libplctag

Hi, firstly thanks for this library. I have been developing almost 1 month in C++.
I would like to learn how can I learn PLC Connection status? I want to learn is PLC connect? is PLC disconnect ? or etc. (any connection status) Because I want to learn connection quality.

C API provides plc_tag_status() function but I guess that does not work for me.
What is your suggestion?

Krister Johnson

unread,
Jul 27, 2022, 4:50:58 PM7/27/22
to Enes Aygün, libplctag
I had the same question some time ago and the suggestions I received were a heartbeat tag or to try listing the tags if it is compactlogix or controllogix. There is example code for tag listing here (https://github.com/libplctag/libplctag/blob/release/src/examples/list_tags_logix.c). I have not tried it out yet. The heartbeat method is not what I'm after as I was more looking for a generic approach that works for any AB PLC, not just ones I've implemented some logic on. If you think of anything else let me know.

--
You received this message because you are subscribed to the Google Groups "libplctag" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libplctag+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/libplctag/af67b1a3-4be1-4c44-8ebb-3de3c18ba466n%40googlegroups.com.

Enes Aygün

unread,
Jul 28, 2022, 1:49:49 AM7/28/22
to libplctag
Thank you. But I am wondering does not PLC support this operation or does not library support this operation?
If PLC can give us PLC connection status, we may write that.

27 Temmuz 2022 Çarşamba tarihinde saat 23:50:58 UTC+3 itibarıyla kris...@gmail.com şunları yazdı:

Enes Aygün

unread,
Jul 28, 2022, 2:00:46 AM7/28/22
to libplctag
By the way, what is mean "hearbeat tag"? Can you explain a little bit?

28 Temmuz 2022 Perşembe tarihinde saat 08:49:49 UTC+3 itibarıyla Enes Aygün şunları yazdı:

Kyle

unread,
Jul 28, 2022, 10:38:31 AM7/28/22
to libplctag
Thanks for using the library!

The PLC does not support a connection status.   If you are using an older Rockwell PLC, PLC5 or SLC or MicroLogix, you can read the status data file.  Newer PLCs do not have a tag that is guaranteed to exist.

Whether or not the library is connected to the PLC is complicated.  The PLC will drop the connection if it is unused long enough.   Generally this is on the order of 5-10 seconds.  So the library drops it first at about 5 seconds of inactivity.  The connection can be dropped when the PLC is updated in some circumstances as well.  The library will automatically reconnect when you try to read or write.  Unless you are reading and writing to a PLC continuously, there probably isn't a TCP connection to it all of the time.

With a CIP PLC, there are three levels of connection:
  1. A TCP connection to the PLC.
  2. An EIP session to the PLC.
  3. A CIP connection to the PLC.
These are created in order and torn down in reverse order.

There isn't a good way to determine whether the connection to the library is good or not.  If there is a problem with the connection, the library will tear down and try to set up a full connection again.  What you would see is that read or writes would take a lot longer than normal in that case.

Modbus PLCs are a lot simpler.   There is only a TCP connection.

I could probably add a counter or something for retries.   What are you trying to do with the connection status?

Best,
Kyle

Enes Aygün

unread,
Jul 28, 2022, 11:43:04 AM7/28/22
to libplctag
Hi Kyle, thanks for your response.

I just want to learn connection status. if I knew the connection state in advance, I would not have waited in vain for a timeout while reading or writing.

28 Temmuz 2022 Perşembe tarihinde saat 17:38:31 UTC+3 itibarıyla Kyle şunları yazdı:

Kyle

unread,
Aug 3, 2022, 11:07:21 PM8/3/22
to libplctag
There are many things that can delay a response.   Having or not having a connection to a PLC does not guarantee that you will get a response quickly.   I have run tests against my PLCs that show a very wide variation in response time.   I generally use no lower than 500ms even if I am on the same 1Gbps LAN.  Average response times on my LAN are usually lower than 10ms, closer to 40ms on my WiFi network, but can be higher than 200ms from time to time on either.

I have also measured how long it takes to set up a new connection and that varies considerably too.   I see times from 20ms to 200ms usually.

That is just on my networks with my PLCs.  You would need to measure your networks to see if you have the same variation.  You can use those measurements to determine how long you want to wait for your desired success ratio.  However, external factors can change the PLC's behavior such as other PLCs reading or writing, produced/consumed tags, remote IO etc.

Best,
Kyle
Reply all
Reply to author
Forward
0 new messages