Showing results for 
Search instead for 
Did you mean: 

Labview put the acquisition and processing in different while loops that exchange data

Go to solution



In fact, I have a vi that works on labview which consists of acquiring data thanks to a register placed on the big while loop and in the same loop, data is also processed(spectrum, display..). Now I have to separate both (acquisition and processing). I would like to put each one in a while loop and link them by the flow of data that I acquired. The problem is that the second one does need the data from the first while loop to be lunched. I had the idea to add flat sequence or even a cadenced loop but the problems are still not solved. So to sum up, the main problem is that the acquisition should stay in the while loop and the data should be transmitted to the second which retrieve it from lunching. The idea of putting the all in a flat sequence with two steps and put it in a while loop is to be banned because I need to keep.the acquisition in a whil loop.

Can you please give your suggestions. Its too urgent. Thank you.


0 Kudos
Message 1 of 14

Look at queues, channel wires, and user events to share data among loop. There are examples in the Example Finder. I would recommend channel wires for this task.



Message 2 of 14
Accepted by topic author Yasmine13579

What you are describing has been called the Producer-Consumer Design Pattern.  You have two independent loops, running in parallel.  One, the Producer, "produces" data at some rate (say, from a continuous DAQ input giving you an array of points every second).  The other, the "Consumer", acts on this data and "consumes" it (plots it, writes it to disk, does an FFT, etc.).


You need a method of getting the data from the Producer to the Consumer that "bypasses" the concept of Data Flow, letting the loops run independently.  Queues are the classical structure for doing this.  If you have LabVIEW 2016 or later, you can also use a Stream Channel Wire (basically a more mnemonic metaphor for a Queue).


If you open LabVIEW, click File, New ..., and choose "From Templates", there are two examples of Producer/Consumer Design Pattern Templates that you can study.


Bob Schor

Message 3 of 14

I know I'm a little late, but here is a decent article on the solution you need: Producer/Consumer

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 14

I thank you all for your suggestions. In fact, I have Labview 2016, so I do have the stream option and I used it. I saw the probs and data is actually transported from the first while to the second as I want but the problem is that my VI is aiming to work continuously which means that the memory should not be full. Now, this is the problem I have. Actually they told me that the memory is full because of the link I made between the loops. May be this is due to the type I used (stream), what type should I choose ? (tag, stream...). If with all those types I will absolutely have this problem what should I do to manage the problem. Then I had a question about how to empty the buffer memory in general because as the system is conceived as a demonstrator ( real time) the flow of data and their processing will absolutely cause this problem. Can you please give me your suggestions. 






I do not know how to empty the memory continuously 

0 Kudos
Message 5 of 14

Hello mcduff,


Many thanks.



0 Kudos
Message 6 of 14

Hello Bob_Schor,


Many thanks. Your response was so complete and detailed.



0 Kudos
Message 7 of 14

Hello crossrulz,

Many thanks, I posted another problem.



0 Kudos
Message 8 of 14



 I posted another problem.



0 Kudos
Message 9 of 14

@Yasmine13579 wrote:


 I posted another problem. 

You did?  This is the only one showing up in the LabVIEW Forum.  Has it been "solved"?  You haven't marked any of the responses as the Solution (doing so helps other Forum users who might have a similiar problem/question to know they can "find the solution").


Bob Schor

Message 10 of 14