filters aangepast en bepaling threshold
Dependencies: HIDScope MODSERIAL biquadFilter mbed
Fork of EMGV3 by
Diff: main.cpp
- Revision:
- 23:624827baffa6
- Parent:
- 22:207d314523ef
- Child:
- 24:6661dd6a1718
--- a/main.cpp Thu Oct 08 17:47:14 2015 +0000 +++ b/main.cpp Thu Oct 08 19:15:14 2015 +0000 @@ -9,7 +9,7 @@ Ticker SampleEMG; Ticker ScopeTimer; Ticker serial; - HIDScope scope(5); + HIDScope scope(4); DigitalOut led(LED_RED); MODSERIAL pc(USBTX, USBRX); @@ -26,13 +26,13 @@ double EMG_right_f2; double EMG_right_abs; double Threshold1 = 0.08; - double Threshold2 = 0.06 + double Threshold2 = 0.06; // coëfficiënten const double BiGainEMG_Lh = 0.723601, BiGainEMG_Ll=0.959332; - const double EMGh_a1 = -1.74355513773*BiGainEMG_Lh, EMGh_a2 = 0.80079826172*BiGainEMG_Lh, EMGh_b0 = 1.0*BiGainEMG_Lh, EMGh_b1 = 1.99999965990*BiGainEMG_Lh, EMGh_b2 = 1.0*BiGainEMG_Lh; //coefficients for high-pass filter - const double EMGl_a1 = 1.91721405106*BiGainEMG_Ll, EMGl_a2 = 0.92055427516*BiGainEMG_Ll, EMGl_b0 = 1.0*BiGainEMG_Ll, EMGl_b1 = 1.99999993582*BiGainEMG_Ll, EMGl_b2 = 1.0*BiGainEMG_Ll; // coefficients for low-pass filter - + const double EMGh_a1 = -1.74355513773*BiGainEMG_Lh, EMGh_a2 = 0.80079826172*BiGainEMG_Lh, EMGh_b0 = 1.0*BiGainEMG_Lh, EMGh_b1 = -1.99697722433*BiGainEMG_Lh, EMGh_b2 = 1.0*BiGainEMG_Lh; //coefficients for high-pass filter + const double EMGl_a1 = 1.91721405106*BiGainEMG_Ll, EMGl_a2 = 0.92055427516*BiGainEMG_Ll, EMGl_b0 = 1.0*BiGainEMG_Ll, EMGl_b1 = 1.99999965990*BiGainEMG_Ll, EMGl_b2 = 1.0*BiGainEMG_Ll; // coefficients for low-pass filter + // Filter creation biquadFilter EMG_highpass (EMGh_a1, EMGh_a2, EMGh_b0, EMGh_b1, EMGh_b2); // creates the high pass filter biquadFilter EMG_lowpass (EMGl_a1, EMGl_a2, EMGl_b0, EMGl_b1, EMGl_b2); // creates the low pass filter @@ -55,10 +55,9 @@ void ScopeSend() { scope.set(0, EMG_left_value); - scope.set(1, EMG_left_f2); - scope.set(2, EMG_left_abs); - scope.set(3, EMG_right_value); - scope.set(4, EMG_right_abs); + scope.set(1, EMG_left_f1); + scope.set(2, EMG_left_f2); + scope.set(3, EMG_left_abs); scope.send(); } @@ -68,7 +67,7 @@ ScopeTimer.attach(&ScopeSend, 0.002); while(1) { - if (EMG_left_abs > Threshold) + if (EMG_left_abs > Threshold1) { led.write(0); }