Filtre passe bas simple
Diff: FiltrePB.cpp
- Revision:
- 1:999ae031e7c1
- Parent:
- 0:a5c9e3376d19
- Child:
- 2:46a658fe2f70
--- a/FiltrePB.cpp Mon Feb 15 15:10:52 2016 +0000 +++ b/FiltrePB.cpp Mon Feb 15 15:16:59 2016 +0000 @@ -1,22 +1,16 @@ - #include "FiltrePB.h" -#define NOFFSET 100 -#define HUBLEXR -#define r2d 57.295779513082320876798154814105 -#define PI 3.1415926535897932384626433832795 -FiltrePB::FiltrePB(float fc) -{ - dt=0.01; - vep=vsp=0.0; - tau=1.0/(fc*2*PI); //calcul de la constante de temps - a=1.0/(1+(2*tau/dt)); //calcul du coefficient a du filtre - b=(1-(2*tau/dt))*a; //calcul du coefficient b du filtre - +FiltrePB::FiltrePB(){ } -float FiltrePB::FiltreExe(float ve) -{ +FiltrePB::FiltrePB(float fc, float Ts){ + vep=vsp=0.0; + tau=1.0/(fc*2*3.1415); //calcul de la constante de temps + a=1.0/(1+(2*tau/Ts)); //calcul du coefficient a du filtre + b=(1-(2*tau/Ts))*a; //calcul du coefficient b du filtre +} + +float FiltrePB::FiltreExe(float ve){ vs=a*ve+a*vep+b*vsp; vep=ve; vsp=vs;