Browse Source

APP_Framework/Framework/: complete one order RC low pass filter.

pull/9/head
chunyexixiaoyu 11 months ago
parent
commit
6664b23234
  1. 23
      APP_Framework/Framework/knowing/filter/low_pass_filter/one_order_rc_lpf.c
  2. 11
      APP_Framework/Framework/knowing/filter/low_pass_filter/one_order_rc_lpf.h

23
APP_Framework/Framework/knowing/filter/low_pass_filter/one_order_rc_lpf.c

@ -1 +1,22 @@
#include<one_order_rc_lpf.h>
#include<one_order_rc_lpf.h>
void OneOrderRcLpfInit(OneOrderRcLpfHander* hander,float cutoff_fre,float sampling)
{
hander->vi = 0;
hander->fcutoff = cutoff_fre; // low pass filter cutoff frequency
hander->vo = 0;
hander->vo_prev = 0;
hander->fs = sampling; //sampling rate
}
float OneOrderRcLpfFun(OneOrderRcLpfHander *hander)
{
float rc;
float alpha1;
float alpha2;
rc = (float) 1.0/2.0/3.1415926/hander->fcutoff;
alpha1 = 1/(1+rc*hander->fs);
alpha2 = rc*hander->fs/(1+rc*hander->fs);
hander->vo = alpha1*hander->vi + alpha2 *hander->vo_prev;
hander->vo_prev = hander ->vo;
return hander->vo;
}

11
APP_Framework/Framework/knowing/filter/low_pass_filter/one_order_rc_lpf.h

@ -2,4 +2,15 @@
#define _ONE_ORDER_RC_LPF_H
typedef struct
{
float vi;
float vo_prev;
float vo;
float fcutoff;
float fs;
} OneOrderRcLpfHander;
void OneOrderRcLpfInit(OneOrderRcLpfHander* hander,float cutoff_fre,float sample);
float OneOrderRcLpfFun(OneOrderRcLpfHander *hander);
#endif
Loading…
Cancel
Save