4 directional EMG control of the XY table. Made during my bachelor end assignment.
Dependencies: C12832_lcd HIDScope mbed-dsp mbed
Revision 43:42bfab67c4a5, committed 2015-06-04
- Comitter:
- jessekaiser
- Date:
- Thu Jun 04 14:34:04 2015 +0000
- Parent:
- 42:e67627d11789
- Child:
- 44:d5aa53e4778c
- Commit message:
- Aansturing motor 2 emg signalen;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jun 03 14:26:56 2015 +0000 +++ b/main.cpp Thu Jun 04 14:34:04 2015 +0000 @@ -109,7 +109,7 @@ step_freq1 = (setpoint*speed1); speed_old1 = speed1; - //Achteruit + //Achteruit triceps force2 = K_Gain*(filtered_triceps/MAX_tri); force2 = force2 - damping2; acc2 = force2/Mass; @@ -117,14 +117,15 @@ damping2 = speed2 * Damp; step_freq2 = (setpoint*speed2); speed_old2 = speed2; - if (filtered_biceps > filtered_triceps) { Dir = 0; - step_freq2 = 1; + speed2 = 0.01; + speed_old2 = 0.01; Step.period(1.0/step_freq1); } if (filtered_triceps > filtered_biceps) { Dir = 1; - step_freq1 = 1; + speed1 = 0.01; + speed_old1 = 0.01; Step.period(1.0/step_freq2); } //Speed limit @@ -132,13 +133,13 @@ speed1 = 1; step_freq1 = setpoint; } - if (speed2 > 2) { + if (speed2 > 1) { speed2 = 1; - step_freq1 = setpoint; + step_freq2 = setpoint; } //EMG treshold if (filtered_biceps < EMG_tresh && filtered_triceps < EMG_tresh) { - Enable = 1; + Enable = 1; //Enable = 1 turns the motor off. } else { Enable = 0; }