LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Output data from subVI to main program

Solved!
Go to solution

Hello,

 

I am trying to output data from subVI to the main program in real time. But I found the the value can be only trasferred when the subVI is finished.

I make some research and I think using queue is the best, but global variable.Can you any give me some tip on using queue to transfer data from subVI to the main program in real time?

 

Thank you!

0 Kudos
Message 1 of 10
(6,063 Views)

I would need to see your VI in order to advise you which data transfer mechanism would be best for your scenario but I'll try to answer your question about queues.

 

A queue is a reference based object in LabVIEW, this breaks data flow in LabVIEW as passing the queue wire around does not pass the actual data. In order for you to get the data in "real  time" as you say, then your sub vi must be in parallel to the other code in your main VI. LabVIEW 2012 ship with a really good example of this, called the "Continuous Measurement and Logging" Sample project. This should give you an idea of how to have multiple asynchronous pieces of code communicating through queues.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
Message 2 of 10
(6,060 Views)

Basically, the subVI can measure Vout in a loop and I want transfer those data to the main program and also display them on UI.

 

Thanks !

Download All
0 Kudos
Message 3 of 10
(6,054 Views)

The EASY way to get what you want is to pass a reference to the indicator on the Main block diagram to the SubVI. The SubVI can use this reference to update the Main front panel programmatically. Follow these steps:

  1. On Main.vi block diagram, right-click the control terminal and choose "Create" -> "Reference"
  2. Right-Click the newly created reference and choose "Create" -> Control
  3. Cut the newly created control and paste it into the SubVI
  4. On the SubVI's newly pasted control, right-click and choose "Create" -> "Property" -> "Value"
  5. Use this property node in the SubVI where you would normally use a native indicator

**Disclaimer** Please note that I said this is the easiest way. From what I can see of your code, it would benefit from a complete restructure to utilize a standardized architecture.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 4 of 10
(6,017 Views)

Additionally, if you have many values you want to pass, consider creating an array of your references and then pass only the array. This way you can avoid numerous having endless inputs in your sub VI.

 

Im wondering now, what is the problem with using a global variable to pass the data? Is there a time delay?

Best regards!

0 Kudos
Message 5 of 10
(6,008 Views)

Hi Charles,

 

Thank you for your answer.

But I am confused what do you the "control terminal"?

Also I followed your step, I can only create anther control but not a indicator.

 

Thanks !

0 Kudos
Message 6 of 10
(5,977 Views)

When you place a control/indicator on the front panel, it also places a terminal on the block diagram. This block diagram terminal is the terminal that has the "Create" -> "Reference" right-click menu option.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 7 of 10
(5,970 Views)

Hi Chales,

 

I am still kind of confused your steps.

I just made a simple program and followed your steps. Do you mind to point out the error?

 

Thanks !

Download All
0 Kudos
Message 8 of 10
(5,960 Views)
Solution
Accepted by topic author tian66

No problem. 

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
Download All
Message 9 of 10
(5,947 Views)

Thank you. It works!

 

In your step 4, I should choose " creat the property node for digital class" but not the "value".

Kudo is given.

0 Kudos
Message 10 of 10
(5,940 Views)