BiQuadfilter

Dependencies:   HIDScope biquadFilter mbed

Files at this revision

API Documentation at this revision

Comitter:
11i
Date:
Mon Oct 10 14:53:29 2016 +0000
Parent:
0:e8a91f8d53ce
Commit message:
Biquad filter, zou moeten werken, nog niet geprobeerd

Changed in this revision

HIDScope.lib Show annotated file Show diff for this revision Revisions of this file
biquadFilter.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HIDScope.lib	Mon Oct 10 14:53:29 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tomlankhorst/code/HIDScope/#188304906687
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/biquadFilter.lib	Mon Oct 10 14:53:29 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tomlankhorst/code/biquadFilter/#26861979d305
--- a/main.cpp	Mon Oct 10 14:06:18 2016 +0000
+++ b/main.cpp	Mon Oct 10 14:53:29 2016 +0000
@@ -1,23 +1,34 @@
 #include "mbed.h"
+#include "BiQuad.h"
+#include "HIDScope.h"
+
+//Ticker vanuit EMGsample
+Ticker emgSampleTicker;
 
-//Ticker definiëren, variabelen voor opslag, input en output
-Ticker biquadTicker;
-double v1=0,v2=0,u=0,y=0;
-const double a1=1.2,a2=2.3,b0=1.2,b1=2.2,b2=0.3;
+AnalogIn emg(A0); //Analoge ingang voor EMG signaal
+HIDScope (2); // 2 kanalen
+
+BiQuadChain bqc;
+BiQuad bq1( //get numbers from butter filter MATLAB
+BiQuad bq2( //get numbers from butter filter MATLAB
 
 //Implementeren van de functie
-void computeBiquad(){
-    double v=u-a1*v1-a2*v2;
-    y=b0*v+b1*v1+b2*v2;
-    v2=v1;
-    v1=v;
+void emgSample(){
+    double in=emg.read();
+    double out=bqc.step();
+    
+    scope.set(0,in); //channel 0
+    scope.set(1,out); //channel 1
+    
+    scope.send();
     }
 
 
 int main()
 {
-    biquadTicker.attach(&computeBiquad, 0.01f); //frequentie van 100 HZ
-    while(1){
+    bqc.add(&bq1).add(&bq2);
+    emgSampleTicker.attach(&emgSample, 0.01f); //frequentie van 100 HZ
+    while(1){ //niet terugkomen uit de main
         }
     }
 }
\ No newline at end of file