LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sample code how to define OPC UA item using array of floats

I am fairly new to using LabVIEW and OPC UA Tookit 2017. I would also not consider myself a LabVIEW expert but I feel like I generally know to use it. 

 

Anyway, I can't figure out how to create an OPC UA item using "Add Item VI" for array of float. I can create it but only with one item, I need to add more elements within the array and change the value. Can someone provide sample or guidance how to achieve this?

 

References:

OPC UA ToolKit - http://sine.ni.com/nips/cds/view/p/lang/en/nid/215329

 

//YxH

0 Kudos
Message 1 of 4
(3,811 Views)

Can you show us the VI you have so far? The Add Item function has an input "Item" which is a cluster with an element "data type" with one of the options being an "Array of Float". This will define the item in the server but not give it any value. For that you will need to use the Write.vi function in the same palettes and select float array from the selection menu.

 

To my knowledge there isn't a way to write to individual elements within that array (if you do get that working please let me know) so when you want to update a value within the array you have to write the entire array.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 4
(3,789 Views)

Matt,

 

Let me share two VIs then.

* Data Access Server-v3.vi - this is a sample of getting input (INPUT1) data from somewhere and just put the data back to OUTPUT1.

* Data Access Server-v4-ArrayDataType.vi - What I am hoping to achieve here is to define an output (of type float array say with 10 rows) and an input of float array to pass data, same as above.

 

RE: For that you will need to use the Write.vi function in the same palettes and select float array from the selection menu

To Write, don't I need to define the size of the array first?

//YxH

Download All
0 Kudos
Message 3 of 4
(3,787 Views)

Hi YxH,

I don't think you need to explicitly define the array size, as that portion of the OPC UA communication appears to be taken care of by the toolkit. You should simply need to change the read/write polymorphic VIs to Arrays instead of Scalars. 

 

That is, LabVIEW and OPC UA Toolkit will use the array size of the array you write and handle things in the background rather than forcing you to explicitly define the size. 

I may be missing something here, as the documentation doesn't call this out explicitly. That being said, I can't find anywhere that explicitly requires an array size to be defined. 

Charlie J.
National Instruments
0 Kudos
Message 4 of 4
(3,762 Views)