atoombom

Dependencies:   Encoder HIDScope mbed

Fork of EMG by Tom Tom

Files at this revision

API Documentation at this revision

Comitter:
Bartvaart
Date:
Mon Sep 28 10:25:22 2015 +0000
Parent:
19:6eefdb204444
Commit message:
Hoi Richard hier is een zeer geheim bestand over het filteren van EMG signalen

Changed in this revision

Encoder.lib Show annotated file Show diff for this revision Revisions of this file
LowPassFilter.cpp Show annotated file Show diff for this revision Revisions of this file
LowPassFilter.h 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/Encoder.lib	Mon Sep 28 10:25:22 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/vsluiter/code/Encoder/#18b000b443af
--- a/LowPassFilter.cpp	Mon Sep 28 10:12:00 2015 +0000
+++ b/LowPassFilter.cpp	Mon Sep 28 10:25:22 2015 +0000
@@ -1,21 +1,16 @@
 #include "encoder.h"
-#include "led_flipper.h"
+#include "LowPassFilter.h"
 
 // Define a Ticker, variables for storage, input and 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;
 // Implement the computation function
-void computeBiquad()
+double computeBiquad()
 {
-    double v = u − a1∗v1 − a2∗v2;
-    y = b0∗v + b1∗v1 + b2∗v2;
+    double v = u - a1*v1 - a2*v2;
+    y = b0*v + b1*v1 + b2*2;
     v2 = v1;
     v1 = v;
+    return y;
 }
-
-double filter()
-{
-    biquadTicker.attach(&computeBiquad, 0.01); // 100 Hz
-    while(1) {}
-}
\ No newline at end of file
--- a/LowPassFilter.h	Mon Sep 28 10:12:00 2015 +0000
+++ b/LowPassFilter.h	Mon Sep 28 10:25:22 2015 +0000
@@ -1,4 +1,3 @@
 #include "mbed.h"
 // Header zend de "functies"(cpp) bestanden goed door naar main
-void filter();
-void computeBiquad();
\ No newline at end of file
+double computeBiquad();
\ No newline at end of file
--- a/main.cpp	Mon Sep 28 10:12:00 2015 +0000
+++ b/main.cpp	Mon Sep 28 10:25:22 2015 +0000
@@ -1,6 +1,6 @@
 #include "mbed.h"
 #include "HIDScope.h"
-//#include "LowPassFilter.h"
+#include "LowPassFilter.h"
 
 //Define objects
 AnalogIn    emg(A0); //Analog input
@@ -41,8 +41,10 @@
     * this ensures that 'sample' is executed every... 0.002 seconds
     */
     button.fall(&time);
-    sample_timer.attach(&sample, 0.002);
-
+    sample_timer.attach(&sample, 0.002); //500 Hz
+   
+    biquadTicker.attach(&computeBiquad, 0.01); // 100 Hz
+    
     /*empty loop, sample() is executed periodically*/
     while(1) {}
 }
\ No newline at end of file