AM中波放送用SDR.CICフィルタのみを使用.CQ出版社「トランジスタ技術」誌,2021年5月号に掲載

Dependencies:   mbed

Committer:
MikamiUitOpen
Date:
Wed Mar 03 01:20:09 2021 +0000
Revision:
1:32d6e3f7df30
Parent:
0:7a653530c8ce
2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:7a653530c8ce 1 //-----------------------------------------------------------------
MikamiUitOpen 0:7a653530c8ce 2 // 直流分除去用 IIR フィルタ
MikamiUitOpen 0:7a653530c8ce 3 // u[n] = a1*u[n-1] + x[n]
MikamiUitOpen 0:7a653530c8ce 4 // y[n] = g0*(u[n] - u[n-1])
MikamiUitOpen 0:7a653530c8ce 5 //
MikamiUitOpen 0:7a653530c8ce 6 // 2020/08/17, Copyright (c) 2020 MIKAMI, Naoki
MikamiUitOpen 0:7a653530c8ce 7 //-----------------------------------------------------------------
MikamiUitOpen 0:7a653530c8ce 8
MikamiUitOpen 0:7a653530c8ce 9 #include "mbed.h"
MikamiUitOpen 0:7a653530c8ce 10
MikamiUitOpen 0:7a653530c8ce 11 #ifndef IIR_DC_CUT_HPP
MikamiUitOpen 0:7a653530c8ce 12 #define IIR_DC_CUT_HPP
MikamiUitOpen 0:7a653530c8ce 13 namespace Mikami
MikamiUitOpen 0:7a653530c8ce 14 {
MikamiUitOpen 0:7a653530c8ce 15 class IirDcCut
MikamiUitOpen 0:7a653530c8ce 16 {
MikamiUitOpen 0:7a653530c8ce 17 public:
MikamiUitOpen 0:7a653530c8ce 18 // コンストラクタ
MikamiUitOpen 0:7a653530c8ce 19 // a1 フィルタの係数
MikamiUitOpen 0:7a653530c8ce 20 // g0 利得定数
MikamiUitOpen 0:7a653530c8ce 21 IirDcCut(float a1, float g0)
MikamiUitOpen 0:7a653530c8ce 22 : A1_(a1), G0_(g0), un1_(0) {}
MikamiUitOpen 0:7a653530c8ce 23
MikamiUitOpen 0:7a653530c8ce 24 // フィルタの実行
MikamiUitOpen 0:7a653530c8ce 25 float Execute(float xn)
MikamiUitOpen 0:7a653530c8ce 26 {
MikamiUitOpen 0:7a653530c8ce 27 float un = A1_*un1_ + xn;
MikamiUitOpen 0:7a653530c8ce 28 float yn = (un - un1_)*G0_;
MikamiUitOpen 0:7a653530c8ce 29 un1_ = un;
MikamiUitOpen 0:7a653530c8ce 30 return yn;
MikamiUitOpen 0:7a653530c8ce 31 }
MikamiUitOpen 0:7a653530c8ce 32
MikamiUitOpen 0:7a653530c8ce 33 private:
MikamiUitOpen 0:7a653530c8ce 34 const float A1_; // フィルタ係数
MikamiUitOpen 0:7a653530c8ce 35 const float G0_; // 利得定数
MikamiUitOpen 0:7a653530c8ce 36 float un1_; // 遅延器の値
MikamiUitOpen 0:7a653530c8ce 37
MikamiUitOpen 0:7a653530c8ce 38 // コピー・コンストラクタ,代入演算子の禁止のため
MikamiUitOpen 0:7a653530c8ce 39 IirDcCut(const IirDcCut&);
MikamiUitOpen 0:7a653530c8ce 40 IirDcCut& operator=(const IirDcCut&);
MikamiUitOpen 0:7a653530c8ce 41 };
MikamiUitOpen 0:7a653530c8ce 42 }
MikamiUitOpen 0:7a653530c8ce 43 #endif // IIR_DC_CUT_HPP