LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Process 10 recent values in a continuous loop ?

I have a while loop acquiring data continuosly from the DAQ.
 
I would like to process the latest 10 acquisitions to build a histogram from the DAQ data. OR in other words, the histogram should be built only based on the latest 10 acquisitions. Is there an easy way to accomplish this ?

Kudos are the best way to say thanks 🙂
0 Kudos
Message 1 of 8
(3,507 Views)
You can use a shift register and expand the left side for the nine history values. Feed the current value to the right shift register.
 
Do your analysis on the current and the 9 history values.
 
More efficient might be the implementation of a 10 element fifo buffer.

Message Edited by altenbach on 12-14-2005 01:01 PM

0 Kudos
Message 2 of 8
(3,503 Views)
Simplest is to just use a shift register and drag down the left register 10 values, the second method is to append to an array and do the histogram on the last subset (10 values) both are very easy to implement.  The second method will store all the data but can be slower because it will save all of the data in the loop. 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 8
(3,501 Views)
Since the histogram does not care how the values are sorted in the array buffer, you can use something like in the attached LabVIEW 7.0 example. You just keep a 10 element array in a shift register and replace the currently oldest with the new value at each iteraction.
 
(The example calculates the mean of the 10 last values. Simply substitute your histogram calculation in the top part of the code).
 

This assumes that each acquisition is a single point. If each of your 10 acquisitions is an array of equal size, you would just do a 2D buffer in the same way, replacing an entire row at each iteration. For the histogram statistics, reshape the buffer to a 1D array with a size of the product of the 2D dimensions.

Message Edited by altenbach on 12-14-2005 01:22 PM

Download All
Message 4 of 8
(3,500 Views)

Nice use of a circular buffer by aldenbach, the most efficient and elegant method of of storing the last N values for processing in a loop.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 8
(3,488 Views)
Thanks for all your replies guys.
 
I was planning to use queue operation and do this. This is what I've done. For every acquisition in the while loop, I compute a histogram. So this histogram would be updated for every iteration using a shift register and I wanted this update to have the last 10 histograms only.
 
 

Kudos are the best way to say thanks 🙂
0 Kudos
Message 6 of 8
(3,471 Views)
Soo... do you have one histogram or 10 histograms?
 
Do you want to display the average (or sum) of the last 10 histograms? Do you want toe operator to be able to recall up to the last 10 histograms individually? Please clarify.
 
The attached shows two possibilities.
0 Kudos
Message 7 of 8
(3,461 Views)
Hello
 
thanks for your help. I have a histogram which is built from 10 data acquisitions.
 
I used queue to build a size-10 FIFO model and used enqueue and dequeue to process the latest 10 data acquisitions. This seems to be elegant and does the job very easily.
 
Thanks again for all your help.

Kudos are the best way to say thanks 🙂
0 Kudos
Message 8 of 8
(3,439 Views)