
eindscript the slap
Dependencies: Encoder HIDScope MODSERIAL TextLCD mbed-dsp mbed
Revision 4:305671faeb2b, committed 2014-11-03
- Comitter:
- DominiqueC
- Date:
- Mon Nov 03 19:57:46 2014 +0000
- Parent:
- 3:fbe46d4e4b3f
- Child:
- 5:060d376291b5
- Commit message:
- oude hoek!!
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 03 19:15:03 2014 +0000 +++ b/main.cpp Mon Nov 03 19:57:46 2014 +0000 @@ -28,9 +28,9 @@ #define K_D_GM (0.00000001 /TSAMP) #define I_LIMIT 1. #define RADTICKGM 0.003927 -#define THETADOT0 16 //oud 6.85 -#define THETADOT1 16 //oud 7.77 -#define THETADOT2 16 //oud 9.21 +#define THETADOT0 6.85 +#define THETADOT1 7.77 +#define THETADOT2 9.21 TextLCD lcd(PTD2, PTA12, PTB2, PTB3, PTC2, PTA13); @@ -171,10 +171,10 @@ while(true) { switch(state) { case RUST: { //Aanzetten - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf(" --THE SLAP -- "); //regel 1 LCD scherm - lcd.locate(0,1); + lcd.locate(0,1); lcd.printf(" GROEP 5 "); //regel 2 LCD scherm wait(5); state = KALIBRATIE; @@ -184,14 +184,15 @@ case KALIBRATIE: { //kalibreren met maximale inspanning max_value_biceps=0; max_value_deltoid=0; + //maximale inspanning biceps - lcd.cls(); + lcd.cls(); lcd.locate(0,0); - lcd.printf("Kalibratie1:"); //LCD scherm + lcd.printf("Kalibratie1:"); lcd.locate(0,1); - lcd.printf("Span biceps!"); + lcd.printf("Span biceps!"); wait(5); - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("Meting loopt"); tijdtimer.reset(); @@ -207,14 +208,14 @@ wait(5); //maximale inspanning deltoid - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("Kalibratie2:"); - lcd.locate(0,1); + lcd.locate(0,1); lcd.printf("Span deltoid!"); wait(5); tijdtimer.start(); - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("Meting loopt"); while (tijdtimer.read() <= 3) { @@ -231,9 +232,9 @@ break; }// einde kalibratie case - case RICHTEN: { //batje richten (gebruik biceps en deltoid) + case RICHTEN: { //batje richten (gebruik deltoid) wait(3); - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("Richten"); //regel 1 LCD scherm lcd.locate(0,1); @@ -241,25 +242,24 @@ float setpointkm; float new_pwm_km; wait(5); - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("Meting loopt"); float kalibratiewaarde_deltoid; kalibratiewaarde_deltoid=(envelop_emg1/max_value_deltoid); - //pc.printf("deltoid %f\n\r", kalibratiewaarde_deltoid); //WEGHALEN LATER if (kalibratiewaarde_deltoid >= 0.35) { - setpointkm = -343.57; //11,12 (-127)graden naar links//30 graden (-343.57) naar links - lcd.cls(); + setpointkm = -127; //11,12 graden naar links + lcd.cls(); lcd.locate(0,0); lcd.printf("links"); } else if (kalibratiewaarde_deltoid>0.1 && kalibratiewaarde_deltoid<=0.35) { setpointkm = 0; //11,12graden naar rechts - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("midden"); } else { - setpointkm = 343.57; - lcd.cls(); + setpointkm = 127; //11,12 graden naar rechts + lcd.cls(); lcd.locate(0,0); lcd.printf("rechts"); } @@ -281,9 +281,9 @@ break; } - case SLAAN: { + case SLAAN: { //batje slaan (gebruik biceps) wait(3); - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("Slaan"); //regel 1 LCD scherm lcd.locate(0,1); @@ -294,30 +294,29 @@ float setpointkm; float new_pwm_km; wait(5); - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("Meting loopt"); float kalibratiewaarde_biceps; kalibratiewaarde_biceps=(envelop_emg0/max_value_biceps); - //pc.printf("biceps %f\n\r", kalibratiewaarde_biceps); //WEGHALEN LATER - if (kalibratiewaarde_biceps <= 0.2) { //kalibratiewaarde_biceps<0.3 goal onderin + if (kalibratiewaarde_biceps <= 0.2) { //kalibratiewaarde_biceps<0.2 goal onderin thetadot=THETADOT0; - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("ONDERSTE GOAL"); - } else if (kalibratiewaarde_biceps>0.2 && kalibratiewaarde_biceps<=0.4) { //0.3<kalibratiewaarde_biceps<0.6 goal midden + } else if (kalibratiewaarde_biceps>0.2 && kalibratiewaarde_biceps<=0.4) { //0.2<kalibratiewaarde_biceps<0.4 goal midden thetadot=THETADOT1; - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("MIDDELSTE GOAL"); - } else { //goal bovenin + } else { //goal bovenin thetadot=THETADOT2; - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("BOVENSTE GOAL"); } wait(3); - lcd.cls(); + lcd.cls(); lcd.locate(0,0); lcd.printf("Daar gaat ie!"); @@ -356,8 +355,7 @@ state = HOME; break; - case HOME: { - //pc.printf("HOMESTATE"); + case HOME: { //terugbewegen naar beginpositie float setpointgm; float new_pwm_gm; float setpointkm;