Read bulk tags from one PLC & write to another PLC. SLOWWW!

Hi,

I am trying to read and write 256 tags via Ignition, each of which is of DOUBLE data-type. Hence each tag is a QWORD. These are mapped to PLC and using Modbus TCP protocol.

What I am trying to do is :
a. Read values from 256 tags mapped to PLC-A into Ignition (using system.tags.readAll() function)
b. Write these values into 256 tags mapped to PLC - B from Ignition (using system.tags.writeAll() function)

However just the task of writing into 256 tags of PLC-B takes as much as 1.5 secs!
I would like to know how I can improve this? The most that I could write as a single tag is by associating it with a QWORD. Is there a way to add user defined data types to tags of larger size than a QWORD?

Thanks!

It might be a little quicker if you used system.opc.read/write instead of system.tag.read/write.

After that, since this is Modbus, it would be best to make sure all holding registers and coils you are using are packed as tightly together as possible.

Hi Kevin,

Thanks for the suggestion. I did use system.opc.read/write but it did show little improvements. In a few sequences of read/writes that I did, I got a maximum of 0.9 secs which is still a considerable amount.

I am using only holding registers and it is a contiguous memory block.

I also wanted to know the influence of following points:

a. My laptop is my Ignition server, so the effects of background applications and services running on my laptop
b. The number of tags and the size of each tag
c. Is it possible to allocate a big block of memory like 1000 registers to one tag? Like a user defined data type rather than being limited by a QWORD. Then read from that one tag on PLC-A and write to a similar large sized tag in PLC-B. Will this even be helpful in performance if the read/write process involves just one tag at each end?

Thanks!

This should have no meaningful effect. The only thing to really check would be the network latency between your laptop and the two PLCs.

As long as the registers used are contiguous, this will not change anything.

No, you can't allocate a tag like that, and even if you could it would not change anything (see #2).

The driver will do the best it can to read/write blocks, which is why it's important to make sure your registers are all contiguous.

It might be helpful if you could capture the whole exchange with Wireshark so we can make sure it's happening in the fewest amount of requests possible.

Hello Kevin,

I am seeing that my python script which just directly writes to the PLC takes a significant amount of time if I write just 2 words(tags) or 1024 words(tags).

tagpaths = ["[c_plc]A1", "[c_plc]A1021"] values = [1, 1] system.opc.writeValues(server,tagpaths,values)

Of course in the case of writing to 1024 words, I have to create an array of 1024 values and the same for tagpaths that I am writing to.

So for writing from Ignition to plc for 2 words takes ~3ms but for 1024 it takes ~500ms. So I have a very rookie question on this, does it mean that my Python script is taking a very long time to write to all those 1024 words since it is a scripting language and that is what is making it slow?

To get around that, is it true if I had the same code in a pre-compiled format it would not take so long to complete this task?

Thanks!

[quote=“pratul”]Hello Kevin,

I am seeing that my python script which just directly writes to the PLC takes a significant amount of time if I write just 2 words(tags) or 1024 words(tags).

tagpaths = ["[c_plc]A1", "[c_plc]A1021"] values = [1, 1] system.opc.writeValues(server,tagpaths,values)

Of course in the case of writing to 1024 words, I have to create an array of 1024 values and the same for tagpaths that I am writing to.

So for writing from Ignition to plc for 2 words takes ~3ms but for 1024 it takes ~500ms. So I have a very rookie question on this, does it mean that my Python script is taking a very long time to write to all those 1024 words since it is a scripting language and that is what is making it slow?

To get around that, is it true if I had the same code in a pre-compiled format it would not take so long to complete this task?

Thanks![/quote]

I’d guess that you’re waiting on network I/O, not python. If you get the wireshark capture of the exchange it would be easier to see what’s going on.

Hello Kevin,

So what should I try to capture using wireshark. And what should be a flag to prove a network latency, if I start monitoring the network on which I have my PLCs and Ignition running?

How should the setup of using wireshark look like?

Thanks!

You would run Wireshark on the same machine as the gateway, start the capture, execute your script, then stop the capture. Afterwards you can filter down to the results and see what requests are being sent to the Modbus controllers and how long a response is taking to come back.

The lengths of time to transmit 16-bit values sounds suspiciously close to the pace one would expect for a true serial or modem connection in the 38.4k to 56k bps range. What hardware is at the end of this connection?

Hello Kevin,

I have the wireshark capture as shown below. As you can see the write to PLC from ignition starts from packet No. 713 and the writing of all 1024 registers is completed with packet No. 1225. Total set of 256 queries and responses corresponding to 256 tags.

The time stamp for packet 713 is 4.303755 sec and the last packet 1225 is 4.733259 sec which is 0.429 secs for writing to all registers.
Do you think this is normal? Or you want me to capture something else too?

Thanks!

Hello Phil,

I am running Ignition on my laptop and connected to 2 PLCs. I am trying to understand performance of Ignition in a test setup to read a bunch of tags from one PLC and write it to the other PLC tags.

But for my current setup I am simply writing hard-coded values from an array of 256 elements in Ignition into 256 tags in PLC.

-Pratul

Can you attach the pcap file?

Kevin, I tried to attach pcap file but the forum does not allow me to attach files of pcap extension.
Is there any other way I can send it over to you?

Send it to the support email address.

OK I just sent it to the support email address.

Can you share the script you’re using when writing the 1024 values? If you’re writing them all in one call to system.opc.write I think there may be something wrong on our side, causing more requests than necessary to be used to issue all the writes.