BiQuadfilter

Dependencies:   HIDScope biquadFilter mbed

Committer:
11i
Date:
Mon Oct 10 14:06:18 2016 +0000
Revision:
0:e8a91f8d53ce
Child:
1:fb8d21c27ce0
Problematic biquad filter (niet handig)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
11i 0:e8a91f8d53ce 1 #include "mbed.h"
11i 0:e8a91f8d53ce 2
11i 0:e8a91f8d53ce 3 //Ticker definiëren, variabelen voor opslag, input en output
11i 0:e8a91f8d53ce 4 Ticker biquadTicker;
11i 0:e8a91f8d53ce 5 double v1=0,v2=0,u=0,y=0;
11i 0:e8a91f8d53ce 6 const double a1=1.2,a2=2.3,b0=1.2,b1=2.2,b2=0.3;
11i 0:e8a91f8d53ce 7
11i 0:e8a91f8d53ce 8 //Implementeren van de functie
11i 0:e8a91f8d53ce 9 void computeBiquad(){
11i 0:e8a91f8d53ce 10 double v=u-a1*v1-a2*v2;
11i 0:e8a91f8d53ce 11 y=b0*v+b1*v1+b2*v2;
11i 0:e8a91f8d53ce 12 v2=v1;
11i 0:e8a91f8d53ce 13 v1=v;
11i 0:e8a91f8d53ce 14 }
11i 0:e8a91f8d53ce 15
11i 0:e8a91f8d53ce 16
11i 0:e8a91f8d53ce 17 int main()
11i 0:e8a91f8d53ce 18 {
11i 0:e8a91f8d53ce 19 biquadTicker.attach(&computeBiquad, 0.01f); //frequentie van 100 HZ
11i 0:e8a91f8d53ce 20 while(1){
11i 0:e8a91f8d53ce 21 }
11i 0:e8a91f8d53ce 22 }
11i 0:e8a91f8d53ce 23 }