Filtre passe bas simple
FiltrePB.cpp@0:a5c9e3376d19, 2016-02-15 (annotated)
- Committer:
- garivetm
- Date:
- Mon Feb 15 15:10:52 2016 +0000
- Revision:
- 0:a5c9e3376d19
- Child:
- 1:999ae031e7c1
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garivetm | 0:a5c9e3376d19 | 1 | |
garivetm | 0:a5c9e3376d19 | 2 | #include "FiltrePB.h" |
garivetm | 0:a5c9e3376d19 | 3 | #define NOFFSET 100 |
garivetm | 0:a5c9e3376d19 | 4 | #define HUBLEXR |
garivetm | 0:a5c9e3376d19 | 5 | #define r2d 57.295779513082320876798154814105 |
garivetm | 0:a5c9e3376d19 | 6 | #define PI 3.1415926535897932384626433832795 |
garivetm | 0:a5c9e3376d19 | 7 | |
garivetm | 0:a5c9e3376d19 | 8 | FiltrePB::FiltrePB(float fc) |
garivetm | 0:a5c9e3376d19 | 9 | { |
garivetm | 0:a5c9e3376d19 | 10 | dt=0.01; |
garivetm | 0:a5c9e3376d19 | 11 | vep=vsp=0.0; |
garivetm | 0:a5c9e3376d19 | 12 | tau=1.0/(fc*2*PI); //calcul de la constante de temps |
garivetm | 0:a5c9e3376d19 | 13 | a=1.0/(1+(2*tau/dt)); //calcul du coefficient a du filtre |
garivetm | 0:a5c9e3376d19 | 14 | b=(1-(2*tau/dt))*a; //calcul du coefficient b du filtre |
garivetm | 0:a5c9e3376d19 | 15 | |
garivetm | 0:a5c9e3376d19 | 16 | } |
garivetm | 0:a5c9e3376d19 | 17 | |
garivetm | 0:a5c9e3376d19 | 18 | float FiltrePB::FiltreExe(float ve) |
garivetm | 0:a5c9e3376d19 | 19 | { |
garivetm | 0:a5c9e3376d19 | 20 | vs=a*ve+a*vep+b*vsp; |
garivetm | 0:a5c9e3376d19 | 21 | vep=ve; |
garivetm | 0:a5c9e3376d19 | 22 | vsp=vs; |
garivetm | 0:a5c9e3376d19 | 23 | return vs; |
garivetm | 0:a5c9e3376d19 | 24 | } |
garivetm | 0:a5c9e3376d19 | 25 |