LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

continuous acquisition and variable averaging

hello,
Im trying to make an application for which i need to take in samples of analog data, sample them and average them.
The frequency is determined at run time from the user using 2 parameters that (s)he enters i.e T and N.
The sampling frequency now has to be set to N/T and analog data is taken in at this frequency.
Now i have the following requirement. In the first T interval I dont average the data. In the next 2T interval I average every 2 samples into 1. In the next 4T interval I average 4 samples into 1 and so on.
The purpose is that such a strategy gives good data resolution in my chemical experiment since rates decay with time. The averaging helps in smoothing and reducing the amount of data.

Could some one please let me know
1. how to set up a analog sampling at a frequency that is fixed but is known only at runtime? the daq assistant does not have a frequency of sampling as input.

2. how do i carry out such averaging? The examples on this site didnt quite cover such a situation where I would need to change the amount of averaging based on the time (perhaps i didnt look enough. if someone knows any link to such a task please let me know).

3.Another problem is that the I shall be displaying the averaged data in real time so I would have to be able to do that too.

thank you
regards
sam
0 Kudos
Message 1 of 2
(2,271 Views)
Sam,
To be able to set the sample rate at runtime, you will probably want to move away from the DAQ Assistant and use the more advanced DAQmx VIs. There are plenty of examples using these VIs. You can find them by going to Help>>Find Examples in LabVIEW and navigating to Hardware Input and Output>>DAQmx>>Analog Measurements>>Voltage. This is assuming that you have a device that is supported by DAQmx. (If you are using the DAQ Assistant, then your device is supported by DAQmx).

As far as the averaging that you are trying to do....that might be a little more difficult. It is basically going to take some additional math and probably some array manipulation. I took a shot at writing a LabVIEW program (attached) to do this. If you look at the block diagram, you will see that I put the DAQmx Read.vi in a case structure that does averaging based on the loop iteration. Right now, the VI will only go through your T, 2T, and 4T iterations, but it could be manipulated to go further. This VI also displays the data on a waveform graph as it is acquired. I saved the VI to LabVIEW 7.0.

Hope this helps!

-Alan A.

Disclaimer: This might not be the best way to approach your averaging problem, but it is one idea.
0 Kudos
Message 2 of 2
(2,253 Views)