From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Moving Average Filter

Solved!
Go to solution

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
(28,554 Views)

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


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 22
(28,554 Views)

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
(28,547 Views)

Hi sammir,

 

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

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 22
(28,536 Views)
Solution
Accepted by 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
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 22
(28,523 Views)

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
(28,498 Views)

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
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 22
(28,490 Views)

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
(28,486 Views)

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
(28,467 Views)

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
(28,420 Views)