Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering while acquiring

I have an programming need that seems straightforward but I just can't get my head around.  I need to sample a single channel (using a 6259) at fairly high rate (10kHz or higher). I'd like to generate a running average of the last, say, 100 samples. I'd also like to plot a filtered version of those 100 samples overtop the raw signal. My thought was to put a 100 sample/10Khz read inside a timed loop set to repeat every 10ms along with the averaging or filtering operations. I'd like to pull samples from the buffer while the acquisition goes on uninterrupted, but I wasn't sure if this is possible using a timed loop.

Is this possible? I am guessing the answer is yes...Is there a better way? Can anyone point me to some relevant tutorials/examples? I've searched the example finder but may have missed something...

Regards,
Matthew Pausley
NC State University
Raleigh,NC
0 Kudos
Message 1 of 4
(3,163 Views)

Therotically, you will not need a timed loop also.

You could use a normal loop, give scan rate as 10K and number of samples to read per channel for DAQmx read as 100.

But reading 100 samples out of Bufffer while acquiring 10K will surely generate buffer overflow errors and averaging it, would definitely be an overhead

0 Kudos
Message 2 of 4
(3,158 Views)
I thought of using a TL to ensure that the averaging process (or filtering) took place at determinstic intervals. If I can use a while loop and be confident things are happening when I need them to be, that's fine.

As far as the overhead issue and overflow, I had not thought that through. Are there guidelines I can use for proper combination of sampling rate and number of sample used? If I experience a buffer overflow error, how will I know? Crash?

Thanks!
Matthew Pausley
NC State University
Raleigh,NC
0 Kudos
Message 3 of 4
(3,150 Views)
Hey Matthew,

A Timed Loop should not be necessary to accomplish what you're trying to do.  Have you looked at some of LabVIEW's "shipping examples".  Help » Find Examples » Hardware Input and Output » DAQmx » Analog Measurements » Voltage » Cont Acq&Graph Voltage-Int Clk.vi is a good place to start.  When doing Continuous acquisition, the "number of samples" input specifies the buffer size.  When the buffer is full, data will be output, the while loop will iterate and wait for the buffer to become full again.  That way, your samples will be seamless.

If you want to filter/average the data while you are acquiring it, then I would suggest a Producer/Consumer Design Pattern (Data) which can be found in the Templates if you select the New... in LabVIEW.  There is also a great example of how to keep a running average in the LabVIEW Example Finder.

If you experience a buffer overflow, LabVIEW will throw an error.

I hope this helps!
- Erik
Message 4 of 4
(3,139 Views)