Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Moving average Routine for 24 bit ADC

Status
Not open for further replies.

ravi_p

Member level 1
Joined
Jun 29, 2004
Messages
38
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
337
moving average+adc

Hi

I working on a project where i have interfacing 24 bit ADC to AT89s52. I want to implement moving average window method for better resolution.

Any one can suggest me how to implement moving average or if any one has the routine can you please share the routine.

Thanks
Ravi
 

adc averaging routines

Hi !
I think that you can use the fomular:
X = (X1+X2+ . . .+Xn)/n
X1,X2,. . .Xn is the sample in the one second ! But I think that you must have good math.
Good luck for U !
 

adc+moving avreage

which 24 bit adc are u using
 

moving average +adc

Keep an accumulator for the added total.

When a new value comes in, subtract out the oldest value. Then add in the newest value.

Your accumulator total / depth is your average, if you're keeping the last 16 values then it's acc/16 etc..

If you're using say 16, you still have to keep all 16 so you will have the 16th oldest to subtract. But you only have to do 1 subtract and 1 add for each new incoming value, you don't have to add all 16 each time. The other 15 values in your history still have their total in the accumulator, you just subtract out the oldest and add in the newest, the other 15 still are in the accumulator.

This is important to do this way if you keep like 256 values, that's a lot of adds for each new value if you don't keep an accumulator with the 255 that don't change this time already added.

Remember to put on your extra higher byte to your accumulator. 32 bits will hold up to 256 of the 24 bit values added etc..

Use an index to your stored values. When you get a new value, subtract out the old one at the index, add in the new one and put it at index, then move your index up one.

ACC=ACC-(valueatindex)
ACC=ACC+(newvalue)
newvalue moved to index location
index = index +1
rolling average = ACC/number of values in buffer

And roll your index around at the top of the buffer..


Alan
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top