Het complete motorscript met alle gewenste functies
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of Motor_EMG_Definitief by
Diff: main.cpp
- Revision:
- 4:92a3b38a5302
- Parent:
- 3:86ca263a83dc
- Child:
- 5:98cf456b08d7
--- a/main.cpp Thu Oct 22 10:59:03 2015 +0000 +++ b/main.cpp Mon Oct 26 19:56:49 2015 +0000 @@ -48,8 +48,8 @@ double position2 = 0, position1 = 0; double m2_ref = 0, m1_ref = 0; int count = 0; - double Grens2 = 90, Grens1 = 90; - double Stapgrootte = 5; + double Grens2 = 70, Grens1 = 70; + double Stapgrootte = 1; // Declaring variables double EMG_L_f_v1 = 0, EMG_L_f_v2 = 0; @@ -324,24 +324,24 @@ if ((EMG_right_MAF >= Threshold3) && (EMG_left_MAF <= Threshold1)) //if(c == 'r') // { m2_ref = m2_ref + Stapgrootte; - m1_ref = m1_ref - Stapgrootte; + m1_ref = m1_ref + Stapgrootte; if (m2_ref > Grens2) { m2_ref = Grens2; - m1_ref = -1*Grens1; + m1_ref = Grens1; } - wait(0.1); + wait(0.05); } if((EMG_right_MAF < Threshold3) && (EMG_left_MAF > Threshold1)) //if (c == 'f') // { m2_ref = m2_ref - Stapgrootte; - m1_ref = m1_ref + Stapgrootte; + m1_ref = m1_ref - Stapgrootte; if (m2_ref < -1*Grens2) { m2_ref = -1*Grens2; - m1_ref = Grens1; + m1_ref = -1*Grens1; } - wait(0.1); + wait(0.05); } } // PROGRAM 1: Motor 1 control, Red LED @@ -349,7 +349,7 @@ { LedG = LedB = 1; LedR = 0; - if ((EMG_right_MAF >= Threshold3) && (EMG_left_MAF <= Threshold1)) // if(c == 't') // + if ((EMG_right_MAF <= Threshold3) && (EMG_left_MAF >= Threshold1)) // if(c == 't') // { m1_ref = m1_ref + Stapgrootte; @@ -357,9 +357,9 @@ { m1_ref = Grens1; } - wait(0.1); + wait(0.05); } - if ((EMG_left_MAF > Threshold1) && (EMG_right_MAF < Threshold3)) //if(c == 'g') // + if ((EMG_left_MAF < Threshold1) && (EMG_right_MAF > Threshold3)) //if(c == 'g') // { m1_ref = m1_ref - Stapgrootte; @@ -367,7 +367,7 @@ { m1_ref = -1*Grens1; } - wait(0.1); + wait(0.05); } } // PROGRAM 2: Firing mechanism & Reset, Blue LED