[应用相关] 一阶低通滤波器的设计

[复制链接]
948|6
 楼主| aspoke 发表于 2023-2-23 12:30 | 显示全部楼层 |阅读模式



h文件
  1. #ifndef _LPF_FIRST_ORDER_H
  2. #define _LPF_FIRST_ORDER_H

  3. typedef struct _lpf_first_order
  4. {
  5.     float fc;   // cut-off frequency
  6.     float uk;
  7.     float alpha; // filter coefficient
  8.     float T;     // samping period
  9. }LpfFirstOderObj;

  10. void lpf_first_order_init(LpfFirstOderObj *filter, float alpha);

  11. float lpf_first_order(LpfFirstOderObj *filter, float k);

  12. void lpf_first_order_fc_set(LpfFirstOderObj *filter, float fc, float T);

  13. #endif
C文件
  1. #include "lpf_first_order.h"

  2. #define LPF_PI  3.1415926

  3. void lpf_first_order_init(LpfFirstOderObj *filter, float alpha)
  4. {
  5.     filter->alpha = alpha;
  6.     filter->fc = 0;
  7.     filter->T = 0;
  8.     filter->uk = 0;
  9. }

  10. float lpf_first_order(LpfFirstOderObj *filter, float k)
  11. {
  12.     float uo;

  13.     uo = filter->alpha * k + (1 - filter->alpha) * filter->uk;
  14.     filter->uk = uo;

  15.     return uo;
  16. }

  17. void lpf_first_order_fc_set(LpfFirstOderObj *filter, float fc, float T)
  18. {
  19.     filter->fc = fc;
  20.     filter->T = T;
  21.     filter->alpha = (2 * LPF_PI * fc * T) / (1 + 2 * LPF_PI * fc * T);
  22. }


中国龙芯CDX 发表于 2023-2-28 13:45 | 显示全部楼层
楼主有详细的说明文件说一下具体的程序方案
mmbs 发表于 2023-3-9 12:13 | 显示全部楼层
一阶有源低通滤波器的上限截止频率受哪些因素影响
maqianqu 发表于 2023-3-9 12:36 | 显示全部楼层
一阶低通滤波器电阻一般取多少               
fengm 发表于 2023-3-10 10:18 | 显示全部楼层
一阶低通滤波器为什么会有相移               
olivem55arlowe 发表于 2023-3-10 10:44 | 显示全部楼层
滤波器的截止频率怎么求?               
biechedan 发表于 2023-3-10 11:56 | 显示全部楼层
一阶有源低通滤波器放大倍数是多少
您需要登录后才可以回帖 登录 | 注册

本版积分规则

25

主题

2474

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部