LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

clear a buffer

I don't know what you are doing, I don't see a Flush anywhere, I don't understand why you would expect a Flush to do anything to your Queue, anyway (which means that if the Flush actually is expected to have no effect, then observing that it has no effect means it is probably functioning correctly!), and why you have a Circular Buffer function (mis-wired, by the way) in here.

 

Please do not take this the wrong way, but do you know what you are doing?  Can you explain for us what you are trying to accomplish with just the top loop?  It looks like you are generating 3 channels of 2000 points of random data, bundling it into a Waveform with a curious dt (I'm assuming you are simulating actual data acquisition -- if so, what is your intended sampling rate, and are you using "Continuous Acquisition", where the next 3 x 2000 points will be delivered when collected?).  You pass this through a Circular Buffer function (why?  what is this supposed to accomplish?) then put it on a Queue.

 

The entire top loop runs at 1 Hz, so as long as we assume the Consumer loop is reasonably fast, the Queue will almost always be empty -- it will only have data on it for the (very brief) interval between the Enqueue and the waiting Dequeue.  Even if you followed the Enqueue with a Flush, the Dequeue still might "win" because it is running asynchronously.

 

OK, so now we have whatever was placed on the Queue.  What do you intend to be there?  The entire set of 3 waveforms, each with 2000 points supposedly sampled at 100Hz (which would take 20 seconds, yet you are shoving Waveforms out 20 times faster ...)?

 

What is supposed to be happening in the bottom loop?  I have to confess that I've never used a Listbox, so I'm not sure what is supposed to happen when it is wired to a For loop, and accordingly I cannot guess (and am too lazy to experiment to find out) how many times (or even if) this For loop runs.  The functions to the right of the For Loop also puzzle me -- I'm not sure what you are trying to do here, but suspect you are not doing it correctly ...

 

Bob Schor

0 Kudos
Message 11 of 16
(1,663 Views)

I removed the part where I attempted to flush the queue from the code. the buffer was posted on the NI site, I modified it to process my cluster in it instead of the waveform. because It was originally build  for a 1D array. It is not mis-wired. 

I am creating a data generator with a waveform format of ( T0, dt, 2D array). That is why I convert my 1D into 2D. Than bundle them in a cluster. I feed the cluster in the buffer becuase I want to display 5 min worth of data on my waveform graph. No timing in the second loop becuase It will not run until the first at data to the queue.The data is then queued in top  loop and dequued in the second loop for display. I unbundled the cluster, built a waveform and select channels  I want to display. each row is a channel. I have decimator in there also. Then index the waveform and display the data plot.

The other for loop is making sure to display each channel name is displayed as you select them in the list box.

Hope the code break down was clear.

 

My goal now is to clear the buffer if I want to  restart it fresh from 0. because the buffer always has 5 min worth of data to process. Therefore there's always a full 5 min data displayed. but I want to be able to clear the waveform graph history, I tried clearing the history of the graph but the next display is a full 5 min data because the buffer never stops running and  input 5 min worth of data to the queue each time once it's full . My guess is to start the data display over, i would have to start the circular buffer over.I cant manage to do it without causing an error.  I hope my code diagnostic is right. please correct me if im wrong and help if possible.

 

 

0 Kudos
Message 12 of 16
(1,651 Views)

@ritch_by_nature wrote:

I removed the part where I attempted to flush the queue from the code. the buffer was posted on the NI site, I modified it to process my cluster in it instead of the waveform. because It was originally build  for a 1D array. It is not mis-wired. 


You posted two things -- your file "buff", which was missing a VI called 2D Waveform Circular Buffer, and a Zip file that contained a VI called 2D Waveform Circular Buffer, which I used to "fill in the blank" of your "buff" file.  This Circular Buffer VI requires a Waveform input in the upper left corner.  If, on the other hand, you modified it, it would be much more helpful to send the version that you use rather than some other code.

 

Are you organizing your code using LabVIEW Project?  Do you have the VIs you are currently using (like "buff" and your modified 2D Waveform Circular Buffer) in the same folder?  If so, if you ZIPped up the folder and attached that, we would have, all at once, all of the VIs that you use, wouldn't have to guess, and wouldn't have to waste our time trying to "help" you only to be told "No, I'm using some other sub-VI".

 

BS

0 Kudos
Message 13 of 16
(1,634 Views)

I apologize, It has a cluster input on the 3rd input on the left corner. first one is for waveform not being used. second is the buffer size, third is the input of the cluster. Use the third one instead.

0 Kudos
Message 14 of 16
(1,607 Views)

Did you get my last reply.

The buffer vi is correct. Use the third input. The one with the cluster. and also use the output cluster. Do not use the waveform.

0 Kudos
Message 15 of 16
(1,566 Views)

Updated buffer. You should not have any issue with this one

 

Admin Note - Attachments removed per user's request

0 Kudos
Message 16 of 16
(1,548 Views)