LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic write to and read from same file and plot histograms

Hello all,

 

I am trying to continuosly acquire data, find peaks and save them in a text file. This process can last upto few minutes.

Now i would like to continuosly read back from the stored peaks and plot a histogram of the peaks stored in the file. I also want to update the histogram as the file gets updated.

 

0 Kudos
Message 1 of 3
(2,365 Views)

Instead of trying to do a "write and read back", particularly for a continuous process where you continue to acquire, find peaks, and save, I recommend the following Producer/Consumer design:

  • Your Producer #1 is the data acquisition code, which gets data of some form, and passes it to Consumer #1.
  • Consumer #1 may save the raw data (always a good idea), or may simply jump to the task of finding peaks.  Let's assume it is a "pure peak-finder".  Let's also assume that you will have less than 10,000 peaks.  
  • Consumer #1 takes the data it gets, finds (say) 5 peaks, and writes them to a Peak File.  It also acts as Producer #2 and sends these 5 peaks to Consumer #2.
  • Consumer #2 is concerned with processing all of the "Peak" data.  When new points (e.g. 5) come in, they are added to the (growing) array of points, then any computation you need takes place.

The purpose of Producer/Consumer patterns is to "decouple" time-critical stuff (like acquiring data, and saving it to disk) from less-time-critical stuff (like writing to disk and forming histograms).  Note that much of the data (any raw data, for example) is not kept in memory, but processed and "reduced" for later use.  Efficient use of Time (cpu) and Space (memory).

 

Bob Schor

0 Kudos
Message 2 of 3
(2,326 Views)

Thanks Bob for this nice algorithm. Any examples would be of great help.

0 Kudos
Message 3 of 3
(2,312 Views)