LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing 2D Numeric Array to a Sub VI Using Refnum

Solved!
Go to solution

Hi All,

 

I want to pass a 2D numeric array to a sub vi which will then run when an event is triggered. I can do this easily for a numeric control (see example image), is there an equivalent method to do this with a 2D numeric array?

 

I think what I am missing is the correct class of refnum and the correct property node.

 

Thanks

Download All
0 Kudos
Message 1 of 8
(3,023 Views)

Hi Penguin,

 

what's wrong with your 2nd image? Where's your problem?

According to your screenshot LabVIEW shows no error…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(2,989 Views)

Thanks for the reply. It is the wrong data type I think, I want to pass the contents of the array which is a numeric.

0 Kudos
Message 3 of 8
(2,970 Views)

If you mean the type is an integer (blue) rather than floating point (e.g. Double, orange) then you can just change the datatype of the numeric control stored in the array in your calling VI.

 

You'll need to update the refnum control in the subVI after doing that.


GCentral
0 Kudos
Message 4 of 8
(2,944 Views)

Hi cbutcher, yes that is exactly it. I want to make this a double. When I connect this with a VI server reference in the top level VI, it errors because of the data type mismatch. Once I have connected the terminals how can I change the data type on the refnum control? Should I simply use a numeric digital control or does it need to be set as a array and configure it as a double?

 

If you can make a quick example that would be extremely helpful!

 

Thanks!

0 Kudos
Message 5 of 8
(2,913 Views)

Hi Penguin,

 

create your array as needed, including correct datatype.

The right-click the array and create a refnum constant in the block diagram.

Right-click the refnum and create a control from it. Move this control to whereever you need it…

 

(There are other ways too, but that should get you started…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(2,903 Views)
Solution
Accepted by topic author QuantumPenguin

On your Block Diagram (either is fine, probably easier from subVI) create an array constant. Place inside a DBL constant. Add a dimension by right clicking and clicking Add Dimension. You now have a 2D dbl array.

 

Right click on this (constant) 2D dbl array, and click Change to Control. If you create the array on the front panel, you probably don't need to do this, but then you need to change between BD and FP at different steps. On the (control) 2D array, right click and Create > Reference. Right click on the reference created and click Create > Control. Now you have a control version of a 2D dbl array refnum. Link this control to the connector pane.

 

In the main VI, you can now wire a reference to a 2D dbl array, and in the subVI, your Value property should return a 2D array of doubles.


GCentral
0 Kudos
Message 7 of 8
(2,901 Views)

Wonderful, thank you very much!

0 Kudos
Message 8 of 8
(2,887 Views)