Which Python Lib To Use?

Wow thats a crazy delay. In the siemens library I used. Snap7. It was as close to instant as I could expect. I was turning a bit on with the python program then flipping it off in the plc with a short timer and you would never even see it turn off. The whole process of reading --> writing --> reading would be <50ms

Yeah, I thought the same thing about the delay. If I recall, the delay was only when reading a tag value, not writing to it. Writing was fast, like <100ms. So not sure what the delay on reading is all about. There might be a function in that library that is more efficient and faster for reading. Again, I was only reading by tag name, and only one tag. I don't think it was anything on my end causing the delay(?). I'd be interested to know someone else's experience.

I've also used the pyads library for communicating with Beckhoff PLC's. That one is fast ("instant") for reading and writing to PLC variables. No issue with delays.
 
I've only recently started experimenting with using Python libraries with PLC's. I used Pycomm3 to communicate with ComplactLogix PLC. Very straight forward and easy. Documentation good and thorough. I was just reading tags and writing to them, so not doing anything compelling.

One thing I did find though that was odd, possibly just inherent to that library is that when reading just one tag, it would hang for several seconds before finally reading back the tag value. My guess is that the time delay is because it's iterating through all the tags on the controller to find the tag name specified(?). I didn't dig into the underlying code to find out, but just a guess.

I believe the delay in pycomm3 is because it retrieves the tag database the first time it connects to the PLC in order to have the UDT definitions ahead of time. There is no documented way to retrieve the structure of only one tag, it is all or nothing. So the larger your tag database is, the longer this takes.
 
Last edited:
You docs and programming examples are excellent. Thank you for all your hard work!

Thanks for the feedback. I added the docs recently, which I feel like I'm terrible at.

When I started learning python, I found that I learned best with simple examples that I could tinker with, to see how they work. Simple, clear examples are sometimes hard to come by, so I had all of that in mind when I added them to the project. I'd end up reading some projects documentation to try to understand how to use it, but it was good examples that really helped me.
 
Thanks for the feedback. I added the docs recently, which I feel like I'm terrible at.

When I started learning python, I found that I learned best with simple examples that I could tinker with, to see how they work. Simple, clear examples are sometimes hard to come by, so I had all of that in mind when I added them to the project. I'd end up reading some projects documentation to try to understand how to use it, but it was good examples that really helped me.

I agree completely as a novice python programmer. I find examples that are either way to complicated for me to understand. Or in the case of the snap7 lib. I had amazing docs, but no examples so it was a little tricky to figure the structure out. I probably miss alot of stuff that is "assumed" by someone more experienced.
 
I'm unfamiliar with Omron, what protocols do your PLC's support? You seem to be referencing software rather than hardware. There are modbus libraries if they support modbus.
 
Github is usually my first stop for this kind of thing. Maybe summat here? But I'd be surprised if @dmroeder's modbus suggestion does not pan out.

Omron generally has Ethernet IP, FINS, and ETHERCAT. I dont know if their ethernet IP protocol is really the same as AB because they have their own version of EDS files that are different. I am going to do some hunting on github
 
I incorporated pylogix into an application but notice a couple of issues regarding a STRING tag I write to:
1. It is necessary that the PLC receives an updated tag value from my external python application within 400 milliseconds. Every few minutes I will see a 'blip' in communication where it may take much longer than 400ms for the PLC tag to update.
2. If I increase the write rate to ~ <50ms, the string tag in the PLC will lag in updating by about 600ms of time. I believe the PLC receives all the values, but a latency is introduced at this faster rate.

Are there known limitations on read/write rates? And can pylogix be used to read/write in a deterministic fashion or at a set RPI consistently? Are there network card optimizations recommended to improve read/write rates?

Thank you for your time.
 
I incorporated pylogix into an application but notice a couple of issues regarding a STRING tag I write to:
1. It is necessary that the PLC receives an updated tag value from my external python application within 400 milliseconds. Every few minutes I will see a 'blip' in communication where it may take much longer than 400ms for the PLC tag to update.
2. If I increase the write rate to ~ <50ms, the string tag in the PLC will lag in updating by about 600ms of time. I believe the PLC receives all the values, but a latency is introduced at this faster rate.

Are there known limitations on read/write rates? And can pylogix be used to read/write in a deterministic fashion or at a set RPI consistently? Are there network card optimizations recommended to improve read/write rates?

Thank you for your time.

What controller are you writing to? The data type you are writing shouldn't matter, there isn't anything special about the STRING type.

There are 2 things that come to mind when I hear "communication blip". The Ethernet module is near its max capacity already, or you are opening/closing the connection with each read/write.
 
1756-L73S controller. I saw in your example code that writes can be faster if the datatype is specified. I just now tried datatype=218 (STRING) but I end up in an error. Can you confirm the string datatype? Or maybe that doesn't matter.

I don't believe the ethernet module is near max capacity and I confirmed we are not opening/closing the connection with each read/write.

I will continue to explore as it may be something else in my code.
 

Similar Topics

Hello Guys, I want to establish profinet communication between siemens plc and my system using python programming. Which python lib can i use to...
Replies
12
Views
478
Hi! I'm trying to communicate with an old Kinetix 300 drive that is fully functioning. Is there any library I can use to monitor this drive with...
Replies
0
Views
441
Hi! I'm trying to communicate with an old Kinetix 300 drive that is fully functioning. Is there any library I can use to monitor this drive with...
Replies
0
Views
496
I have previously shared this elsewhere, so I apologize if you have already seen it. Here is a basic and quick introduction to Python for PLCs...
Replies
10
Views
2,274
Read and write the Tags direct using pycomm3 and LogixDriver. Just in case anybody wanted to know. Here's a sample: from pycomm3 import...
Replies
0
Views
813
Back
Top Bottom