met printstatements 1

Dependencies:   HIDScope MODSERIAL PID QEI biquadFilter mbed

Fork of EMG_5 by Ralph Gerlings

Revision:
26:c9ba45bdd5c9
Parent:
25:07187cf76863
Child:
27:ca07f895f999
--- a/main.cpp	Thu Nov 03 14:58:42 2016 +0000
+++ b/main.cpp	Thu Nov 03 15:20:48 2016 +0000
@@ -82,15 +82,15 @@
             emg1peak = filterpeak1.step(emg1lowfilter); /* 4dB gain peak */
             
             if (max1<emg1peak){
-                max1 = emg1peak;
+                max1 = emg1peak; /* set the max value at the highest measured value */
             }
-            wait(0.001f);    
+            wait(0.001f); /* measure at 1000Hz */   
             }
             wait(0.2f);
             green = 1;
     }
-    maxpart1 = 0.25*max1;
-    maxpart2 = 0.15*max1;
+    maxpart1 = 0.25*max1; /* set cut off voltage at 25% of max for right biceps */
+    maxpart2 = 0.15*max1; /* set cut off votage at 15% of max for left biceps */
 }
 
 void get_max3(){
@@ -108,14 +108,14 @@
             emg3peak = filterpeak3.step(emg3lowfilter);
             
             if (max3<emg3peak){
-                max3 = emg3peak;
+                max3 = emg3peak; /* set the max value at the highest measured value */
             }
             wait(0.001f);    
             }
             wait(0.2f);
             red = 1;
     }
-    maxpart3 = 0.25*max3;
+    maxpart3 = 0.25*max3; /* set cut off voltage at 25% of max for right biceps */
 }
 
 // Filtering & Scope
@@ -126,56 +126,56 @@
     emg1notchfilter = filternotch1.step(emg1highfilter);
     emg1abs = fabs(emg1notchfilter);
     emg1lowfilter = filterlow1.step(emg1abs);
-    emg1peak = filterpeak1.step(emg1lowfilter);
+    emg1peak = filterpeak1.step(emg1lowfilter); /* Final Right Biceps values to be sent */
     // Left Biceps
     emg2 = emg2_in.read();
     emg2highfilter = filterhigh2.step(emg2);
     emg2notchfilter = filternotch2.step(emg2highfilter);
     emg2abs = fabs(emg2notchfilter);
     emg2lowfilter = filterlow2.step(emg2abs);
-    emg2peak = filterpeak2.step(emg2lowfilter);
+    emg2peak = filterpeak2.step(emg2lowfilter); /* Final Left Biceps values to be sent */
     // Left Lower Arm OR Triceps
     emg3 = emg3_in.read();
     emg3highfilter = filterhigh3.step(emg3);
     emg3notchfilter = filternotch3.step(emg3highfilter);
     emg3abs = fabs(emg3notchfilter);
     emg3lowfilter = filterlow3.step(emg3abs);
-    emg3peak = filterpeak3.step(emg3lowfilter);
+    emg3peak = filterpeak3.step(emg3lowfilter); /* Final Lower Arm values to be sent */
     
     
     /* Compare measurement to the calibrated value to decide actions */
-    if (maxpart1<emg1peak){
+    if (maxpart1<emg1peak){ /* See if right biceps is contracting */
         red = 0;
         blue = 1;
         green = 1;
         }
     else {
-        if (maxpart2<emg2peak){
+        if (maxpart2<emg2peak){ /* See if left biceps is contracting */
             red = 1;
             blue = 0;
             green = 1;
             }
         
     else {
-        if (maxpart3<emg3peak){
+        if (maxpart3<emg3peak){ /* See if lower arm is contracting */
             red = 1;
             blue = 1;
             green = 0;
             }
         
     else {
-        red = 1;
+        red = 1; /* Shut down all led colors if no movement is registered */
         blue = 1;
         green = 1;
         }
         }
         }
     /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */
-    scope.set(0, emg1peak );
-    scope.set(1, emg2peak );
-    scope.set(2, maxpart1 );
-    scope.set(3, emg3peak );
-    scope.set(4, maxpart3 );    
+    scope.set(0, emg1peak ); /* plot Right biceps voltage */
+    scope.set(1, emg2peak ); /* Plot Left biceps voltage */
+    scope.set(2, maxpart1 ); /* Show the line above which the motor should run for right biceps */
+    scope.set(3, emg3peak ); /* Plot Lower Arm voltage */
+    scope.set(4, maxpart3 ); /* Plot the line above which the motor should run for lower arm */
  
     scope.send(); /* send everything to the HID scope */
 }