Dan August
/
EMGStdevV3
nu met gains, threshold en eerst opvullen
Fork of EMGStdevV3 by
Diff: main.cpp
- Revision:
- 1:1ffb9e3ae00f
- Parent:
- 0:59e2ea255892
- Child:
- 2:56230ff9fc8f
- Child:
- 3:e609cd999fd2
diff -r 59e2ea255892 -r 1ffb9e3ae00f main.cpp --- a/main.cpp Sun Nov 03 20:18:17 2013 +0000 +++ b/main.cpp Mon Nov 04 13:26:18 2013 +0000 @@ -25,7 +25,7 @@ #define DEN3 -2.1689 #define DEN4 0.4531 -//lowpass filter constantes 4Hz 4e orde, Fs = 312,5 z +//lowpass filter constantes 4Hz 4e orde, Fs = 312,5 Hz #define NUM0_3 0.00000236 // constante #define NUM1_3 0.00000944 // z^-1 #define NUM2_3 0.00001415 // z^-2etc. @@ -63,12 +63,12 @@ if(count_biceps >= size) count_biceps=0; //sizeof(keeper_biceps)/sizeof(float); - for(int i=0; i < (size-1); i++) + for(int i=0; i < size; i++) {sum+=keeper_biceps[i]; } mean=sum/size; sum=0; - for(int i=0; i < size-1; i++) + for(int i=0; i < size; i++) {sum+=(keeper_biceps[i]-mean)*(keeper_biceps[i]-mean); } sig_out=sqrt(sum/size); @@ -80,12 +80,12 @@ if(count_triceps==size) count_triceps=0; //sizeof(keeper_triceps) / sizeof(float); - for(int i=0; i < size-1; i++){ + for(int i=0; i < size; i++){ sum+=keeper_triceps[i]; } mean=sum/size; sum=0; - for(int i=0; i < size-1; i++){ + for(int i=0; i < size; i++){ sum+=(keeper_triceps[i]-mean)*(keeper_triceps[i]-mean); } sig_out=sqrt(sum/size); @@ -283,7 +283,7 @@ //static int sig_count = 1; emg_value_biceps=std_dev(filter(1),1); emg_value_triceps=std_dev(filter(2),2); -//dy = emg_value_biceps-emg_value_triceps; +dy = emg_value_biceps-emg_value_triceps; /*emg_value_flexoren = (100*filter(3)-44); @@ -304,7 +304,7 @@ */ //dy = emg_value_biceps-emg_value_triceps; if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) - pc.printf("%.6f, %.6f\n",emg_value_biceps, emg_value_triceps); + pc.printf("%.6f, %.6f, %.6f\n",emg_value_biceps, emg_value_triceps, dy); /**When not using the LED, the above could also have been done this way: * pc.printf("%.6\n", emg0.read()); */