Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: stange behavior

2004-10-05 by aymanme

--- In AVR-Chat@yahoogroups.com, "dpalu2" <dpalu2@u...> wrote:
> newAverage = Beta * oldAverage + (1 - Beta) * instantaneousReading
> Where: 0 <= Beta <= 1 and all variables are represented as "floats"
> 
> On some devices, this works just fine.  On some, the newAverage 
> reading
> "blows" up (i.e., gets real big or real small) , even if I have zero
> voltage on the A/D ports Same code, same hardware.  VCC looks 
good.   

Well, if the ADC reading is 0, and you are doing smoothing, I 
would expect it to go to zero eventually.  

> newAverage = oldAverage / (1 / Beta) +  instantaneousReading / (1 / 
> (1 -
> Beta)

It is strange that it works this way, though with floating point 
numbers 1/(1/x) does not always equal x

Is there are reason that you are not applying a moving window to 
smooth the data?  Smoothing is basically low pass filtering.  What 
you have looks more like an exponential average.  Presumably beta is 
small so that the most recent sample has the most weight?

Having said that, the algebra is the same so I cant guess as to why 
one would work while the other doesn't.  Though I have never had a 
part that was bad unless I destroyed it and then they usually failed 
in a major way.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.