project script
Dependencies: HIDScope MODSERIAL biquadFilter mbed
Fork of Milestone_sample by
Revision 24:6d63ad38fef7, committed 2018-10-30
- Comitter:
- MarijkeZondag
- Date:
- Tue Oct 30 13:09:58 2018 +0000
- Parent:
- 23:97a976a8f0fc
- Commit message:
- Motoren met 3 spieren aansturen werkt
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 97a976a8f0fc -r 6d63ad38fef7 main.cpp --- a/main.cpp Tue Oct 30 10:37:45 2018 +0000 +++ b/main.cpp Tue Oct 30 13:09:58 2018 +0000 @@ -250,63 +250,46 @@ { while(emg_cal==1) //After calibration is finished, emg_cal will be 1. Otherwise 0. { - // pc.printf("Movag0 = %f , Movag1 = %f, Movag2 = %f \n\r",movAg0, movAg1, movAg2); - // pc.printf("Thresh0 = %f , Thresh1 = %f, Thresh2 = %f \n\r",Threshold0, Threshold1, Threshold2); - // wait(2.0f); - if(movAg0>Threshold0) //If the filtered EMG signal of muscle 0 is higher than the threshold, motor1 will turn in 1 direction + if(movAg0>Threshold0) //If the filtered EMG signal of muscle 0 is higher than the threshold, motor1 will turn in 1 direction { pwmpin1 = 1; directionpin1.write(1); //translatie vooruit - ledr = 1; //Blue + ledr = 1; //Blue ledb = 0; ledg = 1; } - else //If it is not higher than the threshold, the motor will not turn at all. - { - pwmpin1 = 0; - ledr = 0; //white - ledb = 0; - ledg = 0; - } - - if(movAg1>Threshold1) //If the filtered EMG signal of muscle 1 is higher than the threshold, motor2 will turn in 1 direction + else if(movAg1>Threshold1) //If the filtered EMG signal of muscle 1 is higher than the threshold, motor2 will turn in 1 direction { pwmpin2 = 1; - directionpin2.write(0); //rotatie omhoog - ledr = 0; //red + directionpin2.write(1); //rotatie omhoog + ledr = 0; //red ledb = 1; ledg = 1; } - else //If not higher than the threshold, motor will not turn at all + else if(movAg2>Threshold2) //If the filtered EMG signal of muscle 2 is higher than the threshold, motor 1 and 2 will turn { - pwmpin2 = 0; - ledr = 0; //white - ledb = 0; - ledg = 0; - } - // if(movAg2>Threshold2) //If the filtered EMG signal of muscle 2 is higher than the threshold, motor 1 and 2 will turn - //{ - // pwmpin1 = 1; - //pwmpin2 = 1; - // directionpin1.write(0); //translatie achteruit - // directionpin2.write(1); //rotatie omlaag + + pwmpin1 = 1; + pwmpin2 = 1; + directionpin1.write(0); //translatie achteruit + directionpin2.write(0); //rotatie omlaag - //ledr = 1; //green - //ledb = 1; - //ledg = 0; - //} - //else //If not higher than the threshold, motors will not turn at all - //{ - // pwmpin1 = 0; - // pwmpin2 = 0; + ledr = 1; //green + ledb = 1; + ledg = 0; + } + else //If not higher than the threshold, motors will not turn at all + { + pwmpin1 = 0; //Motoren doen niets + pwmpin2 = 0; - // ledr = 0; //white - // ledb = 0; - // ledg = 0; - //} + ledr = 0; //white + ledb = 0; + ledg = 0; + } break; } @@ -332,9 +315,9 @@ // HIDScope_tick.attach(&HIDScope_sample,T); //EMG signals raw + filtered to HIDScope every T sec. button1.rise(switch_to_calibrate); //Switch state of calibration (which muscle) - wait(0.2f); + wait(0.2f); //Wait to avoid bouncing of button button2.rise(calibrate); //Calibrate threshold for 3 muscles - wait(0.2f); + wait(0.2f); //Wait to avoid bouncing of button pc.printf("x is %i\n\r",x); pc.printf("Movag0 = %f , Movag1 = %f, Movag2 = %f \n\r",movAg0, movAg1, movAg2);