# Reading large block of data with OPCUA

**URL:** <https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [October 17, 2020, 7:11am UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774 "2020-10-17T07:11:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mori.luca](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mori.luca/32/13424_2.png) [@mori.luca](https://forum.inductiveautomation.com/u/mori.luca)\
**Post date:** [October 17, 2020, 7:11am UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/1 "2020-10-17T07:11:51Z")

</div>

Hello,  
I was wondering about what is the best way to read large block of data from a plc, in my case Siemens s7-1500 (using integrated OPCUA Server).

I have an UDT definition on my PLC looking something similar to this :

```auto
MyUdt:

Id --> int
Name --> String(20)
Code --> String(20)
p1 --> Int
p2 --> Int
p3 --> long
p4 --> bool
p5 -->bool

```

The above UDT is instantiated 50 times in lets say DB5.  
DB5 starting from byte 0 has inside 50 UDT, not inside an array, just single UDT one after the other like this :

```auto
DB5 :

MyUdt_1
MyUdt_2
MyUdt_3
...
MyUdt_50

```

It happens that I need to read all of them, to perform some logic and then write them back.  
At the moment, in order to perform a read action, I prepare my array of single tags,  
then i call the [system.opc.readValues](https://docs.inductiveautomation.com/display/DOC80/system.opc.readValues) and i have, after few seconds, the values i was looking for.

I need to perform an OPC direct read as I can’t manage to subscribe to this tags, otherwise I will saturate the s7 Opcua Server.

I remember using opensource DotNet DLLs to interact with Siemens PLC, and i was able to perform a block read lets say from DB5 byte 0 - 20000, and then when i had that array of bytes , i had to parse them to recreate the desiderate structure of data.

From my understanding, this reading method should be more efficient.  
Correct me if I’m wrong, but event if i send a [system.opc.readValues](https://docs.inductiveautomation.com/display/DOC80/system.opc.readValues) instead of the system.opc.readValue, the request to the PLC is only one, but still the cpu has to search for every single tag i requested.(And i don’t find a way to register this Nodes on the Siemens OPCUA Server : [Registered reading of OPCUA server](http://forum.inductiveautomation.com/t/registered-reading-of-opcua-server/28160))

Is there any way, and if there is could you point me at some docs, to accomplish the same task?  
My aim is to read the DB5 data as quick as I possibly do, and give to Ignition the task to parse the data.

Thank you for your time

---

<div class="post-metadata">

**Author:** ![roland.scheuer](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@roland.scheuer](https://forum.inductiveautomation.com/u/roland.scheuer)\
**Post date:** [October 17, 2020, 8:31am UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/2 "2020-10-17T08:31:04Z")

</div>

Hi,

what about the Siemens Driver ignition have?

Br,  
Roland

---

<div class="post-metadata">

**Author:** ![mori.luca](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mori.luca/32/13424_2.png) [@mori.luca](https://forum.inductiveautomation.com/u/mori.luca)\
**Post date:** [October 17, 2020, 8:36am UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/3 "2020-10-17T08:36:47Z")

</div>

Hi,  
Thanks for your reply.

My aim was to understand if there is a way to that same thing using OPCUA.  
Maybe something to do with XML files, or something like that.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 17, 2020, 12:59pm UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/4 "2020-10-17T12:59:27Z")

</div>

When you read these 50 UDT instances are you requesting just the 50 top level UDT tags or are you requesting all of the member tags as well?

---

<div class="post-metadata">

**Author:** ![mori.luca](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mori.luca/32/13424_2.png) [@mori.luca](https://forum.inductiveautomation.com/u/mori.luca)\
**Post date:** [October 17, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/5 "2020-10-17T16:54:49Z")

</div>

Hi Kevin,  
Sorry I think I misunderstood your question.  
At the moment I request all of the tags of each udt, so yes I’m requesting all members values.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 17, 2020, 8:30pm UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/6 "2020-10-17T20:30:08Z")

</div>

That’s going to be much slower than requesting only each top level structured value instead, at least if you are using the OPC UA server built in to the S7-1500.

When reading a structured value it will be received in Ignition as a JSON object, containing all the member values and any member structs as embedded JSON objects modeled the same way.

---

<div class="post-metadata">

**Author:** ![mori.luca](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mori.luca/32/13424_2.png) [@mori.luca](https://forum.inductiveautomation.com/u/mori.luca)\
**Post date:** [October 17, 2020, 8:49pm UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/7 "2020-10-17T20:49:35Z")

</div>

Ok thanks,  
I will try this approach instead.  
I imagine I can write the udt back to plc by passing as a value to be written a JSON right?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 17, 2020, 9:09pm UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/8 "2020-10-17T21:09:22Z")

</div>

Yes, you just have to make sure you maintain the same overall structure.

The UDT and every one of its members need to have Read Write permissions. If even a single member has Read Only permissions the write will fail.

---

<div class="post-metadata">

**Author:** ![mori.luca](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mori.luca/32/13424_2.png) [@mori.luca](https://forum.inductiveautomation.com/u/mori.luca)\
**Post date:** [October 17, 2020, 9:21pm UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/9 "2020-10-17T21:21:15Z")

</div>

Thank you very much Kevin, tomorrow I will try this out.

---

<div class="post-metadata">

**Author:** ![mori.luca](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mori.luca/32/13424_2.png) [@mori.luca](https://forum.inductiveautomation.com/u/mori.luca)\
**Post date:** [October 23, 2020, 12:33pm UTC](https://forum.inductiveautomation.com/t/reading-large-block-of-data-with-opcua/39774/10 "2020-10-23T12:33:08Z")

</div>

Hi Kevin,  
I did try the method you pointed out, and it drastically reduced reading time on my S7-1500 integrated opcua server.

Before, using the opc.readvalues with the array of tags, i had the replay from the plc in about 35 seconds, reading something like 100 strings.

Now, by reading the 50 udts i read the string i need, plus like 150 more values per udt so the amount of data being read from the PLC is way more than before, and i get my data back in something like 3 secs.

Thank you for your time
