Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: UIT_IIR_Filter UIT_ACM1602NI UITDSP_ADDA mbed UIT_AQM1602
Biquad.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2014-10-23
- Revision:
- 0:a9412b9e85b7
File content as of revision 0:a9412b9e85b7:
//--------------------------------------------------------------
// Biquad filter for IIR filter of cascade structure
// 2014/10/21, Copyright (c) 2014 MIKAMI, Naoki
//--------------------------------------------------------------
#ifndef IIR_BIQUAD_HPP
#define IIR_BIQUAD_HPP
#include "mbed.h"
// 2nd order IIR filter
class Biquad
{
public:
struct Coefs { float a1, a2, b1, b2; };
Biquad() {} // Default constructore
Biquad(const Coefs ck)
: a1_(ck.a1), a2_(ck.a2), b1_(ck.b1), b2_(ck.b2)
{ Clear(); }
float Execute(float xn)
{
float un = xn + a1_*un1_ + a2_*un2_;
float yn = un + b1_*un1_ + b2_*un2_;
un2_ = un1_;
un1_ = un;
return yn;
}
void Clear() { un1_ = un2_ = 0; }
private:
float a1_, a2_, b1_, b2_;
float un1_, un2_;
Biquad(const Biquad&);
};
#endif // IIR_BIQUAD_HPP