Filtre passe bas simple
FiltrePB.cpp@1:999ae031e7c1, 2016-02-15 (annotated)
- Committer:
- garivetm
- Date:
- Mon Feb 15 15:16:59 2016 +0000
- Revision:
- 1:999ae031e7c1
- Parent:
- 0:a5c9e3376d19
- Child:
- 2:46a658fe2f70
Adding sampling time as an argument
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garivetm | 0:a5c9e3376d19 | 1 | #include "FiltrePB.h" |
garivetm | 0:a5c9e3376d19 | 2 | |
garivetm | 1:999ae031e7c1 | 3 | FiltrePB::FiltrePB(){ |
garivetm | 0:a5c9e3376d19 | 4 | } |
garivetm | 0:a5c9e3376d19 | 5 | |
garivetm | 1:999ae031e7c1 | 6 | FiltrePB::FiltrePB(float fc, float Ts){ |
garivetm | 1:999ae031e7c1 | 7 | vep=vsp=0.0; |
garivetm | 1:999ae031e7c1 | 8 | tau=1.0/(fc*2*3.1415); //calcul de la constante de temps |
garivetm | 1:999ae031e7c1 | 9 | a=1.0/(1+(2*tau/Ts)); //calcul du coefficient a du filtre |
garivetm | 1:999ae031e7c1 | 10 | b=(1-(2*tau/Ts))*a; //calcul du coefficient b du filtre |
garivetm | 1:999ae031e7c1 | 11 | } |
garivetm | 1:999ae031e7c1 | 12 | |
garivetm | 1:999ae031e7c1 | 13 | float FiltrePB::FiltreExe(float ve){ |
garivetm | 0:a5c9e3376d19 | 14 | vs=a*ve+a*vep+b*vsp; |
garivetm | 0:a5c9e3376d19 | 15 | vep=ve; |
garivetm | 0:a5c9e3376d19 | 16 | vsp=vs; |
garivetm | 0:a5c9e3376d19 | 17 | return vs; |
garivetm | 0:a5c9e3376d19 | 18 | } |
garivetm | 0:a5c9e3376d19 | 19 |