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

This commit is contained in:
chunyexixiaoyu 2021-08-17 18:28:14 +08:00
parent 6664b23234
commit 09d86f55b0
2 changed files with 34 additions and 1 deletions

View File

@ -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;
}

View File

@ -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