LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass data out of a While loop each execution

Hey guys,

 

I'm trying to create a measurements subVI. Everything in it is working good. However, I want to be able to pass 4 arrays out of each execution of a while loop.

 

I've attached my VI. The 4 arrays are labeled,  ES441 Ch1 Display, ES441 Ch2 Display...etc. I want this subVI to be able to pass the values in the main VI were I can then take these values and update them on a graph. Any help you guys can give me would be great.

 

Thanks in advance.

 

-Brad

0 Kudos
Message 1 of 6
(9,045 Views)

There are a couple of ways of accomplishing this.  Unfortunately, I do not have LV8.5 installed on this PC, so I could not look at your code. 😞

 

Easiest Method:  Create an ActionEngine which receives the array values.  You can also set a flag to state that data is available.  You use this ActionEngine to write the data in the sub-vi and to read it in the main vi.  This is useful, especially if you have lots of code already written and do not have the luxury of doing the next method.

 

Better Method:  Implement a queue that passes data (arrays) from the sub-vi to the main vi.  You create the queue in the main vi and send the queue reference to the sub-vi.  Basically a Producer / Consumer arrangement, where the consumer loop is inside your main vi.  I have an example of this posted on this forum (somewhere).  I will look for it and post a link to it.

 

R

Message 2 of 6
(9,043 Views)

Here is the link to the example

 

You'll have to implement the data from the sub-vi to the main vi.  The example goes from the main to the sub..  The concept is the same. 

 

Also read the other posts in the thread as they discuss something very similar.

 

R

Message Edited by JoeLabView on 08-25-2008 11:19 AM
Message 3 of 6
(9,039 Views)

JoeLabView wrote:

There are a couple of ways of accomplishing this.  Unfortunately, I do not have LV8.5 installed on this PC, so I could not look at your code. 😞


It's a good thing otherwise your first response would have been: get rid of those local variables, which I will say in your place. Smiley Wink

 

Get rid of those local variables. They are completely unnecessary. Use shift registers instead. Also, if you use data dependency then your outer sequence structure can be eliminated.  

Message 4 of 6
(9,031 Views)

Hey guys thanks for your responses.

 

So far I'm not fully sure I understand both of those concepts. I've only been programming with LabVIEW for about 7 weeks now so I'm not the most experienced of LabVIEW programmers.

 

I think that an AE would be the best solution for me but let me elaborate a little bit more on what exactly my program is try to accomplish.

 

Right I'm trying to create a data acquistion program that integrates with some hardware drivers that were made by a third party company. Currently in order to acquire data from the devices you must first Initialize them and then start measuring. So I've decide that I'm going to create 2 VI's for each of those tasks. In the measurement VI, which is the VI I've posted, (specifically for one device) I want to be able to acquire all of the data and capture it into a 2 dimensional array. This can then be passed out of the VI when it is done executing. This leads me to my problem.

 

Each channel has 8 pieces of data contain in a one dimensional array. I want to be able to send the data from the subVI out to my mainVI each time the while loop executes. 

 

I think that using an AE would solve this problem for me, however this leads me to another question.

 

My program is going to setup in such a way that, there is going to be support for up to 8 of each of the 4 devices. Each of the devices will have its own array of data just like in the subVI I posted. This could in total lead up to 56 arrays that need to be passed out of the measurment VI's. So my question is,

 

Is it possible to create one AE that could handle all of this data and then pass out one complete 2 dimensional array with ALL my data in it? For instance it would pass out an array were the first 8 columns are for 8 of the first device, the second set of 8 column is for 8 of the second devices etc...

 

Hopefully I haven't lost you. Perhaps you can give me some suggestions. Maybe an AE is not the way to go? This program needs to be capable of handling a lot of data so any suggestions you guys could give me would be great.

 

Again thanks in advance.

 

PS I've also posted a newer version of my VI's that doesn't include so many local variables, thanks for the tip on that one.

 

-Brad

 

0 Kudos
Message 5 of 6
(8,992 Views)

You can write the AE to handle all your devices. Your best bet is to have an "Init" state for the AE where you initialize the array that will hold all of the data for all your devices. This way when you provide the data for a specific device to the AE you're simply doing an array subset replacement, which is much more memory efficient.

 

One thing that's not clear from your measurement VI is how it's supposed to be stopped. You have the while loop set up to stop based on a front panel "Stop" button, but this button is not visible. Also, the control that's driving the case structure is hidden.  

Message 6 of 6
(8,974 Views)