Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

moving average of decimal values on fpga target

 

Im would like to take a moving average of 3 decimal values taken on sucessive samples.  So the fourth iteration on the FPGA would average the values from the 2nd, 3rd, and 4th iterations, while the fifth iteration would be the 3rd, 4th, and 5th. 

 

 There seems to be a limitation in that only the  fixed floating point data type seems supported for arrays while running on the fpga.  This is understandable why.  Yet, it appears many of the functions do not support fixed floating point such as "replace in array", or even summation.  Other ways around this, such as using the remove and insert into array functions appear to be restricted as the array is changed size and the error "arrays must be fixed size in current target" is produced.

 

Thanks in Advance

 

 

0 Kudos
Message 1 of 12
(5,960 Views)
how many samples?  fixed number of three is pretty easy.  four is easier. arbitrary number is more fun.
Message Edited by stu@viewpointusa.com on 10-05-2009 08:23 PM
Stu
0 Kudos
Message 2 of 12
(5,957 Views)

doing 4 will be just fine, especially if its easier

thanks

0 Kudos
Message 3 of 12
(5,949 Views)
what is the data source.  analog in as fixed point?  what module.
Stu
0 Kudos
Message 4 of 12
(5,938 Views)

 

9237 bridge module

its analog input channel 0

0 Kudos
Message 5 of 12
(5,936 Views)

this seem tricky.

 

the replace in array function will wire in fixed floating point, but it work run properly with it, ie, only 0 comes out.

 

the only other way i can think of of is to insert into array, but that changes the array size so it can execute on the fpga.

 

 

0 Kudos
Message 6 of 12
(5,927 Views)

Hello Biosolutions,

 

Have you seen this Community Example?

 

FPGA Running Average Function

     http://decibel.ni.com/content/docs/DOC-2460

0 Kudos
Message 7 of 12
(5,925 Views)

see attached image of a diagram.  real simple.  average code could be moved into sub-vi.  sample could be averaged in with previous values on same iteration but iteration rate would be reduced.  this is computing the average while the next point is being acquired.

 

Stu
Download All
0 Kudos
Message 8 of 12
(5,918 Views)

a running average and moving average are very different

the moving average is over a small window.

its generally used to remove noise when not sampling at a high frequency, which is what is done in this case

 

 

0 Kudos
Message 9 of 12
(5,876 Views)

 

this looks very clever.

 

a simplier soluition turned out to be using the fixed point math toolbox, which is free.

http://zone.ni.com/devzone/cda/tut/p/id/7781

 

 

Message 10 of 12
(5,875 Views)