LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Solved!
Go to solution

Hello,

 

It is done. should I open a new discussion about the memory problem?

 

Yasmine

0 Kudos
Message 11 of 14
(595 Views)

Sorry, Yasmine, I didn't see your response about trying Streams and saying "they told me that memory is full because of the link I made between the loops".  

 

I suspect there's a problem with your code, but cannot tell because you didn't post it.  If I had to guess, you might have connected the Producer and Consumer loop together by using the Error Line.  This is absolutely the right thing to do when you have a serial set of routines, but when you are dealing with a parallel architecture such as Producer/Consumer, you want the Loops to be truly "independent" and running at the same time.

 

Here's a Snippet of a Demo that I'll also attach as a LabVIEW 2016 VI (the Snippet is 2018).

PC Stream Demo.png

To emphasize parallel loops (and to see that there are no horizontal wires, like the Error Line, connecting them), I like to "stack" them vertically.  The Producer is on top -- once a second, it generates a "noisy sum-of-sines waveform" and streams it to the Consumer.  The Consumer (on the bottom) just displays the data on a Waveform Chart.  The Consumer needs to run "faster" than the Producer (on average), but that's usually easy to do, and especially so here.

 

This also shows another nice feature of Streams, the built-in Sentinel feature.  When the Stop button is pressed, the True case of the Producer Loop puts an empty Waveform on the Stream, sets "Last Element" to True and "Valid Element" to False, and stops the Producer.  The Consumer monitors the Valid Element line and, if True, plots the Data.  It also uses the "Last Element" line to stop the Consumer.  Very neat, very mnemonic.

 

Bob Schor

 

 

Message 12 of 14
(590 Views)

Hi Bob,

 

Thank you for your response. For the last hint, I coudn't monitor the stop of the consumer loop by the last and valid elements as the objective is to wait indefinitely for data to process them ( it is conceived for a demonstrator).  My question is when you can add the wait item and in which loop and how much time should I put considering the fact that data should be acquired and processed continuously. So I think the solution here is to empty memory from a moment to another but I don't know how. Besides, I opened another discussion about memory to organize the problems. Here is the link. There is a screenshot of the program.

https://forums.ni.com/t5/Discussions-au-sujet-de-NI/LABVIEW-Resolve-a-problem-of-memory-two-while-lo...

 

Yasmine

 

 

0 Kudos
Message 13 of 14
(578 Views)

@Yasmine13579 wrote:

Hi Bob,

 

Thank you for your response. For the last hint, I coudn't monitor the stop of the consumer loop by the last and valid elements as the objective is to wait indefinitely for data to process them ( it is conceived for a demonstrator).

I think you misunderstood the point of the Demo.  In a Producer/Consumer design, because there are two independent loops, when you want to stop the Program (the "Stop" button), you need to stop both loops.  The Stream's Sentinel feature is an elegant way to do this -- you tell the Producer "Stop", and it tells the Consumer to Stop.

  My question is when you can add the wait item and in which loop and how much time should I put considering the fact that data should be acquired and processed continuously.

I'm not certain what you mean by a "Wait Item".  In my Demo, I had a Wait 1 second, as I was simulating a continuous data acquisition system collecting 1000 points at 1kHz (so it "looped" once a second).  Your Producer presumably has some form of timing -- whenever it gets data, it just sends it to the Consumer, which patiently "waits" for data automatically (unless you program a TimeOut, which (for Streams) I almost never use).

So I think the solution here is to empty memory from a moment to another but I don't know how.

You should not need to "empty memory" -- if there is no data present in the Producer, it won't send anything to the Consumer, and your routine will automatically "wait".  Try running the Demo, but add a "Pause 10 seconds" button, which you can implement by wiring either 1000 or 10000 (depending on the Pause button) to the Delay (ms) function in the Producer.

Besides, I opened another discussion about memory to organize the problems. Here is the link. There is a screenshot of the program.

Screen-shots of pieces of code are rarely useful.  You will help us a lot more to help you if you attach the actual VI.  


Bob Schor

Message 14 of 14
(569 Views)