Transform real signal to analytic signal using Hilbert transform filter for ST Nucleo F401RE.

Dependencies:   UIT_ADDA mbed

Committer:
MikamiUitOpen
Date:
Thu Oct 23 00:37:00 2014 +0000
Revision:
0:3d6eb7cd2ee1
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:3d6eb7cd2ee1 1 //--------------------------------------------------------------
MikamiUitOpen 0:3d6eb7cd2ee1 2 // Biquad filter for IIR filter of cascade structure
MikamiUitOpen 0:3d6eb7cd2ee1 3 // 2014/10/21, Copyright (c) 2014 MIKAMI, Naoki
MikamiUitOpen 0:3d6eb7cd2ee1 4 //--------------------------------------------------------------
MikamiUitOpen 0:3d6eb7cd2ee1 5
MikamiUitOpen 0:3d6eb7cd2ee1 6 #ifndef IIR_BIQUAD_HPP
MikamiUitOpen 0:3d6eb7cd2ee1 7 #define IIR_BIQUAD_HPP
MikamiUitOpen 0:3d6eb7cd2ee1 8
MikamiUitOpen 0:3d6eb7cd2ee1 9 #include "mbed.h"
MikamiUitOpen 0:3d6eb7cd2ee1 10
MikamiUitOpen 0:3d6eb7cd2ee1 11 // 2nd order IIR filter
MikamiUitOpen 0:3d6eb7cd2ee1 12 class Biquad
MikamiUitOpen 0:3d6eb7cd2ee1 13 {
MikamiUitOpen 0:3d6eb7cd2ee1 14 public:
MikamiUitOpen 0:3d6eb7cd2ee1 15 struct Coefs { float a1, a2, b1, b2; };
MikamiUitOpen 0:3d6eb7cd2ee1 16
MikamiUitOpen 0:3d6eb7cd2ee1 17 Biquad() {} // Default constructore
MikamiUitOpen 0:3d6eb7cd2ee1 18
MikamiUitOpen 0:3d6eb7cd2ee1 19 Biquad(const Coefs ck)
MikamiUitOpen 0:3d6eb7cd2ee1 20 : a1_(ck.a1), a2_(ck.a2), b1_(ck.b1), b2_(ck.b2)
MikamiUitOpen 0:3d6eb7cd2ee1 21 { Clear(); }
MikamiUitOpen 0:3d6eb7cd2ee1 22
MikamiUitOpen 0:3d6eb7cd2ee1 23 float Execute(float xn)
MikamiUitOpen 0:3d6eb7cd2ee1 24 {
MikamiUitOpen 0:3d6eb7cd2ee1 25 float un = xn + a1_*un1_ + a2_*un2_;
MikamiUitOpen 0:3d6eb7cd2ee1 26 float yn = un + b1_*un1_ + b2_*un2_;
MikamiUitOpen 0:3d6eb7cd2ee1 27
MikamiUitOpen 0:3d6eb7cd2ee1 28 un2_ = un1_;
MikamiUitOpen 0:3d6eb7cd2ee1 29 un1_ = un;
MikamiUitOpen 0:3d6eb7cd2ee1 30
MikamiUitOpen 0:3d6eb7cd2ee1 31 return yn;
MikamiUitOpen 0:3d6eb7cd2ee1 32 }
MikamiUitOpen 0:3d6eb7cd2ee1 33
MikamiUitOpen 0:3d6eb7cd2ee1 34 void Clear() { un1_ = un2_ = 0; }
MikamiUitOpen 0:3d6eb7cd2ee1 35
MikamiUitOpen 0:3d6eb7cd2ee1 36 private:
MikamiUitOpen 0:3d6eb7cd2ee1 37 float a1_, a2_, b1_, b2_;
MikamiUitOpen 0:3d6eb7cd2ee1 38 float un1_, un2_;
MikamiUitOpen 0:3d6eb7cd2ee1 39
MikamiUitOpen 0:3d6eb7cd2ee1 40 Biquad(const Biquad&);
MikamiUitOpen 0:3d6eb7cd2ee1 41 };
MikamiUitOpen 0:3d6eb7cd2ee1 42
MikamiUitOpen 0:3d6eb7cd2ee1 43 #endif // IIR_BIQUAD_HPP
MikamiUitOpen 0:3d6eb7cd2ee1 44