LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

signals from multiple VIs

I have two VIs and I would like to take a signal from one of the VIs and use it in the other VI without having to combine both VIs into one.  Is there a way to do this?
0 Kudos
Message 1 of 13
(4,198 Views)
You can use global or shared variables to do this.
 
You can also use references.

Kudos are the best way to say thanks 🙂
0 Kudos
Message 2 of 13
(4,194 Views)
Look at the examples (Help menu> Find Examples) for Queues and Notifiers.

Another possibility is a VI setup with uninitialized shift registers commonly called a "Functional Global". Just do a search here and you'll find a lot of information on what they are and how to use them.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 3 of 13
(4,189 Views)

Other options include using notifiers, queues and action engines depending on your applications needs.  You can find some good examples by searching for 'producer consumer' and 'master slave' architectures.

A global variable is the easiest method to implement but it has limitations when more than one source writes to it (potential race conditions). 

K

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 4 of 13
(4,187 Views)
The variable I want to pass to a different VI is part of a 2D array.  Can I seperate it out and then pass it through a global variable?  If so, how do I seperate it out?  If not how could I seperate it out and pass it?
0 Kudos
Message 5 of 13
(4,173 Views)
Use the "Array Subset" function from the Array palette to get the section of the 2D array you need to pass. This can then be written to whatever mechanism you choose to pass the data.

As others have stated, Global Variables have the potential to cause problems. Queues and Notifiers are a good way to go and are really not that difficult to implement. With Queues, you can buffer data so your receiving VI will not miss anything in case it runs slower than the sending VI. Both Queues and Notifiers can be implemented so the receiver can "sleep" until data is available so it takes no CPU time.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 6 of 13
(4,170 Views)

I am trying to write a small peice of code to figure out how to use Queues.  In the large code I am writing I already have the DAQ working,however, that program is complicated and unnesecary.  In the code I have attached, besides the DAQ not working, it gives me the error. 

Enqueue Element: contains unwired or bad terminal.

What do I need to fix with the Queue to get it to work?

0 Kudos
Message 7 of 13
(4,149 Views)
You use queues in much the same way you use DAQ. Open a reference, read or write, close.



In this simple example, you see one loop reading the DAQ and writing the data to a queue and the other loop reading the data from the queue. The problem with your example is that on your Enqueue Element function, you don't have anything connected to the "Element" terminal. If you turn on the context help window (Ctrl+H) and place your cursor over that function, you see the Element terminal is listed in bold text. ALL BOLD terminals on subVIs and functions MUST be wired.

You should always have your "Obtain Queue" function outsied the loop and pass the reference into the loop to the "Enqueue" and "Dequeue" functions. Both of the "Obtain Queue" functions in this example will open a reference to the same queue because they are using the same "Name" on the Name terminal.

Ed

Message Edited by Ed Dickens on 05-05-2006 08:20 AM



Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 8 of 13
(4,143 Views)
Can the second loop, the one taking the value off of the queue, be done with a for loop?  I tride this and I got an error.  Also, I am trying to use the value that I pull off the queue to build an array, however the data type is wrong, so this also gives me a couple errrors.  Any suggestions?
0 Kudos
Message 9 of 13
(4,131 Views)
Yes, the receiver can be a For loop. It can be anywhere as long as you have everything configured correctly.

Anytime you have a broken Run arrow and you don't know why, go ahead and click on it and you will get a dialog that shows all the problems in the VI that are causing it not to be ab;e to be compiled. If you double click on one of the entries, the problem will be highlighted on the diagram. Give it a try.

The attached VI is an attempt to fix it. The main problem was that you are attempting to build an array with 3 numerics and on 2D array. This does not work. You need to do something to the 2D array first. I inserted a "Reshape Array" function to convert it to a 1D array. This is only a guess because I don't really know what you are trying to do. The other problem is that the For loop is building an array of the queue references on the right border where it's going out of the For loop. Arrays are automatically built for data leaving a For unless you manually change the behavior. Just right click on the tunnel and select "Disable Indexing". Notice now the tunnel is a solid block indicating that no array will be built and the wire going to the Release function is now not broken.

A lot of this is basic information for LabVIEW. It sounds like you could use to run through some tutorials to get up to speed on the basics. Here's a few good ones.
LabVIEW Graphical Programming Course - This is really the LabVIEW Basics 1 & 2 classes.
From the Uni. of Toronto
LabVIEW for Dummiees from the Illinois Institue of Technology
3 hour Introduction to LabVIEW from NI

Ed




Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 10 of 13
(4,123 Views)