Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/highpass #206

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Feature/highpass #206

wants to merge 11 commits into from

Conversation

rubennoro
Copy link
Contributor

@rubennoro rubennoro commented Nov 24, 2024

-Implemented High Pass Algorithm with scale and alpha factors
-Code doesn't build because of issues with PCA driver code, don't think those are relevant

Any other notes go here

Test Cases

  • Case A
  • Edge case
  • ...

To Do

Any remaining things that need to get done

  • item 1
  • ...

Checklist

It can be helpful to check the Checks and Files changed tabs.
Please reach out to your Project Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.

  • All commits are tagged with the ticket number
  • No merge conflicts
  • All checks passing
  • Remove any non-applicable sections of this template
  • Assign the PR to yourself
  • Request reviewers & ping on Slack
  • PR is linked to the ticket (fill in the closes line below)

Closes #178 (issue #178 )

Copy link
Contributor

@dyldonahue dyldonahue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the algorithm is good ( i dont have correct ones memorized by heart, but this seems roughly correct so i trust you sourced it well.

only issueS

  1. There isnt any room to add a new data point. The way this would likely to be used is that u create the filter, and can over time, add a new data point (ie, one more buffer). If done correctly, you shouldnt need to store the value of SAMPLES worth of data. Just the current data point, and the summation of the output up until this (prev_sum)

  2. Right now, could only b used in one place/for one thing. Else, if you try and have two high pass filters, the data will combine and the static variables will belnd together.

the best solution is to create a high pass filter struct object, and instead of using statci variables, you store those as members of the struct, that way we can create multiple instances of the struct.

Id create a "high pass filter init" function that creates and returns a high pass filter object with a given alpha and scale, and the current "high_pass" API u have would just take in the new data point and the hgih pass object which should give access to the static data needed

@@ -5,8 +5,7 @@
#include <stdint.h>

/*
PCA 9539 16 bit GPIO expander. Datasheet:
https://www.ti.com/lit/ds/symlink/pca9539.pdf?ts=1716785085909
PCA 9539 16 bit GPIO expander. Datasheet: https://www.ti.com/lit/ds/symlink/pca9539.pdf?ts=1716785085909
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PCA changes shouldn't be in this PR


#include <stdio.h>

int high_pass(int alpha, int scale);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no functions for the user to pass a value through the filter.

{
static float buffer[SAMPLES] = { 0 }; //initialize changing buffer
static int index = 0;
static float prev_sum = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation does not allow for using multiple filters at once.


//Scale Var allows adjustment of output strength
//Alpha Var controls weight of prev input & sum difference
float high_pass(int alpha, int scale)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these values be ints? Floats might also be useful here.


#include <stdio.h>

int high_pass(int alpha, int scale);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation for the function should be in the header file and use doxygen, javadoc style comments.

#include "high_pass.h"

//Samples can be modified
#define SAMPLES 12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this modifiable by the user. They should not have to edit code in embedded base. This also should be available to be edited on a per high-pass filter level.


float prev_output;

} high_pass_st;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention when defining a type (atleast in our codebases) is to append _t to the type, so this should be high_pass_t

void high_pass_init(float alpha, float scale, high_pass_st filter);
/**
@brief Initialization for high pass values
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doxygen comments go above the function, and explain the parameters and what the function returns (if it returns anything)

@@ -0,0 +1,43 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete notes from this if they won't be relevant to future programmers.


void high_pass_init(float alpha, float scale, high_pass_st filter)
{
filter->alpha = alpha;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect syntax and will not compile

* @param alpha
* @param scale
* @param filter
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fill in doc comments

@Sabramz Sabramz requested a review from dyldonahue December 5, 2024 17:23
@Sabramz Sabramz removed the request for review from dyldonahue December 21, 2024 04:10
@Sabramz Sabramz dismissed dyldonahue’s stale review December 21, 2024 04:12

bro should enjoy his retirement

@Sabramz
Copy link
Contributor

Sabramz commented Dec 21, 2024

Looks good. Merge after thorough testing.

@Sabramz
Copy link
Contributor

Sabramz commented Dec 21, 2024

Outline the test cases tested in the header of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Develop a high pass filter algorithm
3 participants