Browse Source

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

pull/9/head
chunyexixiaoyu 11 months ago
parent
commit
09d86f55b0
  1. 23
      APP_Framework/Framework/knowing/filter/high_pass_filter/one_order_rc_hpf.c
  2. 12
      APP_Framework/Framework/knowing/filter/high_pass_filter/one_order_rc_hpf.h

23
APP_Framework/Framework/knowing/filter/high_pass_filter/one_order_rc_hpf.c

@ -1 +1,22 @@
#include<one_order_rc_hpf.h>
#include<one_order_rc_hpf.h>
void OneOrderRcHpfInit(OneOrderRcHpfHander* 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
hander->vi_prev = 0;
}
float OneOrderRcHpfFun(OneOrderRcHpfHander *hander)
{
float rc;
float alpha;
rc = (float) 1.0/2.0/3.1415926/hander->fcutoff;
alpha = rc/(rc+1/hander->fs);
hander->vo = (hander->vi - hander->vi_prev + hander->vo_prev)*alpha;
hander->vi_prev = hander ->vi;
hander->vo_prev = hander ->vo;
return hander->vo;
}

12
APP_Framework/Framework/knowing/filter/high_pass_filter/one_order_rc_hpf.h

@ -1,5 +1,17 @@
#ifndef _ONE_ORDER_RC_HPF_H
#define _ONE_ORDER_RC_HPF_H
typedef struct
{
float vi;
float vi_prev;
float vo_prev;
float vo;
float fcutoff;
float fs;
} OneOrderRcHpfHander;
void OneOrderRcHpfInit(OneOrderRcHpfHander* hander,float cutoff_fre,float sampling);
float OneOrderRcHpfFun(OneOrderRcHpfHander *hander);
#endif
Loading…
Cancel
Save