LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number of elements out of index array per second

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

Download All
0 Kudos
Message 1 of 26
(3,391 Views)

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.

Mean.PNG

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 26
(3,378 Views)

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.

Moving Average.png

Bob Schor

 

 

0 Kudos
Message 3 of 26
(3,367 Views)

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

0 Kudos
Message 4 of 26
(3,348 Views)

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

0 Kudos
Message 5 of 26
(3,344 Views)

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

0 Kudos
Message 6 of 26
(3,328 Views)

@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.

0 Kudos
Message 7 of 26
(3,301 Views)
Hi,
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??
Anyways can u attach me your prog instead of pic so i can see what u are really doin in your prog?
Thanks
Sachet
0 Kudos
Message 8 of 26
(3,275 Views)
I told you both of the VI names in my first reply. A neat trick for finding a VI if all you know is the name is the quick-drop menu. Press cntrl+space while on the block diagram and then type the name in.

Bob_Schor also included a Snippet. If you have LabVIEW 2015, you can drag and drop that image directly on to your block diagram to import the code.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 9 of 26
(3,267 Views)

@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.

0 Kudos
Message 10 of 26
(3,259 Views)