emg
Dependencies: HIDScope MODSERIAL mbed-dsp mbed TouchButton
Fork of test by
Revision 38:017fd93e9efe, committed 2014-10-28
- Comitter:
- Tanja2211
- Date:
- Tue Oct 28 13:45:16 2014 +0000
- Parent:
- 37:8b15c29445d3
- Child:
- 39:012ff1795e6b
- Commit message:
- Ik hoop dat het gaat werken
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Oct 28 13:21:42 2014 +0000 +++ b/main.cpp Tue Oct 28 13:45:16 2014 +0000 @@ -182,201 +182,192 @@ wait(5); - while(true) { - if (key==0) { + if (key==1) { + + //rood + myled1 = 0; + myled2 = 1; + myled3 = 1; + + pc.printf("calibratie tricep aan\n"); + wait(2); + + Calibratie_Triceps(); + drempelwaardeT=MOVAVG_T-1; + pc.printf("drempelwaarde triceps is %f\r\n", drempelwaardeT); + pc.printf("calibratie tricep klaar,\n"); + wait(5); + + //pc.printf("key 2 caliratie biceps/n"); + //pc.printf("key 3 START/n"); + //wait(5); + + } else if (key==2) { + + //green + myled1 = 1; + myled2 = 0; + myled3 = 1; + wait(0.1); + + pc.printf("calibratie bicep snelheid 1 aan\n"); + wait(2); - //niks + Calibratie_Biceps(); + drempelwaardeB1=MOVAVG_B-1; + pc.printf("drempelwaarde snelheid 1 is %f\r\n", drempelwaardeB1); + wait(5); + + pc.printf("calibratie bicep snelheid 2 aan\n"); + wait(2); + + Calibratie_Biceps(); + drempelwaardeB2=MOVAVG_B-1; + pc.printf("drempelwaarde snelheid 2 is %f\r\n", drempelwaardeB2); + wait(5); + + pc.printf("calibratie bicep snelheid 2 aan\n"); + wait(2); + + Calibratie_Biceps(); + wait(2); + + drempelwaardeB2=MOVAVG_B-1; + pc.printf("drempelwaarde snelheid 3 is %f\r\n", drempelwaardeB3); + + pc.printf("caliratie biceps is klaar, accord? -> key 4/n"); + + wait(5); + } else if (key==3) { + if(drempelwaardeT==0) { + pc.printf("voer calibratie triceps uit"); + } else if (drempelwaardeB1==0) { + pc.printf("voer calibratie biceps uit"); + } else if (drempelwaardeB2==0) { + pc.printf("voer calibratie biceps uit"); + } else if (drempelwaardeB3==0) { + pc.printf("voer calibratie biceps uit"); + } else { + + //blue myled1 = 1; myled2 = 1; - myled3 = 1; + myled3 = 0; + wait(0.1); + + pc.printf("eerst positie dan snelheid aangeven/n"); - pc.printf("moet eerst calibreren\n"); - } else if (key==1) { + //bepaling van positie met triceps 1 + Ticker log_timerT1; + + arm_biquad_cascade_df1_init_f32(¬chT,1,notch_const,notch_states); + arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states); + arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states); - //rood - myled1 = 0; - myled2 = 1; - myled3 = 1; + log_timerT1.attach(Triceps, 0.005); + wait(10); + log_timerT1.detach(); + + MOVAVG_T=MOVAVG_Positie1; + + // positie van batje met behulp van Triceps - pc.printf("calibratie tricep aan\n"); - wait(2); + if (MOVAVG_Positie1>= drempelwaardeT) { + yT1=1; + } else { + yT1=0; + } - Calibratie_Triceps(); - drempelwaardeT=MOVAVG_T-1; - pc.printf("drempelwaarde triceps is %f\r\n", drempelwaardeT); - pc.printf("calibratie tricep klaar,\n"); + pc.printf("Triceps eerste meting is klaar.\n"); wait(5); - //pc.printf("key 2 caliratie biceps/n"); - //pc.printf("key 3 START/n"); - //wait(5); - - } else if (key==2) { + //bepaling van positie met tricep 2 + Ticker log_timerT2; - //green - myled1 = 1; - myled2 = 0; - myled3 = 1; - wait(0.1); + arm_biquad_cascade_df1_init_f32(¬chT,1,notch_const,notch_states); + arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states); + arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states); - pc.printf("calibratie bicep snelheid 1 aan\n"); - wait(2); - - Calibratie_Biceps(); - drempelwaardeB1=MOVAVG_B-1; - pc.printf("drempelwaarde snelheid 1 is %f\r\n", drempelwaardeB1); + log_timerT2.attach(Triceps, 0.005); wait(5); + log_timerT2.detach(); - pc.printf("calibratie bicep snelheid 2 aan\n"); - wait(2); + MOVAVG_T=MOVAVG_Positie2; - Calibratie_Biceps(); - drempelwaardeB2=MOVAVG_B-1; - pc.printf("drempelwaarde snelheid 2 is %f\r\n", drempelwaardeB2); - wait(5); + if (MOVAVG_Positie2 >= drempelwaardeT) { + yT2=1; + } else { + yT2=0; + } + + pc.printf("Triceps tweede meting is klaar.\n"); - pc.printf("calibratie bicep snelheid 2 aan\n"); - wait(2); + //*** INPUT MOTOR 2 *** + positie=yT1+yT2; - Calibratie_Biceps(); - wait(2); - - drempelwaardeB2=MOVAVG_B-1; - pc.printf("drempelwaarde snelheid 3 is %f\r\n", drempelwaardeB3); - - pc.printf("caliratie biceps is klaar, accord? -> key 4/n"); + //controle positie op scherm + if (positie==0) { + pc.printf("Motor 2 blijft op stand 1\n"); + } else { + if (positie==1) { + pc.printf("Motor 2 gaat naar stand 2\n"); + } else { + if (positie==2) { + pc.printf("Motor 2 gaat naar stand 3\n"); + } + } + } wait(5); - } else if (key==3) { - if(drempelwaardeT==0) { - pc.printf("voer calibratie triceps uit"); - } else if (drempelwaardeB1==0) { - pc.printf("voer calibratie biceps uit"); - } else if (drempelwaardeB2==0) { - pc.printf("voer calibratie biceps uit"); - } else if (drempelwaardeB3==0) { - pc.printf("voer calibratie biceps uit"); - } else { - //blue - myled1 = 1; - myled2 = 1; - myled3 = 0; - wait(0.1); - - pc.printf("eerst positie dan snelheid aangeven/n"); - - //bepaling van positie met triceps 1 - Ticker log_timerT1; + Ticker log_timerB; - arm_biquad_cascade_df1_init_f32(¬chT,1,notch_const,notch_states); - arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states); - arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states); - - log_timerT1.attach(Triceps, 0.005); - wait(10); - log_timerT1.detach(); - - MOVAVG_T=MOVAVG_Positie1; - - // positie van batje met behulp van Triceps + arm_biquad_cascade_df1_init_f32(¬chB,1,notch_const,notch_states); + arm_biquad_cascade_df1_init_f32(&lowpassB,1,lowpass_const,lowpass_states); + arm_biquad_cascade_df1_init_f32(&highpassB,1,highpass_const,highpass_states); - if (MOVAVG_Positie1>= drempelwaardeT) { - yT1=1; - } else { - yT1=0; - } - - pc.printf("Triceps eerste meting is klaar.\n"); - wait(5); - - //bepaling van positie met tricep 2 - Ticker log_timerT2; - - arm_biquad_cascade_df1_init_f32(¬chT,1,notch_const,notch_states); - arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states); - arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states); + log_timerB.attach(Biceps,0.005); + wait(5); + log_timerB.detach(); - log_timerT2.attach(Triceps, 0.005); - wait(5); - log_timerT2.detach(); - - MOVAVG_T=MOVAVG_Positie2; - - if (MOVAVG_Positie2 >= drempelwaardeT) { - yT2=1; - } else { - yT2=0; - } + //bepaling van snelheidsstand met biceps - pc.printf("Triceps tweede meting is klaar.\n"); - - //*** INPUT MOTOR 2 *** - positie=yT1+yT2; - - //controle positie op scherm - if (positie==0) { - pc.printf("Motor 2 blijft op stand 1\n"); - } else { - if (positie==1) { - pc.printf("Motor 2 gaat naar stand 2\n"); + if (MOVAVG_B >= drempelwaardeB1) { + yB1=1; + if (MOVAVG_B >= drempelwaardeB2) { + yB2=1; + if (MOVAVG_B >= drempelwaardeB3) { + yB3=1; } else { - if (positie==2) { - pc.printf("Motor 2 gaat naar stand 3\n"); - } - } - } - - wait(5); - - Ticker log_timerB; - - arm_biquad_cascade_df1_init_f32(¬chB,1,notch_const,notch_states); - arm_biquad_cascade_df1_init_f32(&lowpassB,1,lowpass_const,lowpass_states); - arm_biquad_cascade_df1_init_f32(&highpassB,1,highpass_const,highpass_states); - - log_timerB.attach(Biceps,0.005); - wait(5); - log_timerB.detach(); - - //bepaling van snelheidsstand met biceps - - if (MOVAVG_B >= drempelwaardeB1) { - yB1=1; - if (MOVAVG_B >= drempelwaardeB2) { - yB2=1; - if (MOVAVG_B >= drempelwaardeB3) { - yB3=1; - } else { - yB3=0; - } - } else { - yB2=0; + yB3=0; } } else { - yB1=0; + yB2=0; } + } else { + yB1=0; + } - //*** INPUT MOTOR 1 *** - snelheidsstand=yB1+yB2+yB3; + //*** INPUT MOTOR 1 *** + snelheidsstand=yB1+yB2+yB3; - //controle snelheidsstand op scherm - if (snelheidsstand==0) { - pc.printf("Motor 1 beweegt niet\n"); + //controle snelheidsstand op scherm + if (snelheidsstand==0) { + pc.printf("Motor 1 beweegt niet\n"); + } else { + if (snelheidsstand==1) { + pc.printf("Motor 1 beweegt met snelheid 1\n"); } else { - if (snelheidsstand==1) { - pc.printf("Motor 1 beweegt met snelheid 1\n"); + if (snelheidsstand==2) { + pc.printf("Motor 1 beweegt met snelheid 2\n"); } else { - if (snelheidsstand==2) { - pc.printf("Motor 1 beweegt met snelheid 2\n"); - } else { - if (snelheidsstand==3) { - pc.printf("Motor 1 beweegt met snelheid 3\n"); - } + if (snelheidsstand==3) { + pc.printf("Motor 1 beweegt met snelheid 3\n"); } } } } } } + } \ No newline at end of file