Leon Klute / Mbed 2 deprecated EMG_Controller

Dependencies:   HIDScope QEI biquadFilter mbed

Fork of EMG_Controllertest_servo by Pascal van Baardwijk

Files at this revision

API Documentation at this revision

Comitter:
LeeJon
Date:
Wed Oct 26 07:59:31 2016 +0000
Parent:
7:eed677b636d3
Commit message:
nu met 1 seconde wachttijd na het lezen van een puls

Changed in this revision

servoController.h Show annotated file Show diff for this revision Revisions of this file
--- a/servoController.h	Tue Oct 25 12:35:29 2016 +0000
+++ b/servoController.h	Wed Oct 26 07:59:31 2016 +0000
@@ -2,13 +2,19 @@
 
 Serial pc(USBTX,USBRX);
 PwmOut ServoPWMpin(D9);
+Timeout resetter;
 
+bool readtime = 1;
 double ServoAngle = 89 ;
 float Pulsew = 0.0015;
 double treshold = 0.3;
 bool binary_input_signal = 0;
 bool binary_input_signal_previous = 0;
 
+void set21(){
+    readtime = 1;
+}
+
 void control_servo(double input_signal){
     pc.printf("/n/r %f", input_signal);
     if (input_signal > treshold){                        // convert the emg to a zero or a one
@@ -16,7 +22,9 @@
     } else {
         binary_input_signal = 0;
     }
-    if(( binary_input_signal!= binary_input_signal_previous)&& binary_input_signal){
+    if((( binary_input_signal!= binary_input_signal_previous)&& binary_input_signal)&& readtime){
+        readtime = 0;
+        resetter.attach(&set21, 1);
         if( ServoAngle < 45){                           // check wether it is more opened or closed
             ServoAngle = 89;                            // open 
         }