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 CCS Technical Support

Median Filter code snip from old post 13211

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







Median Filter code snip from old post 13211
PostPosted: Thu Nov 27, 2003 10:41 am     Reply with quote

Hello All,

I'm looking for a median filter code. A search shows that post 13211 has what I need but the post is no longer avaliable.

Does anyone know how to look at the old Forum or have a code snip that they can share with the forum?

Thanks in advance for your help.

Peter


http://www.pic-c.com/forum/general/posts/13211.html
hp



Joined: 07 Sep 2003
Posts: 4
Location: Texas

View user's profile Send private message

PostPosted: Thu Nov 27, 2003 10:52 am     Reply with quote

Hello,

You can do a search on the Forum for Post 13211. The search turned up: http://www.ccsinfo.com/forum/viewtopic.php?t=3462 which looks like the post you wanted.

Harrison
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Mon Dec 01, 2003 9:00 am     Reply with quote

This works really well for a signal that is being measured on a regular basis. This results in a signal thats filtered much like an RC circuit. In an RC circuit one time constant gets you to reach ~66% of the full scale value and ~5 time constants gives you the final value. Using this formula each sample is like a time constant that gives you 1/x of the stable value where x is the number of shifts in the subtraction operation. The number of samaples required to reach a stable value is dependant on the number of shifts.
Code:

   {  Analog_Input_1_RAW-=(Analog_Input_1_RAW>>2);          // Decrement by 1/4
      Analog_Input_1_RAW+=read_adc(ADC_READ_ONLY);          // Add current value to filtered reading
   }

This example results in a 12 bit result derived from the 10 bit ADC. If the RAW readings are going to be scaled these extra 2 bits dont matter and do nothing to reduce precision of a scaled result.
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