I am designing Moving Average Filter. But I am confused And I need to filter the 4 channel within the FPGA of the cRIO. So please some body help me. Any suggestion are welcome regarding the post. I am using the NI 9220 and I want to filter 4 channel continously inside the FPGA.
Lookng forward for yor reply.
Thanks in advance...
Solved! Go to Solution.
and what's the problem?
For the simplest approach you need to use an array to store data, then replace one element with new data, sum up the array and divide by the number of elements. Do this 4 times for each channel...
(This might not be the best approach for a FGPA, but it will work...)
Can you attached vi or the picture for the vi so I can try and see is it working for my application or not.
That would be greate help.
you can look at "Mean Pt-by-Pt" to get an idea of a moving average function...
I would do something like this. I used an array of size 4, so you need to replace those constants with the array length that you want. Remember an FPGA must have a fixed length array.
This is what I would do. I am old fashioned and do not like using floating point on an FPGA, way too expensive. This is for integer math; it will also work with fixed point inputs.
Using the 4 sample delay will impart some error on the first 4 mean samples, but will be fine after that. This assumes you don't need the history data as was previously posted.
Of course. I forgot the feedback node had that delay feature to it. I was trying to come up with something similar with the subtract oldest value and adding new value before dividing, just couldn't quite get there with the shift register holding the array. And by that point I figured I might as well just keep with the simple average.
2-cents on data filtering (not the a direct answer the the question at hand):
If possible, an "oversampled" average tends to have much better results (IMO) than a pt-by-pt moving average. pt-by-pt moving averages cause phase-shifts in the data that I don't like. If you need something like that, I recommend a Median filter which is for the most part the same but keeps the charactertistic data points (such as maximums and minimums) from shifting to the right.
THanks for all the reply. But this code is working fine in simple Labview but not in Labview FPGA. So please if some one designed the moving avarage filter in labview FPGA so please let me know. Or post the result or answer so that can be useful for otheruser also.