Tim Luten / Mbed 2 deprecated DEMO_TEST_LIJN

Dependencies:   Demo_TEST3 QEI biquadFilter mbed

Fork of Demo_TEST3 by Biorobotica TIC

Files at this revision

API Documentation at this revision

Comitter:
Hubertus
Date:
Thu Oct 18 13:46:33 2018 +0000
Parent:
0:df553b18547d
Child:
2:36ad60c0aa01
Commit message:
Calibratie goed voor mekaar (NOTCH HP ABS LP MOVAG)

Changed in this revision

Servo.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/Servo.lib	Thu Oct 18 13:46:33 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
--- a/main.cpp	Wed Oct 17 11:19:42 2018 +0000
+++ b/main.cpp	Thu Oct 18 13:46:33 2018 +0000
@@ -1,12 +1,16 @@
 #include "mbed.h"
 #include "math.h"
 #include "BiQuad.h"
+//#include "Servo.h"
 #include "HIDScope.h"
 
+
+//Servo myservo(D7);
 //Define objects
 AnalogIn    emgL( A0 );                                                         // EMG Left Arm
 AnalogIn    emgR( A1 );                                                         // EMG Right Arm
 DigitalOut  ledB(LED_BLUE);                                                     // Informative LED for gaining zero and max
+DigitalOut  ledR(LED_RED);
 DigitalOut  ledG(LED_GREEN);                                                    // Informative LED for gaining zero and max
 DigitalIn   TestButton(PTA4);                                                   // Button used for gaining zero and max
 DigitalIn   onoff(PTC6);                                                        // Button used for switching between zero and max
@@ -51,15 +55,19 @@
 
 void emgSample() {                                                              // EMG function
     
-    double emgFilteredR = bqcR.step( emgR.read() );                             // Filtered value of EMG signal right biceps
-    double emgFilteredL = bqcL.step( emgL.read());                              // Filtered value of EMG signal left biceps
-    double emgabsR = abs(emgFilteredR);                                         // Absolute value of EMG signal right biceps
-    double emgabsL = abs(emgFilteredL);                                         // Absolute value of EMG signal left biceps
+    double emgFilteredR = bqcR.step( emgR.read() );  
+    double emgabsR = abs(emgFilteredR);                                         // Absolute value of EMG signal right biceps          
+    
+    double emgNOFilteredL = bq3L.step(emgL.read());                          // Filtered HP value of EMG signal left biceps                
+    double emgHPFilteredL = bq2L.step(emgNOFilteredL);                            // Filtered HP value of EMG signal left biceps
+    double emgabsL = abs(emgHPFilteredL);                                       // Absolute value of EMG signal left biceps
+    double emgLPFilteredL = bq1L.step(emgabsL);                                 // Filtered HP value of EMG signal left biceps
+    
     
     
     for(int i = P-1; i >= 0; i--){                                              // For-loop used for moving average
         if (i == 0) {
-            A[i] = emgabsL;
+            A[i] = emgLPFilteredL;
             }
          else {
              A[i] = A[i-1];
@@ -98,7 +106,12 @@
     if (TestButton==0 & k<200) {                                                // Loop used for gaining max and zero value
         Lvector[k] = movmeanL;
         Rvector[k] = movmeanR;
-        ledB = !ledB;
+        if (x==0){
+        ledB = !ledB;                                                           // SPIER NIET AANSPANNEN BIJ BLAUW
+        }                                                                       // SPIER WEL AANSPANNEN BIJ ROOD
+        else if (x==1){
+        ledR = !ledR;
+        }
         k++;
     }    
     else if (k==200) {                                                          // End of the loop, used for calculation value
@@ -112,6 +125,7 @@
         Rwaarde[x] = sumZ/200;                                                  // Value of zero for rigth biceps
         k++;
         ledB = 1;
+        ledR = 1;
         ledG = !ledG;
     }
     else if (k == 201 && onoff ==0) {                                           // Loop used for switching between zero and max
@@ -153,11 +167,20 @@
 {  
 ledB = 1;
 ledG = 1;
+ledR = 1;
 bqcR.add( &bq1R ).add( &bq2R ).add( &bq3R );                                    // Filter for emg signal
-bqcL.add( &bq1L ).add( &bq2L ).add( &bq3L );                                    // Filter for emg signal
 emgSampleTicker.attach( &emgSample, 0.002 );                                    // Ticker for EMG function
 Lwaarde[0] = 0.01;                                                              // Startvalue for zerovalue, to - 
 Rwaarde[0] = 0.01;                                                              // - prevent dividing by 0
     while(1) {
+       // 
+//        if (movmeanL > (0.02))
+//        {   myservo = 0.5;
+//            wait(0.01);
+//        }
+//        else {
+//            myservo = 0.0;
+//            wait(0.01);
+//            }
     }
 }
\ No newline at end of file