Jump to content
pato7

OPC UA Labview Reading items and properties from excel sheet or text file?

Recommended Posts

Hello Guys,

I am a masters student at a German university now working on a research project and we are using OPC UA labview toolkit. I am new with using OPC UA in Labview so I am not sure to what extent are the capabilities OPC UA labview are similar to that defined by the OPC foundation. I hope I can get some tips and help on some issues. 

 

Normally through labview we can create an OPC UA server and add folders/ Items/Properties to create the data structure. But this is done manually by adding the vi for each folder and item and connecting them. This is reasonable if we have two or three items or properties in the data structure. But if we have for example 40 items, then it would get messy. So i am thinking of a way to read the data from an excel sheet or text doc and automatically create the data structure in the OPC UA server. Offcourse, the data in the excel sheet should be arranged in a special way so that we can create the node paths easily and define the characteristics( read/write, datatype) of each node automatically. so far i was able to create the OPC UA server but I am stuck on how to transform the data from the excel file to the OPC UA server.

please find attached the VI i have so far.

Any help would be highly appreciated.

THank you.

BEst Regards,

Elias

non-Secureconnections.vi

fileread.vi

Data2.xls

Share this post


Link to post
Share on other sites

Crosspost http://www.labviewforum.de/Thread-OPC-UA-Labview-Reading-items-and-properties-from-excel-sheet-or-text-file and http://forums.ni.com/t5/LabVIEW/OPC-UA-Labview-Reading-items-and-properties-from-excel-sheet-or/td-p/3295449

As to your specific question, standard LabVIEW only supports querying and updating OPC UA items programmatically. Configuration of them is manual. There is the LabVIEW DSC Toolkit which also supports some limited programmatic configuration of OPC UA items, but not as extensive as it supports the old OPC items.

Edited by rolfk

Share this post


Link to post
Share on other sites
3 minutes ago, rolfk said:

Thank you for your comment. I am just not getting any positive help on the other sites, thats why I am posting here... And now that you mentioned thats its a crosspost, I hope its cleared now...

Share this post


Link to post
Share on other sites

@rolfk Please note that I am deleting my cross post on the other sites and sticking to my posts on this website. THank you. Any help would be highly appreciated and Sorry again for the misunderstanding...

Best Regards.

Share this post


Link to post
Share on other sites

I can't really give you more help here than what I added in my last post. LabVIEW out of the box only supports querying and updating OPC items, configuration is entirely manual. If you want some programmatic configuration capabilities you need to either get the LabVIEW DSC toolkit or another 3rd party OPC UA interface library.

Share this post


Link to post
Share on other sites
On 5/14/2016 at 2:13 AM, pato7 said:

Normally through labview we can create an OPC UA server and add folders/ Items/Properties to create the data structure. But this is done manually by adding the vi for each folder and item and connecting them. This is reasonable if we have two or three items or properties in the data structure. But if we have for example 40 items, then it would get messy. So i am thinking of a way to read the data from an excel sheet or text doc and automatically create the data structure in the OPC UA server. Offcourse, the data in the excel sheet should be arranged in a special way so that we can create the node paths easily and define the characteristics( read/write, datatype) of each node automatically. so far i was able to create the OPC UA server but I am stuck on how to transform the data from the excel file to the OPC UA server.

I can't open your VIs as I don't have LabVIEW 2015, so I can't see what you've done. However, here are some quick tips:

Share this post


Link to post
Share on other sites
20 minutes ago, JKSH said:

I can't open your VIs as I don't have LabVIEW 2015, so I can't see what you've done

@JKSH Thank you for your reply. I have attached here 2014 Version files. Basically I have just created the server code and a read from file code but its still not integrated in the server code. I will try to work with CSV files and use the For loop method, Thanks for the advice. I am trying to find a way how to relate each item read to its corresponding folder and also if there's more than one item related to the same folder.

Thank you.

Data2.xls

fileread.vi

non-Secureconnections.vi

Share this post


Link to post
Share on other sites
1 hour ago, rolfk said:

 

I can't really give you more help here than what I added in my last post. LabVIEW out of the box only supports querying and updating OPC items, configuration is entirely manual. If you want some programmatic configuration capabilities you need to either get the LabVIEW DSC toolkit or another 3rd party OPC UA interface library.

 

@rolfk Thank you for your help. I already have the DSC module installed with my labview. Can't it be helpful for my task related to inputing my folders/items/properties from a CSV file?

Thanks

 

Share this post


Link to post
Share on other sites
13 hours ago, pato7 said:

@rolfk Thank you for your help. I already have the DSC module installed with my labview. Can't it be helpful for my task related to inputing my folders/items/properties from a CSV file?

Thanks

Well with the DSC functions you can create the OPC UA Items. Reading an ASCII formatted spreadsheet file is trivial and really should not pose any problems after reading the resources that JKSH has posted. Implementing the logic about grouping items according to their folder that is not really a LabVIEW problem but simply a classical programming problem about sorting/grouping items in a list. As such I'm not inclined to do the programming work for you. It's not fundamentally difficult but it is a lot of nitty gritty work to do for me just as well as for you and it's your problem to solve.:D

Share this post


Link to post
Share on other sites
1 minute ago, rolfk said:

Well with the DSC functions you can create the OPC UA Items. Reading an ASCII formatted spreadsheet file is trivial and really should not pose any problems after reading the resources that JKSH has posted. Implementing the logic about grouping items according to their folder that is not really a LabVIEW problem but simply a classical programming problem about sorting/grouping items in a list. As such I'm not inclined to do the programming work for you. It's not fundamentally difficult but it is a lot of nitty gritty work to do for me just as well as for you and it's your problem to solve.:D

@rolfk Thank you for your advice. Your advice and tips are more than enough for me and its highly appreciated. I never asked to do the programming work for me. I'll work by the tips I got here. THank you:)

Share this post


Link to post
Share on other sites
20 hours ago, pato7 said:

@JKSH Thank you for your reply. I have attached here 2014 Version files. Basically I have just created the server code and a read from file code but its still not integrated in the server code. I will try to work with CSV files and use the For loop method, Thanks for the advice. I am trying to find a way how to relate each item read to its corresponding folder and also if there's more than one item related to the same folder.

You're welcome :)

It looks like you already know how to use the OPC UA server VIs. So, what you need to do next is take the strings that you read from your file and pass them into those VIs (in a loop).

If you're new to LabVIEW programming, it's worth spending some time to learn LabVIEW properly. If your university has any LabVIEW training courses, attend them. Otherwise, see http://www.ni.com/getting-started/labview-basics/

Share this post


Link to post
Share on other sites

Thank you for your advice. Due to the limited time that I was given to finish this project, I am trying to read more tutorials and watch youtube videos to improve my skills faster. I have managed to write the code reading from text  file. And I have classified all information that I have read from the file. But I have two problems now:

1) In some cases, a Folder can have several items in it and an item can have several properties in it. So I thought of giving each node an ID and link it to its parent ID. 

My data is arranged in the following order in the text file :  ID,NodeType,ParentID,Name,DataType,Access Level,Description

Is there any blocks special for linking nodes to their parents? Or do you have any other solution for linking several items to the same folder?

2) I have added the OPC UA blocks (Add folder, Add Item, Add Property) in the for loop where I am reading from the text file and I have placed a condition depending on the type of the node But I am not able to relate all three together which can be fixed if I knew how to solve question 1. The problem is in creating the correct node path

Moreover, After exiting the for loop, I am getting an error while wiring the OPC UA blocks to the Start Server Block due to connecting two terminals of different types but I don't know if I can change the data type exiting the for loop without affecting the data structure created inside the loop.

You can find my files attached below. Any hint or tip would be highly appreciated.

Thank you.

 

ReadCSV.vi

Read.txt

Share this post


Link to post
Share on other sites
12 hours ago, pato7 said:

Is there any blocks special for linking nodes to their parents? Or do you have any other solution for linking several items to the same folder?

According to the CSV file that you posted,

  • The "parent folder path" that you need to use for your items is "Process". (This path is outputted by Add Folder.vi)
  • The "item path" that you need to use for your properties is "Process.Temperature". (This path is outputted by Add Item.vi)

 

13 hours ago, pato7 said:

Moreover, After exiting the for loop, I am getting an error while wiring the OPC UA blocks to the Start Server Block due to connecting two terminals of different types but I don't know if I can change the data type exiting the for loop without affecting the data structure created inside the loop.

You're using Indexing on your loop outputs. This creates an Array, which you probably don't want: http://digital.ni.com/public.nsf/allkb/B85025233861378A86256CE700491E34

Have a look at Shift Registers instead: http://www.ni.com/getting-started/labview-basics/shift-registers

Share this post


Link to post
Share on other sites
10 hours ago, JKSH said:

You're using Indexing on your loop outputs. This creates an Array, which you probably don't want: http://digital.ni.com/public.nsf/allkb/B85025233861378A86256CE700491E34

Have a look at Shift Registers instead: http://www.ni.com/getting-started/labview-basics/shift-registers

Thank you for the tip. It was very useful. I have managed to eliminate the errors I got before and I am working on the other issues now. Thank you for your help again:))

Best Regards

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.