forked from cleanflight/cleanflight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve soft filtering function for reuse
Reorder serial.c *_cut_hz parameters Remove unnecessary dT calculation in luxfloat Restructured filter filter.h fix Luxfloat remove internal dT Void function for gyro fillter
- Loading branch information
1 parent
1a15e5a
commit ce2ea79
Showing
9 changed files
with
86 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* filter.c | ||
* | ||
* Created on: 24 jun. 2015 | ||
* Author: borisb | ||
*/ | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
|
||
#include "common/filter.h" | ||
|
||
|
||
// PT1 Low Pass filter (when no dT specified it will be calculated from the cycleTime) | ||
float filterApplyPt1(float input, filterStatePt1_t *filter, uint8_t f_cut, float dT) { | ||
|
||
// Pre calculate and store RC | ||
if (!filter->RC) { | ||
filter->RC = 1.0f / ( 2.0f * (float)M_PI * f_cut ); | ||
} | ||
|
||
filter->state = filter->state + dT / (filter->RC + dT) * (input - filter->state); | ||
|
||
return filter->state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* filter.h | ||
* | ||
* Created on: 24 jun. 2015 | ||
* Author: borisb | ||
*/ | ||
|
||
typedef struct filterStatePt1_s { | ||
float state; | ||
float RC; | ||
float constdT; | ||
} filterStatePt1_t; | ||
|
||
float filterApplyPt1(float input, filterStatePt1_t *filter, uint8_t f_cut, float dt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters