calibrate

Dependencies:   FastPWM MODSERIAL QEI mbed

Revision:
0:46c28ea3feb9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 30 15:00:46 2018 +0000
@@ -0,0 +1,72 @@
+#include "mbed.h"
+
+//global variables
+
+double EMG_filt1;
+double EMG_filt2;
+double EMG_filt3;
+double EMG_filt4;
+bool calibrationbool;
+double EMG_max1 = 10000.0; 
+double EMG_max2 = 10000.0;
+double EMG_max3 = 10000.0;
+double EMG_max4 = 10000.0;
+
+void calibrationbutton
+{
+    calibrationbool = true;
+    EMG_max1 = 0.0001;
+    EMG_max2 = 0.0001;
+    EMG_max3 = 0.0001;
+    EMG_max4 = 0.0001;
+    
+}
+
+void switchtostate
+{
+    calibrationbool = false //Dit moet waarschijnlijk anders in het hele script.
+}
+
+void calibratie()
+{
+    static int count
+
+    if     (0.95*EMG_filt1>EMG_max1)
+    {
+        EMG_max1 = 0.95*EMG_filt1;
+    }
+    if     (0.95*EMG_filt2>EMG_max2)
+    
+    {
+        EMG_max2 = 0.95*EMG_filt2;
+    }
+    
+    if     (0.95*EMG_filt3>EMG_max3)
+    {
+            EMG_max3 = 0.95*EMG_filt3;
+    }
+    if     (0.95*EMG_filt4>EMG_max4)
+    {
+        EMG_max4 = 0.95*EMG_filt4;
+    }
+
+        count++;
+        if (count == eengetal)
+        {
+        switchtostate()   
+        }
+    }   
+}
+    
+    InterruptIn button
+    
+
+int main
+{
+    button.fall(calibrationbutton)
+    
+    while (true)
+    {
+        }
+        
+        
\ No newline at end of file