CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

What is averaging algorithm?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lala
Guest







What is averaging algorithm?
PostPosted: Thu Jun 03, 2004 3:08 am     Reply with quote

Confused

hello;

What is averaging algorithm? i just study on resistive touchscreen technology and want to know how the averaging algorithm apply to this technology?

thank you
SteveS



Joined: 27 Oct 2003
Posts: 126

View user's profile Send private message

PostPosted: Thu Jun 03, 2004 8:33 am     Reply with quote

Since filtering comes up a lot I wrote up a real short and simple introduction to filters in the code section. Hope that helps.

- SteveS
bdring
Guest







PostPosted: Fri Jun 11, 2004 2:01 pm     Reply with quote

I often use a rolling average. You can call this hundreds or times without the need to store a bunch of values in RAM. Adjust the variable type to fit your application. It is not very fast, but it works for me.


Code:
int16 avg(int16 oldVal, int16 newVal, int8 sampleNo)
{
   return = oldVal + (newVal-oldVal)/sampleNo;
}



Initialize the value to zero and call it as shown below.

Code:
oldVal = 0;
oldVal = avg(oldVal, 100, 1);
oldVal = avg(oldVal, 120, 2);
oldVal = avg(oldVal, 140, 3);

oldVal will hold the average at every stage and end up with 130 in this case.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group