Yahoo Groups archive

AVR-Chat

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

Thread

stange behavior

stange behavior

2004-10-05 by dpalu2

Hi All:

Have any of you ever come accross a bad batch of Atmel AT90S8535 
chips?
The reason I ask is as follows.

I have deployed an  application that does some "smoothing" of airflow
measurement readings with a simple equation:  
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.   
I have all interrupts turned off.

If I just use the instantaneous readings without any smoothing, it 
never
blows up.  I've tried making variables local (stack) and global 
(heap).
Results are the same.  If its software, you'd think that I'd have the
problem on all devices, not just some of them.

The other funny thing is that the behavior is periodic.  What is 
really odd
however, is that I tried changing the equation to use all division in 
lieu
of multiplication as follows,

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

Things work fine !

I am using ImageCraft ICCAVR.

It seems like some of my chips have a goofy ALU.  Has any one else
experienced anything like this?

TIA

Draper

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.

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.