06-24-2016 01:08 PM
Dear all,
I am using C-DAQ NI9237 for data acquisition from 2 wheatstone full bridge . So i have a program written read two signals from two channels . Since there are fluctuations in data i am taking moving average similar to the example given by national instruments to calculate moving average which i have attached herewith. Also i have attached my program where i have used the same program to calculate moving average . For the moving average i am using index array to take out element from data array coming from DAQ./. But i am wondering how many element does the index array vi throws out of my array in a second ??? Because i have configured my CDAQ at 200 samples per second acquisition rate. So i am worried whether my index array is able to catch up with the speed of DAQ. Well i could observe moving average response is bit slow in the wavechart.
So if i am losing data when i am taking moving average by this method , is there any better way to take moving average ?
I have attached my VI as well as NI moving average example. Can anyone help me ?
Thanks. Any good suggestions will be highly appreciated.
Note: Attachment
1. with filter new 1.vi is my program
2. moving average example from NI.com
Sachet
06-24-2016 01:27 PM - edited 06-24-2016 01:42 PM
You could use the Mean PtByPt VI to keep a running average with point inputs. You could do this for every point, or you could do it for every acquisition Mean. The only different between the results of these two is your average length. With the running average of the mean values, your history length is in quantities of application loop rate. With the running average of the data points, your history length is in units of actual sample rate.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-24-2016 01:44 PM
Well, here's a little routine I wrote to simulate generating data at 200 Hz and displaying a 200-point moving average (if you used a smaller moving average, it would go faster). All of the computation is inside a single While loop, so if computing the Moving Average took longer than the 5 milliseconds we are "waiting" in the loop, the average loop time would be >5 msec.
Recalling that the millisecond clock on the PC is not supposed to be so accurate, on my machine, the average loop time is typically 1-2 microseconds below 5 milliseconds, so computing (and displaying) the average "takes no time" (i.e. does not slow down the loop, even without a Producer/Consumer Design).
Incidentally, I'm using a Lossy Queue as the basis for my 200-point Moving Averager.
Bob Schor
06-24-2016 02:39 PM
Hi,
Sorry i am new to labview. Do you mean to use normal mean instead of index array to pass element to the calculation of moving average like the one i have attached here?
Thanks.
Sachet
06-24-2016 02:46 PM
Hi,
Thanks for your suggestion. Sorry for misunderstanding. Actually i want to take moving average of only 25 terms only. But my moving average response was little bit slower than i had expected. My first guess for slower response was the use of index array which draws out only one element at a time so i am thinking it is not working as fast as CDAQ which i have configured at 200 Hz. So my main motive was to ask if there is any way i could make the response faster ???
Thanks.
Sachet
06-24-2016 04:10 PM
Well, my moving average of 200 points was able to "keep up" at 200 Hz, so I'd expect a moving average of 25 points to be 8 times faster.
Bob Schor
06-24-2016 10:42 PM - edited 06-24-2016 10:45 PM
@sk1 wrote:Thanks for your suggestion. Sorry for misunderstanding. Actually i want to take moving average of only 25 terms only. But my moving average response was little bit slower than i had expected. My first guess for slower response was the use of index array which draws out only one element at a time so i am thinking it is not working as fast as CDAQ which i have configured at 200 Hz. So my main motive was to ask if there is any way i could make the response faster ???
Don't guess. benchmark!!!
For all practical purpose, my 25 point moving average code has a loop time of about 400ns (2.5MHz!) on my laptop, so obviously something else is the limiting factor in your case.
(It is basically the same code as yours except for some obvious code simplifications)
For small N, you could even eliminate the upper shift regsiter and just take the array sum, but that would slow down a little bit for very large N. Probably still fast enough.
06-25-2016 08:19 AM
06-25-2016 09:32 AM
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-25-2016 09:58 AM
@sk1 wrote:
In my program i am using index array to take out element from the y array coming out daq. So my index array is the limiting factor because it pulls out only 1 element each time. But in your case you are taking moving average of numbera coming out from number generator. So my main motive is to replace the index array with another vi which i want to know??
"Index array" is NOT the time limiting factor, it is a very, very fast and efficient operation. Almost everything else is slower.
If you want to find out what is really slowing you down, please show us the actual code and don't continue to point fingers at innocent primitives.