LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Moving Average Filter

Solved!
Go to solution
Highlighted

Hello,

 

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

 

Spoiler
 

 

0 Kudos
Message 1 of 22
(18,082 Views)
Highlighted

Hi sammir,

 

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

Best regards,
GerdW
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 2 of 22
(18,082 Views)
Highlighted

Hello

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. 

 

 

0 Kudos
Message 3 of 22
(18,075 Views)
Highlighted

Hi sammir,

 

you can look at "Mean Pt-by-Pt" to get an idea of a moving average function...

Best regards,
GerdW
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 4 of 22
(18,064 Views)
Highlighted
Solution
Accepted by topic author Ajaxy

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 5 of 22
(18,051 Views)
Highlighted

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.

 

 

4samplemean.png

Message 6 of 22
(18,026 Views)
Highlighted

WillD wrote:

4samplemean.png


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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 7 of 22
(18,018 Views)
Highlighted

You can get the same effect by click-drag-expanding the shift registers on the left side of a loop:

 

4SaMeanshift.png

Message 8 of 22
(18,014 Views)
Highlighted

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.

0 Kudos
Message 9 of 22
(17,995 Views)
Highlighted

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.

 

 

0 Kudos
Message 10 of 22
(17,948 Views)