LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data loss in producer-consumer

I cannot view and store at the same time as it causes data loss. If I remove the cycle from the chart the data is correct without data loss, but I need to store and see the signal, I am using a notifier for displaying the signal.

 

 

Image 1 : no data loss, only save data

image 2 : data loss with chart

 

psd: i am using mpusbapi bulk usb.

Download All
0 Kudos
Message 1 of 2
(460 Views)

The "trick" of the Producer/Consumer pattern in LabVIEW is that loops can run "in parallel", and moving data around in memory is quite fast.  You have three loops:  Data Acquisition loop, which generates data at regular intervals, but spends very few cycles "inside the loop" because most of the work takes place in the hardware, a Plotting loop which gets an Array of data from the Acquisition loop (and needs to plot it at least as fast as the data are being generated), and a data-saving Loop, which writes data to disk (and is governed by disk speed, generally also pretty fast.

 

Data Acquisition -> Data Plotting is one Procedure/Consumer loop.  Data Plotting -> Data Saving is a second Producer/Consumer Loop.  When the Plotting Loop gets the data from its dequeue (acting as a Consumer), it immediately puts it on a Queue to the Data Saving loop, making it a (second) Producer.  Note that running the Producer or the Consumer takes very little time -- it's basically "copying data from one block of memory to another".  Because it is in a Queue, no data gets "lost" or "ignored" (unlike the case with a Notifier).  Note that Queues are "elastic" -- if one loop needs "a little more time" to consume, the data will "build up" in the Queue, and when the loops resume "full speed", they'll "drain" the Queue.

 

Bob Schor

0 Kudos
Message 2 of 2
(403 Views)