This is with minumum of 10 milliseconds threshold delay 00:53
Dependencies: biquadFilter MODSERIAL QEI Servo mbed
Fork of StateMachine_EMg_RKI_PID_MOTOR_metklikenalles by
Diff: main.cpp
- Revision:
- 17:008587f85301
- Parent:
- 16:438b330f5312
- Child:
- 18:9d59ee0e459f
--- a/main.cpp Thu Nov 01 22:00:34 2018 +0000 +++ b/main.cpp Thu Nov 01 23:53:30 2018 +0000 @@ -43,6 +43,11 @@ Ticker threshold_check_ticker; Timer t; //timer try out for Astrid Timer timer_calibration; //timer for EMG calibration +Timer threshold_timer1; +Timer threshold_timer2; +Timer threshold_timer3; +Timer threshold_timer4; + //Input system AnalogIn emg1(A0); //right biceps @@ -265,29 +270,56 @@ //Check if emg_filtered has reached their threshold void threshold_check() { - //EMG1 threshold check if(emg1_filtered>threshold1) { - bicepsR = 1; + threshold_timer1.start(); + if(threshold_timer1.read_ms()>10) { + bicepsR = 1; + } else { + bicepsR = 0; + } } else { + threshold_timer1.stop(); + threshold_timer1.reset(); bicepsR= 0; } //EMG2 threshold check if(emg2_filtered>threshold2) { - tricepsR = 1; + threshold_timer2.start(); + if(threshold_timer2.read_ms()>10) { + tricepsR = 1; + } else { + tricepsR = 0; + } } else { + threshold_timer2.stop(); + threshold_timer2.reset(); tricepsR= 0; } //EMG3 threshold check if(emg3_filtered>threshold3) { - bicepsL = 1; + threshold_timer3.start(); + if(threshold_timer3.read_ms()>10) { + bicepsL = 1; + } else { + bicepsL = 0; + } } else { - bicepsL= 0; + threshold_timer3.stop(); + threshold_timer3.reset(); + bicepsR= 0; } //EMG4 threshold check if(emg4_filtered>threshold4) { - tricepsL = 1; + threshold_timer4.start(); + if(threshold_timer4.read_ms()>10) { + tricepsL = 1; + } else { + tricepsL= 0; + } } else { + threshold_timer4.stop(); + threshold_timer4.reset(); tricepsL= 0; }