LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running a for loop inside a while loop for data acquisition

Hi everyone, I kind of understand what my problem is. It's bad software structure, due to lack of knowledge basically. So I am looking for suggestions here to solve my problem.

 

I have a while loop which is used for continuous data acquisition. I am Ni-daq USB 6251 with sampling rate of 20K and reading 2k samples and an accelerometer for some analysis . Now at each iteration I get a  1D array with 2000 values, these values are basically the vibration measured by the sensor. I need to use each of these values to do a computation, so I pass the array with indexing to a for loop (which is part of my code inside the while loop) and the number of iterations for the for loop is the size of the array. My VI obviously won't stop unless the for loop finishes computation for all 2000 values.

 

Does anybody know of any alternative way to achieve this without the need to use the for loop or wait for it till its done? 

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

If your problem is the calculation takes a long time and is slowing down your nice acquisition (or producer) loop, the pattern you're looking for is called "producer-consumer".

 

A link explaining some common design patterns in LabVIEW, including producer-consumer, is here:

https://forums.ni.com/t5/Developer-Center-Resources/Scalable-Design-Patterns-in-LabVIEW/ta-p/3534309


GCentral
0 Kudos
Message 2 of 3
(2,791 Views)

A more direct link: Producer/Consumer


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(2,771 Views)