1 Star 0 Fork 2

sklink/qfoc

forked from luoqi/qfoc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hpf_1st.c 749 Bytes
一键复制 编辑 原始数据 按行查看 历史
/*
* @Author: luoqi
* @Date: 2022-11-29 09:44:24
* @Last Modified by: luoqi
* @Last Modified time: 2022-11-29 09:53:35
*/
#include "hpf_1st.h"
#define HPF_PI 3.1415926
int hpf_1st_init(Hpf1stObj *filter, float fc, float fs)
{
float ts = 1 / fs;
filter->alpha = 1 / (1 + 2 * HPF_PI * fc * ts);
filter->ts = ts;
filter->fc = fc;
filter->u_k1 = 0;
filter->y_k1 = 0;
return 0;
}
float hpf_1st_calcu(Hpf1stObj *filter, float u_k)
{
float y_k = filter->alpha * (u_k - filter->u_k1 + filter->y_k1);
filter->y_k1 = y_k;
filter->u_k1 = u_k;
return y_k;
}
int hpf_1st_fc_set(Hpf1stObj *filter, float fc)
{
filter->fc = fc;
filter->alpha = 1 / (1 + 2 * HPF_PI * fc * filter->ts);
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sklink/qfoc.git
git@gitee.com:sklink/qfoc.git
sklink
qfoc
qfoc
main

搜索帮助