27 #ifndef NOTCH_FILTER_H
28 #define NOTCH_FILTER_H
49 filter->
Ts = 1.0 / frequency;
59 float d = expf(-M_PI * bandwidth * filter->
Ts);
70 float theta = 2.0 * M_PI * frequency * filter->
Ts;
85 float a = (1 + filter->
d2) * 0.5;
87 *output_signal = (
b * filter->
yn1) - (filter->
d2 * filter->
yn2) + (a * *input_signal) - (
b * filter->
xn1) +
92 filter->
xn1 = *input_signal;
94 filter->
yn1 = *output_signal;
static void notch_filter_update(struct SecondOrderNotchFilter *filter, float *input_signal, float *output_signal)
Notch filter propagate.
static void notch_filter_set_sampling_frequency(struct SecondOrderNotchFilter *filter, uint16_t frequency)
Set sampling frequency of the notch filter.
static void notch_filter_set_filter_frequency(struct SecondOrderNotchFilter *filter, float frequency)
Set notch filter frequency in Hz.
static void notch_filter_set_bandwidth(struct SecondOrderNotchFilter *filter, float bandwidth)
Set bandwidth of the notch filter.
static float notch_filter_get_output(struct SecondOrderNotchFilter *filter)
Get notch filter output.
static void notch_filter_init(struct SecondOrderNotchFilter *filter, float cutoff_frequency, float bandwidth, uint16_t sample_frequency)
Initialize second order notch filter.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.