LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading data from a continuous loop

Hello all

 

I am trying to put together a simple data acquisition and filter VI. I am using a Labjack U6 and I am streaming data continuously at 100Hz from 8 analogue channels. I then filter the data with a smoothing filter (windowed average). This acquire and filter happens sequentially in the same loop which runs continuously. I then designed a state machine within the same VI to start and stop the acquire/filter loop and to retrieve values from the filtered array of data. I failed to recognise that Labview will execute my state machine code once only as the aquire/filter loop is still running!

 

So, what is the best method to read back values from my filtered array? I am considering putting my acquire/filter loop in one VI and my state machine controller in another - but then how best to access the filtered data? I only need values occasionally and if I place the whole set of filtered arrays as a VI output will I not be creating several copies of large amounts of data? I am considering a queue to be the solution but I would welcome comments on this.

 

Code attached.

 

Thanks

 

Ray

0 Kudos
Message 1 of 5
(2,486 Views)

A queue would be an appropriate solution. Depending on how you need to use the data you could also use a notifier or user events.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 5
(2,483 Views)

I'm with Mark, the queue sounds the most appropriate.  If you only need the latest data, then the notifier might be a better choice.


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 5
(2,477 Views)

Thanks for the input.

 

As I have not designed my application to use queues this looks quite difficult to change now. I have solved the problem by using a non-reentrant VI as a controller which is queried by the Acquire VI. The Acquire VI is started and is run asynchronously by the controller.  The controller VI is called once a loop by the Acquire VI to see if it should still keep running and is passed an array of the filtered values. The rest of my code gets access to the latest filtered values through the controller VI.

 

It's not ideal, but it does the job. I was keen to use a method of periodic sampling in this Acquire VI as it enables me to add different filters if the data is too noisy.

 

Ray

0 Kudos
Message 4 of 5
(2,447 Views)

Without seeing your code it is difficult to give any advice. But from your description it doesn't sound like it is architected very well. You may want to consider looking at the producer/consumer architecture. Also, separate your UI from your data acquisition and processing code. If you use multiple parallel loops you should pass data between them using queues or notifiers.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 5
(2,437 Views)