LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview subVI - Array input/output

Hi All,

 

Bit of a newb when it comes to Labview. This is my first time using subVIs and I am a bit stuck on arrays. Refering to the screenshot below, I have a couple of questions that I hope someone can could provide some guidance on.

 

 

Question 1

I have highlighted 6 numbers in a green box. These numbers are contained in an array in the mainVI, ideally I would like to input that array directly into the subVI instead of inputing each number/element individually. I have played around for the last hour and read online and I have got no where.

 

So basically instead of have each individual number listed seperately in my subVI I would like to draw straight from the array in my mainVI.

 

Question 2

Along the same lines as question 1. The last operation in the sub VI multiplies two arrays and the product is obviously an array. How do I output this array to my main VI?

 

What I did previously was create a numerical indicator for each element and output that to the mainVI and then rebuild the array in the main VI.

 

 

I have tried the flatten to string option, but I wasnt able to unflatten it. I am sure the solutions to my issue are not complex and I hope that someone can point me in the right direction.

 

 

Thanks for your time and help.

0 Kudos
Message 1 of 5
(13,667 Views)

Not sure how to edit my post about, but I managed to get flatten to string/unflatten string to work so question 2 is answered, still stuck with question 1

0 Kudos
Message 2 of 5
(13,661 Views)

Hi,

 

You can just pass the array of numbers instead of passing the numbers individually. Check the attached example. It must explain it to you.


Regards,
Nitz 

(Give Kudos to Good Answers, Mark it as a Solution if your problem is Solved:smileywink:)  

0 Kudos
Message 3 of 5
(13,660 Views)

Hi,

 

Adding to this, in some cases you may need to pass elements of different types (string, numerical, boolean, etc.) to another VI. In such cases, you can bundle all of them into a cluster and send it to the SubVI and later unbundle and use it in the SubVI.

Regarding editing a post, you can go to the Options  given on the top right side of your post and then select Edit Reply.:)


Regards,

Nitz

(Give Kudos to Good Answers, Mark it as a Solution if your problem is Solved:smileywink:)  

Message 4 of 5
(13,659 Views)

DANG11,

 

I suspect you may be doing more work than you need to do.  By my reading of your diagram your goal is to input an array of numbers and a threshold (F).  If any of the values in the array are greater than F then you would like to multiply them by 0.5 and output the resultant array.

 

Off the top of my head there are two easy ways to do this that don't require breaking the elements out one by one (which is generally a bad idea, it takes longer to wire up and can cause problems when you need to pass 7 elements next time).

 

1. Use a For Loop to iterate through the array elements:

 

For Loop Implementation.vi.png

(the False case just has the Array In element wired straight through)

 

or

 

2. Keep everything as arrays and use a little logical/mathematical trickery (T/F can be converted to 1/0, adding 1 to that gets us 2/1, dividing by 2 is the same as multiplying by 0.5, dividing by 1 doesn't change the result)

 

No Loop Implementation.vi.png

 

Hope this helps.

 

~Simon

 

 

Download All
0 Kudos
Message 5 of 5
(13,637 Views)