![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Cutoff frequency variable LPF by IIR 6th-order Butterworth filter for ST Nucleo F401RE.
Dependencies: UIT_IIR_Filter UIT_ACM1602NI UITDSP_ADDA mbed UIT_AQM1602
Diff: IIR_Cascade.hpp
- Revision:
- 0:a9412b9e85b7
diff -r 000000000000 -r a9412b9e85b7 IIR_Cascade.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IIR_Cascade.hpp Thu Oct 23 06:44:40 2014 +0000 @@ -0,0 +1,55 @@ +//-------------------------------------------------------------- +// IIR filter ---- Cascade structure +// 2014/10/23, Copyright (c) 2014 MIKAMI, Naoki +//-------------------------------------------------------------- + +#ifndef IIR_CASCADE_HPP +#define IIR_CASCADE_HPP + +#include "mbed.h" +#include "Biquad.hpp" + +namespace Mikami +{ + // IIR filter -- Cascade structure + template<int order> class IirCascade + { + private: + Biquad hk_[order]; // Elements of cascade structure + float g0_; // gain factor + + IirCascade(const IirCascade&); + IirCascade& operator=(const IirCascade&); + + public: + IirCascade() {} + IirCascade(float g0, const Biquad::Coefs ck[]) + { SetCoefs(g0, ck); } + + void SetCoefs(float g0, const Biquad::Coefs ck[]) + { + g0_ = g0; + for (int k=0; k<order; k++) + hk_[k] = Biquad(ck[k]); + } + + float Execute(float xn) + { + float yn = g0_*xn; + for (int k=0; k<order; k++) + yn = hk_[k].Execute(yn); + + return yn; + } + + void Clear() + { + for (int k=0; k<order; k++) + hk_[k].Clear(); + } + }; +} +#endif // IIR_CASCADE_HPP + + +