Pascal van Baardwijk / Mbed 2 deprecated EMG_Controllertest_servo

Dependencies:   HIDScope QEI biquadFilter mbed

Fork of EMG_Controllertest_servo by Leon Klute

Files at this revision

API Documentation at this revision

Comitter:
pbaardwijk
Date:
Tue Oct 25 12:07:53 2016 +0000
Parent:
5:bb77e2a6c1e8
Commit message:
Latest version with a few fixes

Changed in this revision

emg.h 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
servoController.h Show annotated file Show diff for this revision Revisions of this file
--- a/emg.h	Tue Oct 25 11:13:13 2016 +0000
+++ b/emg.h	Tue Oct 25 12:07:53 2016 +0000
@@ -30,6 +30,9 @@
 //Timeout to change state after 10 seconds
 Timeout change_state2;
 
+//led
+DigitalOut led(LED_RED);
+
 //Emg input
 AnalogIn emg0( A0 );
 AnalogIn emg1( A1 );
@@ -68,11 +71,13 @@
 }
 
 void calibrate() {
-    state = STATE_CALIBRATION;  
+    state = STATE_CALIBRATION; 
+    led.write(0); 
 }
 
 void run() {
     state = STATE_RUN;  
+    led.write(1);
 }
 
 void EMG_filter();
--- a/main.cpp	Tue Oct 25 11:13:13 2016 +0000
+++ b/main.cpp	Tue Oct 25 12:07:53 2016 +0000
@@ -76,7 +76,7 @@
     Controller.attach(&Ticker_Flag,1/Frequency);
     pc.baud(9600);
     
-    
+    led.write(1);
     Lift_Input_force =  Potmeter.read();
     Slide_Input_force = Potmeter2.read();
     
@@ -92,7 +92,7 @@
     ServoPWMpin.period(0.01f);                          // 0.01 second period
     
     while (true) {
-        pc.printf("\n\r%f", Norm_EMG_0);
+ //       pc.printf("\n\r%f", Norm_EMG_0);
          
         if (go_emgSample == true){
                 EMG_filter();
--- a/servoController.h	Tue Oct 25 11:13:13 2016 +0000
+++ b/servoController.h	Tue Oct 25 12:07:53 2016 +0000
@@ -2,7 +2,7 @@
 
 Serial pc(USBTX,USBRX);
 
-PwmOut ServoPWMpin(D8);
+PwmOut ServoPWMpin(D9);
 Ticker servoTick;
 float i = 0;
 char Key;
@@ -12,12 +12,13 @@
 //double input_signal = 0;
 double cali_min = 0;
 double cali_max = 1;
-double treshold = 0.5;
+double treshold = 0.3;
 float treshold_multiplier = 0.5;
 bool binary_input_signal = 0;
 bool binary_input_signal_previous = 0;
 
 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
         binary_input_signal = 1;
     } else {