LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging 100 Measurements in continuous sampling

Hi Everyone:

  1. I am using NI-9220 and NI 9203
  2. am acquiring continuous analog (current) data signal from Laser Distance Sensor.
  3. To acquire measurements, I used DAQ assistant.
  4. I added the shift register to save the acquired data from the previous loop.
  5. I did add Three step filtration:

 

  • Backward/Forward Filter to fix the phase shift problem
  • Low Pass Filter
  • Moving Average

 

The vi software is attached.

 

Questions

  1. Could you please review the vi software and let me know if there is anything wrong? It seems to me that there is something wrong
  2. How can I get the average (Arithmetic Mean) in one point every 100 points instead of the moving average? In other words, I want only one averaged a point per second at the end of every iteration.
  3. How can I add another different channel in the same loop but with different parameters such as sampling rate, signal type (voltage), and apply the filtration process in the same loop?
  4. How can I make increase the precision of the measurements?

 

Any recommendation, suggestion, any help would be highly appreciated. 

 

Thanks

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

Hi Everyone:

  1. I am using NI-9220 and NI 9203
  2. am acquiring continuous analog (current) data signal from Laser Distance Sensor.
  3. To acquire measurements, I used DAQ assistant.
  4. I added the shift register to save the acquired data from the previous loop.
  5. I did add Three step filtration:

 

  • Backward/Forward Filter to fix the phase shift problem
  • Low Pass Filter
  • Moving Average

 

The vi software is attached.

 

Questions

  1. Could you please review the vi software and let me know if there is anything wrong? It seems to me that there is something wrong
  2. How can I get the average (Arithmetic Mean) in one point every 100 points instead of the moving average? In other words, I want only one averaged a point per second at the end of every iteration.
  3. How can I add another different channel in the same loop but with different parameters such as sampling rate, signal type (voltage), and apply the filtration process in the same loop?
  4. How can I make increase the precision of the measurements?

 

Any recommendation, suggestion, any help would be highly appreciated. 

 

Thanks

0 Kudos
Message 2 of 5
(2,611 Views)

I can't open your vi as I've not yet converted to 2019 but you just need to read 100 points at a time and then average them. I'm not sure how this works with the DAQ Assistant but it's easy to set up using DAQmx.

0 Kudos
Message 3 of 5
(2,573 Views)

I agree with Johntrich that you would do well to learn a little DAQmx (which "does all the work" of the Dreaded DAQ Assistant (a.k.a. DDA), and eliminates its Evil Twin, the Dynamic Data Wire.  I strongly recommend that you spend a little time and review the excellent DAQmx Tutorials that NI publishes, especially "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquisition Applications".

 

The basic Idea is that you create some Tasks (in MAX, for example) that spell out the details -- how many channels, voltage range, timing, sampling mode, etc., and your VI basically consists of a DAQmx Start (with a constant wired to the Task input that you "expand" by clicking on the little "selection triangle" and choosing the Task you just created and saved in MAX), a While Loop containing the DAQmx Read, and outside the While, a Stop Task and Clear Task.

 

Each time the loop runs, it should give you 100 points.  Depending on whether you asked for 1 or N channels, and whether you specified that you wanted "just data" or a Waveform output, you'll have the output you specified and can do what you need to with it.  If a single channel of Data (1D Array of Dbl), you simply put it through the Mean function found on the Math Palette (under Prob & Stat), while if it is a single Waveform, you unbundle the Data (Y) and take its mean.  If N channels, you do the same thing, but run the N channels through a For loop to do them one at a time, getting an Array of Means.

 

If you need to do additional processing, particularly if the processing takes time comparable with the time to acquire N samples, you can treat the Acquisition loop as a "Producer" and pass the data to a Consumer in a Producer/Consumer Design Pattern.  Otherwise, if it is something simple (and relatively fast, like saving to disk), just do it inside the DAQmx Read While loop (being sure to do the "slow" things, like opening and closing the file, outside the loop, before and after).

 

Bob Schor

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

If I'm reading your code correctly (and with so many Express Nodes it's hard to be sure without investing more time than I'm happy to - sorry!) then you're not taking a Moving Average - you're taking the average of all of the samples you've acquired so far.

 

The "Append Waveforms" node creates an output waveform that is the total of all of your iterations of the loop so far, and then you pass this into the statistics Express VI. So the output stats will be from the input data set (i.e. all). You could change this by wiring only the new data (i.e. the second input to Append Waveforms) into the stats Expr. VI.


GCentral
0 Kudos
Message 5 of 5
(2,520 Views)