LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass data.

I am generating data in one of the while loop.  I want to pass this data to 3 sub vi's which have while loop inside.  I am planning to use global variables.  But, it will affect the performance of the VI. 
Is there any better to do this.  or can i use an array or cluster of one global variable to do this operation so that i can reduce the # of global variables.Smiley Happy
0 Kudos
Message 1 of 23
(5,329 Views)
Use Notifiers
 
In examples shipped with LabVIEW, search for a VI called 'Pass data with Notifiers,.vi'
 
This will do just what you have illustrated
Any doubts, do ask
 
Regards,
Dev
Message 2 of 23
(5,322 Views)
Also, in your sub vi you could use reference to indicator on Main VI
Message 3 of 23
(5,310 Views)
Thank u
0 Kudos
Message 4 of 23
(5,305 Views)
hi Dev,
Can u explain little bit more about using reference of indicators in sub vi's.
 
-Visswa
0 Kudos
Message 5 of 23
(5,304 Views)
look at these vi's
Download All
Message 6 of 23
(5,293 Views)

hi,

I am able to pass the data from the main VI to sub VI using reference.  but, i don't know how to send data from sub VI to Main VI using reference.  if it is not possible can u suggest me any other way of doing this.

-Visswa

0 Kudos
Message 7 of 23
(5,261 Views)

Create an indicator in main vi.  Right click on indicator and click on Create - Reference.  The reference appears on the block diagram. 

In your subvi, create a Control Refnum on the front panel.  In block diagram, right click on Ctl Refnum and select Create -> Property -> Value.  Right click on Value property and select Change to All Write.  Wire Ctl Refnum to top terminal of Value property.  Wire whatever indicator you want to transfer to main to the value property through a To Variant function.  On front panel, wire the Ctl Refnum to a terminal in the connector pane.  Save subvi.

Back in main, add your subvi on the block diagram.  Wire the Reference to the subvi connector pane terminal for the Ctl Reference.  Whenever the subvi is run and the indicator data changes, you will see it change on the main front panel indicator.

According to NI, Labview has no pointer data type.  But the Reference is just that, a pointer.  By passing the pointer of your main indicator to the subvi, and changing its value there, the subvi is writing to the same memory location as the main vi indicator, so it shows up instantly in main.

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 23
(5,244 Views)
Hello!
Thanks tbob. I did what you said and it still doesnt work. Is there something else that I should check? Are the locations of the  Mainvi and a Subvi a factor?.
Actually, I got it working last week but my coworker moved files around. Now it just doesnt want to work. Any ideas?
Thanks!
Andrea - Software Developer
0 Kudos
Message 9 of 23
(4,958 Views)

Almost a year has past since my last post and your new one.  Were you on vacation that whole time?Smiley Very Happy

You said that you got it working last week, and now after files were moved it doesn't work anymore.  Put the files back where they were.  The main vi has to know where the subvi is.  I would need to see your code to see how you call the subvi.  If you call it by reference, and you have moved the subvi, you have to change the path of the subvi in the main.

If you call the subvi by its icon, and you move the subvi, the icon should be a grey question mark if the main can't find it.  Then you have to right click and select Replace, and find the subvi.  If the icon looks OK but is grey, right click on it and select Relink to Subvi.

Message Edited by tbob on 09-26-2007 03:53 PM

- tbob

Inventor of the WORM Global
0 Kudos
Message 10 of 23
(4,939 Views)