emg
Dependencies: HIDScope MODSERIAL mbed-dsp mbed TouchButton
Fork of test by
Diff: main.cpp
- Revision:
- 41:d86fced533a8
- Parent:
- 40:42735d766db1
- Child:
- 42:6430dd3a8ea2
--- a/main.cpp Tue Oct 28 14:02:14 2014 +0000 +++ b/main.cpp Tue Oct 28 15:30:22 2014 +0000 @@ -104,14 +104,18 @@ //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; @@ -121,10 +125,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"); //naar HID Scope scope.set(2,emg_valueB); //ruwe data scope.set(3,filtered_emgB); //filtered @@ -151,13 +155,15 @@ void Calibratie_Biceps() { Ticker log_timerB; - +pc.printf("d\n"); 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); +pc.printf("e\n"); + log_timerB.attach(Biceps, 0.5); + pc.printf("f\n"); + wait(3); + pc.printf("g\n"); log_timerB.detach(); } @@ -174,14 +180,15 @@ TouchButton TButton; int key=0;//vraagt om calibratie - key = TButton.PressedButton(); + pc.printf("key 1 calibratie triceps\n"); pc.printf("key 2 caliratie biceps\n"); pc.printf("key 3 START\n"); - wait(5); + while(true) { + key = TButton.PressedButton(); if (key==1) { //rood @@ -205,13 +212,15 @@ myled1 = 1; myled2 = 0; myled3 = 1; - wait(0.1); 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);