06-03-2022 01:39 AM - edited 06-03-2022 01:42 AM
I have a 48 Analog Input Channel DAQ system, I am reading at a rate of 1Khz. (The data has to be datalogged at 1Khz).
The signal received are with noise and to display to user without much fluctuation I am averaging the values using 'Mean Pt by Pt' API.
I am attached the VI wherein I have considered only 5 Analog Input which is simulated by a pointer numeric control. In producer loop I am purposely adding noise and storing the data array in a variable named as "data acquisition with noise".
In consumer loop I am applying the averaging method to individual analog input by the help of 'mean pt by pt' API.
The VI solves the purpose but for 48 Channel it becomes messy by using 48 'Mean pt by Pt' API.
How do I optimize the code so that with a single API I can get averaged values.?
Solved! Go to Solution.
06-03-2022 02:35 AM
How about using For-loop
06-03-2022 02:46 AM
I have tried with for loop, the results are not matching with the input signal
06-03-2022 04:17 AM
@msabah38 wrote:
I have tried with for loop, the results are not matching with the input signal
No, that is to be expected.
The for loop will average all channel data, as if it was a single channel.
You'd have to DIY something...
I'd make a 2D circular buffer (search the forum), size Channels X Length. You'd get a history of 10 for all channels, and you'd be able to get an average at any time.
Theoretically, you can keep the sum of all data, and subtract the earliest point when you add the newest point. That will save a lot of calculations. However, once you get a NaN, Inf, -Inf, or mixed small and large numbers, the sum is corrupted, and it won't work well.
06-03-2022 09:20 AM
wiebe@CARYA wrote:
The for loop will average all channel data, as if it was a single channel.
... unless we use a parallel FOR loop with a sufficient number of instances. 😄
06-03-2022 09:28 AM
Maybe all you need is something along these lines.
(I also remember some other more detailed discussions. Will try to find the link)
06-03-2022 10:08 AM - edited 06-03-2022 10:30 AM
Maybe all you really need is a simple and inexpensive exponential filter.
(adapted from my old post here)
Note that the filter factor control could be defined as 1/alpha (where alpha is in the range 0..1)) so a higher number increases the smoothing
06-03-2022 10:24 AM
@altenbach wrote:
wiebe@CARYA wrote:
The for loop will average all channel data, as if it was a single channel.
... unless we use a parallel FOR loop with a sufficient number of instances. 😄
should that work?
It still seems to use 1 instance of the PtPyPt VI?
I'd expect 0,1,2,3,4,5,6,7,8,9, but I get 0, .5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5.
06-03-2022 10:43 AM - edited 06-03-2022 11:09 AM
@altenbach wrote:
Note that the filter factor control could be defined as 1/alpha (where alpha is in the range 0..1)) so a higher number increases the smoothing
Here's how that could look like:
06-03-2022 10:50 AM - edited 06-03-2022 10:51 AM
Could you please downgrade the array averaging_MODCA2.vi 15 KB VI to LV.2015