emg
Dependencies: HIDScope MODSERIAL mbed-dsp mbed TouchButton
Fork of test by
Revision 43:bc93d31b80f5, committed 2014-10-28
- Comitter:
- s1340735
- Date:
- Tue Oct 28 16:37:38 2014 +0000
- Parent:
- 42:6430dd3a8ea2
- Child:
- 44:bcd0bb522bf5
- Commit message:
- key 3 aangepast
Changed in this revision
TouchButton.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/TouchButton.lib Tue Oct 28 15:38:58 2014 +0000 +++ b/TouchButton.lib Tue Oct 28 16:37:38 2014 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/BMT-M9-Groep01/code/TouchButton/#e2599f77aa36 +http://developer.mbed.org/teams/BMT-M9-Groep01/code/TouchButton/#c77d8b0165c0
--- a/main.cpp Tue Oct 28 15:38:58 2014 +0000 +++ b/main.cpp Tue Oct 28 16:37:38 2014 +0000 @@ -91,7 +91,7 @@ T5=T4, T4=T3, T3=T2, T2=T1, T1=T0; //sturen naar scherm (Realterm) - pc.printf("%f\r\n",MOVAVG_T); + pc.printf("Moving average T %f\r\n",MOVAVG_T); //sturen naar HID Scope scope.set(0,emg_valueT); //ruwe data @@ -104,18 +104,14 @@ //Biceps lezen emg_valueB = emgB.read_u16(); // read direct ADC result, converted to 16 bit integer (0..2^16 = 0..65536 = 0..3.3V) emg_value_f32B = emgB.read(); -pc.printf("a1\n"); + //Biceps filteren arm_biquad_cascade_df1_f32(¬chB, &emg_value_f32B, &filtered_emgB, 1 ); - pc.printf("a12\n"); arm_biquad_cascade_df1_f32(&lowpassB, &filtered_emgB, &filtered_emgB, 1 ); - pc.printf("a13\n"); filtered_emgB = fabs(filtered_emgB); - pc.printf("a14\n"); arm_biquad_cascade_df1_f32(&highpassB, &filtered_emgB, &filtered_emgB, 1 ); - pc.printf("a15\n"); filtered_emgB = fabs(filtered_emgB); -pc.printf("a2\n"); + //Biceps moving average B0=filtered_emgB*1000; MOVAVG_B=B0*0.01667+B1*0.01667+B2*0.01667+B3*0.01667+B4*0.01667+B5*0.01667+B6*0.01667+B7*0.01667+B8*0.01667+B9*0.01667+B10*0.01667+B11*0.01667+B12*0.01667+B13*0.01667+B14*0.01667+B15*0.01667+B16*0.01667+B17*0.01667+B18*0.01667+B19*0.01667+B20*0.01667+B21*0.01667+B22*0.01667+B23*0.01667+B24*0.01667+B25*0.01667+B26*0.01667+B27*0.01667+B28*0.01667+B29*0.01667+B30*0.01667+B31*0.01667+B32*0.01667+B33*0.01667+B34*0.01667+B35*0.01667+B36*0.01667+B37*0.01667+B38*0.01667+B39*0.01667+B40*0.01667+B41*0.01667+B42*0.01667+B43*0.01667+B44*0.01667+B45*0.01667+B46*0.01667+B47*0.01667+B48*0.01667+B49*0.01667+B50*0.01667+B51*0.01667+B52*0.01667+B53*0.01667+B54*0.01667+B55*0.01667+B56*0.01667+B57*0.01667+B58*0.01667+B59*0.01667; @@ -125,10 +121,10 @@ B25=B24, B24=B23, B23=B22, B22=B21, B21=B20, B20=B19, B19=B18, B18=B17, B17=B16, B16=B15, B15=B14; B14=B13, B13=B12, B12=B11, B11=B10, B10=B9, B9=B8, B8=B7, B7=B6, B6=B5, B5=B4, B4=B3; B3=B2, B2=B1, B1=B0; -pc.printf("a3\n"); + //sturen naar scherm - pc.printf("%f\r\n",MOVAVG_B); -pc.printf("a4\n"); + pc.printf("Moving average B %f\r\n",MOVAVG_B); + //naar HID Scope scope.set(2,emg_valueB); //ruwe data scope.set(3,filtered_emgB); //filtered @@ -155,15 +151,13 @@ void Calibratie_Biceps() { Ticker log_timerB; -pc.printf("d\n"); + 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); -pc.printf("e\n"); + log_timerB.attach(Biceps, 0.005); - pc.printf("f\n"); wait(3); - pc.printf("g\n"); log_timerB.detach(); } @@ -179,18 +173,15 @@ TouchButton TButton; - int key=0;//vraagt om calibratie - + int key=0; pc.printf("key 1 calibratie triceps\n"); pc.printf("key 2 caliratie biceps\n"); pc.printf("key 3 START\n"); - while(true) { key = TButton.PressedButton(); if (key==1) { - //rood myled1 = 0; myled2 = 1; @@ -202,12 +193,12 @@ Calibratie_Triceps(); drempelwaardeT=MOVAVG_T-1; pc.printf("drempelwaarde triceps is %f\r\n", drempelwaardeT); + pc.printf("calibratie tricep klaar,\n"); - wait(5); + wait(3); } if (key==2) { - //green myled1 = 1; myled2 = 0; @@ -215,57 +206,50 @@ pc.printf("calibratie bicep snelheid 1 aan\n"); wait(2); -pc.printf("a\n"); Calibratie_Biceps(); - pc.printf("b\n"); drempelwaardeB1=MOVAVG_B-1; - pc.printf("c\n"); - 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); + wait(3); 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(3); - Calibratie_Biceps(); + pc.printf("calibratie bicep snelheid 3 aan\n"); wait(2); - - drempelwaardeB2=MOVAVG_B-1; + Calibratie_Biceps(); + drempelwaardeB3=MOVAVG_B-1; pc.printf("drempelwaarde snelheid 3 is %f\r\n", drempelwaardeB3); pc.printf("caliratie biceps is klaar\n"); - wait(5); } + if (key==3) { - if(drempelwaardeT==0) { - pc.printf("voer calibratie triceps uit\n"); - } - if (drempelwaardeB1==0) { - pc.printf("voer calibratie biceps uit\n"); - } - if (drempelwaardeB2==0) { - pc.printf("voer calibratie biceps uit\n"); - } - if (drempelwaardeB3==0) { - pc.printf("voer calibratie biceps uit\n"); - } else { - + //blue myled1 = 1; myled2 = 1; myled3 = 0; wait(0.1); - - pc.printf("eerst positie dan snelheid aangeven/n"); + + if(drempelwaardeT==0) { + pc.printf("geen waarde calibratie TRICEPS \n"); + } + if (drempelwaardeB1==0) { + pc.printf("geen waarde calibratie BICEPS 1 \n"); + } + if (drempelwaardeB2==0) { + pc.printf("geen waarde calibratie BICEPS 2 \n"); + } + if (drempelwaardeB3==0) { + pc.printf("geen waarde calibratie BICEPS 3 \n"); + } else { + + pc.printf("eerst positie dan snelheid aangeven /n"); //bepaling van positie met triceps 1 Ticker log_timerT1; @@ -275,7 +259,7 @@ arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states); log_timerT1.attach(Triceps, 0.005); - wait(10); + wait(5); log_timerT1.detach(); MOVAVG_T=MOVAVG_Positie1; @@ -287,8 +271,8 @@ } else { yT1=0; } - - pc.printf("Triceps eerste meting is klaar.\n"); + + pc.printf("Triceps meting 1 is klaar.\n"); wait(5); //bepaling van positie met tricep 2 @@ -310,7 +294,7 @@ yT2=0; } - pc.printf("Triceps tweede meting is klaar.\n"); + pc.printf("Triceps meting 2 is klaar.\n"); //*** INPUT MOTOR 2 *** positie=yT1+yT2;