Skip to content

Commit

Permalink
Tested the High Pass Filter and included it in Cerb makefile with no …
Browse files Browse the repository at this point in the history
…build errors
  • Loading branch information
Ruben Noroian committed Jan 26, 2025
1 parent ba74657 commit d29b50c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions middleware/include/high_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ typedef struct {
float scale;

float prev_output;
float prev_input;

} high_pass_t;

Expand Down
9 changes: 5 additions & 4 deletions middleware/src/high_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ void high_pass_init(float alpha, float scale, high_pass_t *filter)
filter->scale = scale;

filter->prev_output = 0.0;
filter->prev_input = 0.0;
}

float high_pass(high_pass_t *filter, float input)
{
float output =
filter->scale(input - (filter->alpha * input +
(1 - filter->alpha) * prev_output));
filter->scale * (filter->alpha * (input - filter->prev_input) +
(1 - filter->alpha) * filter->prev_output);

filter->prev_output =
filter->alpha * input + (1 - filter->alpha) * prev_output;
filter->prev_input = input;
filter->prev_output = output;

return output;
}

0 comments on commit d29b50c

Please sign in to comment.