EMG filtering; highpass, notch, abs, moving average

Dependencies:   HIDScope MODSERIAL- mbed-dsp mbed

Files at this revision

API Documentation at this revision

Comitter:
Hooglugt
Date:
Mon Oct 06 13:21:55 2014 +0000
Parent:
29:7523e4a8e000
Child:
31:d8eaf0ce8517
Commit message:
reset van triceps toegevoegd; met een loop die elke 0.1 sec checked of triceps is aangespannen

Changed in this revision

Project_main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Project_main.cpp	Mon Oct 06 12:42:02 2014 +0000
+++ b/Project_main.cpp	Mon Oct 06 13:21:55 2014 +0000
@@ -20,6 +20,7 @@
 int         force = 0;
 
 Ticker log_timer;
+Ticker reset_timer;
 MODSERIAL pc(USBTX,USBRX);
 HIDScope scope(4);
 
@@ -35,9 +36,9 @@
     uint16_t emg_trivalue;
     emg_trivalue = emg1.read_u16();         // read direct ADC result (0..4096 = 0..3.3V) biceps
 
-    /*send value to PC. Line below is used to prevent buffer overrun */ //VRAAG: praktisch nut hiervan? behalve dat het een heleboel spul uitprint
-    if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) {
-        //pc.printf("%u\n",emg_value);
+    /*send value to PC. Line below is used to prevent buffer overrun */ 
+    if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) { //VRAAG: praktisch nut hiervan? print emg value wanneer buffercount groter dan 30 is
+        //pc.printf("%u\n",emg_bivalue);
     }
     scope.set(0,emg_bivalue);
     scope.set(1,emg_bifloat.read());
@@ -46,12 +47,21 @@
     scope.send();
 }
 
+void resetlooper(){
+    if(emg_trifloat.read()>0.8 && direction != 0) { //dit is alleen mogelijk wanneer directionchoice is gemaakt
+        direction = 0;
+        force = 0;              // WEGHALEN, wanneer in uiteindelijke script na force keuzen niet meer gereset kan worden (voor nu wel handig)
+        goto directionchoice;
+    }    
+}
+        
 int main()
 {
     pc.baud(115200); //baudrate instellen
     emg_bifloat.period_ms(2); //sets period for the PWM to the emgfloat PTD4
     emg_trifloat.period_ms(2);
     log_timer.attach(looper, 0.001); // The looper() function will be called every 0.001 seconds (with the ticker object)
+    reset_timer.attach(resetlooper, 0.1); //
 
     goto directionchoice; // goes to first while(1) for the deciding the direction