09-11-2012 10:37 AM
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
09-11-2012 10:40 AM
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.
09-11-2012 11:01 AM
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.
09-14-2012 06:15 AM
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
09-14-2012 10:23 AM
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.