You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on an application that requires a tag value to be updated very frequently. Currently I'm using the following to read the tag, but it still takes about 250 [ms] to read the tag. Are there any ways to improve the read time? Ideally it would be < 50 [ms].
Thanks!
from pycomm3 import LogixDriver
import time
def read_single():
with LogixDriver('192.168.0.20') as plc:
return plc.read('ZoneCount')
st = time.time()
ZoneCount = read_single()
et = time.time()
get the execution time
elapsed_time = et - st
print('Execution time:', elapsed_time, 'seconds')
print(ZoneCount)
The text was updated successfully, but these errors were encountered:
In your read_single method, you're creating a new driver every time which has a lot of overhead. When the driver first connects, it uploads the tag list and all of the data types from the controller. This is so that it can optimize the reads based on tag size and allows reading full structures (like UDTs, AOIs, and builtins). You should try creating a single driver instance and reusing it each time, it will probably be much faster that way.
Another optimization would be to read multiple tags at once, since it will be able to use fewer messages by packing them together in a single request. Or if you're reading from an array or UDT/AOI, it can read the whole array/structure at once instead of individual attributes across multiple requests.
Hello,
I'm working on an application that requires a tag value to be updated very frequently. Currently I'm using the following to read the tag, but it still takes about 250 [ms] to read the tag. Are there any ways to improve the read time? Ideally it would be < 50 [ms].
Thanks!
from pycomm3 import LogixDriver
import time
def read_single():
with LogixDriver('192.168.0.20') as plc:
return plc.read('ZoneCount')
st = time.time()
ZoneCount = read_single()
et = time.time()
get the execution time
elapsed_time = et - st
print('Execution time:', elapsed_time, 'seconds')
print(ZoneCount)
The text was updated successfully, but these errors were encountered: