28 #ifndef ADAPTIVE_NOTCH_FILTER_H
29 #define ADAPTIVE_NOTCH_FILTER_H
66 float low_freq_bound,
float high_freq_bound,
float bandwidth,
float lambda,
float a_ini,
float value)
69 filter->
Ts = sample_time;
72 filter->
r = bandwidth;
76 filter->
y[0] = filter->
y[1] = filter->
y_est[0] = filter->
y_est[1] = value;
77 filter->
a_est = a_ini;
82 float fs = 1. / filter->
Ts;
86 float lp_tau = 1.0 / (2.0 * M_PI * filter->
lp_cutoff_f);
90 float hp_tau = 1.0 / (2.0 * M_PI * filter->
hp_cutoff_f);
120 float beta = -filter->
xband[1] + filter->
r * filter->
y_est[1];
125 filter->
y[1] = filter->
y[0];
126 filter->
y[0] = *output_signal;
128 filter->
y_est[0] = out_est;
140 return filter->
y_est[0];
static void adaptive_notch_filter_update(struct AdaptiveNotchFilter *filter, float value, float *output_signal)
Update a second order adaptive notch filter.
Butterworth2LowPass hp_filter
static void adaptive_notch_filter_init(struct AdaptiveNotchFilter *filter, float sample_time, float low_freq_bound, float high_freq_bound, float bandwidth, float lambda, float a_ini, float value)
Init a adaptive notch filter.
struct SecondOrderNotchFilter output_n_filter
static float adaptive_notch_filter_get_output(struct AdaptiveNotchFilter *filter)
Return the latest second order adaptive notch filter output.
Butterworth2LowPass lp_filter
Simple first order low pass filter with bilinear transform.
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
Second order low pass filter structure.
static void notch_filter_update(struct SecondOrderNotchFilter *filter, int32_t *input_signal, int32_t *output_signal)
Notch filter propagate.
static void notch_filter_set_filter_frequency(struct SecondOrderNotchFilter *filter, float frequency)
Set notch filter frequency in Hz.
static void notch_filter_init(struct SecondOrderNotchFilter *filter, float cutoff_frequency, float bandwidth, uint16_t sample_frequency)
Initialize second order notch filter.