EMG filtering; highpass, notch, abs, moving average

Dependencies:   HIDScope MODSERIAL- mbed-dsp mbed

Files at this revision

API Documentation at this revision

Comitter:
wbuysman
Date:
Mon Sep 29 13:26:03 2014 +0000
Parent:
16:370858b84fe5
Child:
18:ff4fce36d1c8
Commit message:
3 Leds ingesteld als confirmatie keuze

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Sep 29 13:16:35 2014 +0000
+++ b/main.cpp	Mon Sep 29 13:26:03 2014 +0000
@@ -33,14 +33,14 @@
 {
     /*variable to store value in*/
     uint16_t emg_value;
-    /*put raw emg value both in red and in emg_value*/
-    red.write(emg0.read());      // read float value (0..1 = 0..3.3V)
+    /*put raw emg value both in emgfloat and in emg_value*/
+    emgfloat.write(emg0.read());      // read float value (0..1 = 0..3.3V)
     emg_value = emg0.read_u16(); // read direct ADC result (0..4096 = 0..3.3V)
     /*send value to PC. Line below is used to prevent buffer overrun */
     if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30)
         pc.printf("%u\n",emg_value);
     scope.set(0,emg_value);
-    scope.set(1,red.read());
+    scope.set(1,emgfloat.read());
     scope.send();
     /**When not using the LED, the above could also have been done this way:
     * pc.printf("%u\n", emg0.read_u16());
@@ -53,8 +53,8 @@
 {
     /*setup baudrate. Choose the same in your program on PC side*/
     pc.baud(115200);
-    /*set the period for the PWM to the red LED*/
-    red.period_ms(2);
+    /*set the period for the PWM to the emgfloat PTD4*/
+    emgfloat.period_ms(2);
     /**Here you attach the 'void looper(void)' function to the Ticker object
     * The looper() function will be called every 0.001 seconds.
     * Please mind that the parentheses after looper are omitted when using attach.
@@ -63,11 +63,15 @@
     while(1) { //Loop
         for(i=1, i<4, i++) {
             if(i=1) {           //red
+                red=0;
+                green=1;
+                blue=1;
                 for(lag=0.0, lag<5.0, lag = lag + 0.1) {
-                    if(red.read()>0.8) {                    //red andere naam! 0.8 klopt niet als grenswaarde. #nofilter
+                    if(emgfloat.read()>0.8) {                    // 0.8 klopt niet als grenswaarde. #nofilter
                         DIRECTION = 1;
-                        blue = 0.95;
-                        green = 0.95;
+                        blue = 0;
+                        green = 0;
+                        red=1;
                         wait(2);                            // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
                     } else {
                         wait(0.1);
@@ -75,11 +79,15 @@
                 }
             }
             if(i=2) {           //green
+                red =1;
+                green=0;
+                blue=1;
                 for(lag=0.0, lag<5.0, lag = lag + 0.1) {
-                    if(red.read()>0.8) {                    //red andere naam! 0.8 klopt niet als grenswaarde. #nofilter
+                    if(emgfloat.read()>0.8) {                    //0.8 klopt niet als grenswaarde. #nofilter
                         DIRECTION = 2;
-                        blue = 0.95;
-                        green = 0.95;
+                        blue = 0;
+                        green = 1;
+                        red=0;
                         wait(2);                            // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
                     } else {
                         wait(0.1);
@@ -87,11 +95,15 @@
                 }
             }
             if(i=3) {           //blue
+                red=1;
+                green=1;
+                blue=0;
                 for(lag=0.0, lag<5.0, lag = lag + 0.1) {
-                    if(red.read()>0.8) {                    //red andere naam! 0.8 klopt niet als grenswaarde. #nofilter
+                    if(emgfloat.read()>0.8) {                    //0.8 klopt niet als grenswaarde. #nofilter
                         DIRECTION = 3;
-                        blue = 0.95;
-                        green = 0.95;
+                        blue = 1;
+                        green = 0;
+                        red=0;
                         wait(2);                            // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
                     } else {
                         wait(0.1);