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:08:13 2014 +0000
Parent:
14:8addbde24223
Child:
16:370858b84fe5
Commit message:
Begin gemaakt met selectie richting

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Sep 29 12:04:18 2014 +0000
+++ b/main.cpp	Mon Sep 29 13:08:13 2014 +0000
@@ -1,10 +1,16 @@
 #include "mbed.h"
 #include "MODSERIAL.h"
 #include "HIDScope.h"
+#define DIRECTION 0
+#define FORCE 0
 
 //Define objects
 AnalogIn    emg0(PTB1); //Analog input
 PwmOut      red(LED_RED); //PWM output
+PwmOut      green(LED_GREEN);
+PwmOut      blue(LED_BLUE);
+
+
 Ticker log_timer;
 MODSERIAL pc(USBTX,USBRX);
 HIDScope scope(2);
@@ -24,7 +30,7 @@
 **/
 void looper()
 {
-    /*variable to store value in*/    
+    /*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)
@@ -40,6 +46,8 @@
     */
 }
 
+
+
 int main()
 {
     /*setup baudrate. Choose the same in your program on PC side*/
@@ -47,13 +55,27 @@
     /*set the period for the PWM to the red LED*/
     red.period_ms(2);
     /**Here you attach the 'void looper(void)' function to the Ticker object
-    * The looper() function will be called every 0.01 seconds.
+    * The looper() function will be called every 0.001 seconds.
     * Please mind that the parentheses after looper are omitted when using attach.
     */
     log_timer.attach(looper, 0.001);
-    while(1) //Loop
-    {
-      /*Empty!*/
-      /*Everything is handled by the interrupt routine now!*/
+    while(1) { //Loop
+        for(i=1, i<4, i++) {
+            if(i=1) {           //red
+                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
+                        DIRECTION = 1;
+                        red = 0.95;
+                        green = 0.95;
+                        wait(2);                            // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
+                    } else {
+                        wait(0.1);
+                    }
+                }
+            }
+        }
+
+        /*Empty!*/
+        /*Everything is handled by the interrupt routine now!*/
     }
 }
\ No newline at end of file