tomlankhorst/control
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
control::filter::Biquad< T, S > Class Template Reference

#include <biquad.h>

Inheritance diagram for control::filter::Biquad< T, S >:
control::system::SISO< T >

Public Member Functions

 Biquad (T b0, T b1, T b2, T a1, T a2)
 
 Biquad (T b0, T b1, T b2, T a0, T a1, T a2)
 
 Biquad (TCS< T > z, TCS< T > p, T k)
 
step (T x)
 
TCS< T > poles ()
 
TCS< T > zeros ()
 
bool stable ()
 
void reset ()
 

Protected Member Functions

std::tuple< T, T, T, T, T > zpk2coef (TCS< T > z, TCS< T > p, T k)
 
std::tuple< T, T > zero2coef (TCS< T > z)
 
TCS< T > solve (T a, T b, T c)
 

Protected Attributes

wz [2] = {0, 0}
 
B [3]
 
A [2]
 

Detailed Description

template<typename T = float, typename S = const T>
class control::filter::Biquad< T, S >

Biquad

Filters that - in the z domain - are the ratio of two quadratic functions.

The general form is:

       b0 + b1 z^-1 + b2 z^-2

H(z) = -------------------— a0 + a1 z^-1 + a2 z^-2

Normalized by dividing all coefficients by a0.

Template Parameters
Tarithmetic type
Sparameter type (const T)

Constructor & Destructor Documentation

◆ Biquad() [1/3]

template<typename T = float, typename S = const T>
control::filter::Biquad< T, S >::Biquad ( b0,
b1,
b2,
a1,
a2 
)
inline

Initialize a biquad filter with normalized (5) coefficients

Parameters
Tb0
Tb1
Tb2
Ta1
Ta2

◆ Biquad() [2/3]

template<typename T = float, typename S = const T>
control::filter::Biquad< T, S >::Biquad ( b0,
b1,
b2,
a0,
a1,
a2 
)
inline

Initialize a biquad with unnormalized (6) coefficients

Parameters
b0
b1
b2
a0
a1
a2

◆ Biquad() [3/3]

template<typename T = float, typename S = const T>
control::filter::Biquad< T, S >::Biquad ( TCS< T >  z,
TCS< T >  p,
k 
)
inline

Initialize a biquad with ZPK

Parameters
TCS<T>z zeros
TCS<T>p poles
Tk gain

Member Function Documentation

◆ poles()

template<typename T = float, typename S = const T>
TCS<T> control::filter::Biquad< T, S >::poles ( )
inline

Poles of the biquad

Get a tuple of two complex values that represent the biquads poles. Poles of a biquad are the solution to the denominator, a quadratic equation.

Returns
TCS<T>

◆ reset()

template<typename T = float, typename S = const T>
void control::filter::Biquad< T, S >::reset ( )
inline

Reset the biquad

◆ solve()

template<typename T = float, typename S = const T>
TCS<T> control::filter::Biquad< T, S >::solve ( a,
b,
c 
)
inlineprotected

Solve a quadratic polynomial

ax^2+bx+c -> k(x-z1)(x-z2)

Parameters
aT
bT
cT
Returns
TCS<T> zeros

◆ stable()

template<typename T = float, typename S = const T>
bool control::filter::Biquad< T, S >::stable ( )
inline

Stability of the biquad

Checks stability through evaluating the magnitude of the poles

Returns
bool whether stable

◆ step()

template<typename T = float, typename S = const T>
T control::filter::Biquad< T, S >::step ( x)
inlinevirtual

Step the biquad

Parameters
Tx input value
Returns
T output value

Implements control::system::SISO< T >.

◆ zero2coef()

template<typename T = float, typename S = const T>
std::tuple<T, T> control::filter::Biquad< T, S >::zero2coef ( TCS< T >  z)
inlineprotected

Coefficients of quadratic poly. corresponding to zeros

Gets the coefficients of the quadratic polynomial s.t. its solutions are p

(x-z1)(x-z2) -> x^2-(z1+z2)+z1*z2

Parameters
TCS<T>z tuple of two complex Ts
Returns
std::tuple<T,T> tuple of two Ts

◆ zeros()

template<typename T = float, typename S = const T>
TCS<T> control::filter::Biquad< T, S >::zeros ( )
inline

Zeros of the biquad

See also
poles()
Returns
TCS<T>

◆ zpk2coef()

template<typename T = float, typename S = const T>
std::tuple<T, T, T, T, T> control::filter::Biquad< T, S >::zpk2coef ( TCS< T >  z,
TCS< T >  p,
k 
)
inlineprotected

Convert ZPK to coefs


The documentation for this class was generated from the following file: