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

low pass and high pass filter

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
wangine



Joined: 07 Jul 2009
Posts: 98
Location: Curtea de Arges, Romania

View user's profile Send private message Send e-mail Yahoo Messenger

low pass and high pass filter
PostPosted: Sat Nov 26, 2011 2:17 pm     Reply with quote

Simple low pass and high pass filter.
The magic number is the coeficients (fill_rate_hp & fill_rate_lp).

Code:
/********************************************************************/
/*  Writer Tanase Bogdan                                 */
/*  (c) copyright www.hexhoby.ro                           */
/*  ALL RIGHTS RESERVED                                    */
/*                                                    */
/********************************************************************/
/* Ver 0.2 release 28/august/2011                           */
/********************************************************************/

float32 fill_rate_lp =  0.9689f; //float32 fill_rate =  0.8958700000f;
float32 fill_rate_hp = 0.9921767002f;

float32 low_pass = 0;
float32 high_pass = 0;

struct {
float   lp_x_0;
float   lp_x_1;
float   lp_y_0;

float   hp_x_0;
float   hp_x_1;
float   hp_y_0;
}filtru;


//~~~~~~~~~~~~~~~~~~~~~~~init lp_filter~~~~~~~~~~~~~~~~~~~~~~~~~~~

void init_lp_filter()
   {
   filtru.lp_x_0 = 0.0004171f;
   filtru.lp_x_1 = 0.0004227f;
   filtru.lp_y_0 = 0.0196256f;
   }
//~~~~~~~~~~~~~~~~~~~lowpass filter angle from accelerometer ~~~~~~~~~~~~~~~~
float32 lp_filter(float32 lp_f)
   {
   filtru.lp_x_0 = filtru.lp_x_1;
   filtru.lp_x_1 = lp_f * 0.00391165f; //(1.0f/2.556465999e+02f)>> //0.00391164991199243405231770500852
   
   low_pass = filtru.lp_y_0 = filtru.lp_x_0 + filtru.lp_x_1 + fill_rate_lp * filtru.lp_y_0;
   return low_pass ;


   }
//~~~~~~~~~~~~~~~~~~~~~highpass filter angle rate from gyro ~~~~~~~~not necesary (kalman) ha
float hp_filter(float32 hp_f)
{
   filtru.hp_x_0 = filtru.hp_x_1;
   filtru.hp_x_1 = hp_f * 0.9960883500f; //0.99608835009221601668808968822535
   filtru.hp_y_0 = filtru.hp_x_1 - filtru.hp_x_0 +   
               fill_rate_hp * filtru.hp_y_0;
   high_pass = filtru.hp_y_0;

   return high_pass;

}
//==========================================


and how it works
http://www.youtube.com/watch?v=Y6e-i7dk23w

The blue line is the filter pass.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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