script uitleg
Dependencies: Encoder MODSERIAL mbed
Revision 2:4ae32e8863d5, committed 2013-11-06
- Comitter:
- jaccoton
- Date:
- Wed Nov 06 16:16:10 2013 +0000
- Parent:
- 1:5deb5092d487
- Commit message:
- Uitleg van het script
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 5deb5092d487 -r 4ae32e8863d5 main.cpp --- a/main.cpp Tue Nov 05 10:02:42 2013 +0000 +++ b/main.cpp Wed Nov 06 16:16:10 2013 +0000 @@ -115,7 +115,7 @@ zzzz2=0; ffff1=0; ffff2=0; - + float F,FF,FFF,FFFF; /*Variables to store direction in dependent on the EMG*/ float emg_dir; float emg_dir2; @@ -178,7 +178,7 @@ z = y*0.3913+y1*-0.7827+y2*0.3913-z1*-0.3695-z2*0.1958; // Formula for low pass filter at 40Hz instead of a Notch filter z = abs(z); //Rectify the signal f = z*0.0036+z1*0.0072+z2*0.0036-f1*-1.8227-f2*0.8372; // low pass filter at 5Hz - + F = f; z1 = z; // Store older values of variables @@ -190,10 +190,10 @@ f1 = f; f2 = f1; - if (f<0.1) + if (f<0.2) f=0; else - f=f*3; + f=f; //pc.printf("%f \n \r",(s1*f)); @@ -203,6 +203,7 @@ zz = yy*0.3913+yy1*-0.7827+yy2*0.3913-zz1*-0.3695-zz2*0.1958; // Formula for low pass filter at 40Hz instead of a Notch filter zz = abs(zz); //Rectify the signal ff = zz*0.0036+zz1*0.0072+zz2*0.0036-ff1*-1.8227-ff2*0.8372; // low pass filter at 5Hz + FF = ff; zz1 = zz; // Store older values of variables zz2 = zz1; @@ -212,16 +213,17 @@ xx2 = xx1; ff1 = ff; ff2 = ff1; - if (ff<0.1) + if (ff<0.2) ff=0; else - ff=ff*3; + ff=ff; /* EMG Filter 3*/ xxx = emg2.read(); //Reading EMG value yyy = 0.6389*xxx+1.2779*xxx1+0.6389*xxx2-yyy1*1.143-yyy2*0.4128; //Formula for highpass filter at 20Hz as given in slides zzz = yyy*0.3913+yyy1*-0.7827+yyy2*0.3913-zzz1*-0.3695-zzz2*0.1958; // Formula for low pass filter at 40Hz instead of a Notch filter zzz = abs(zzz); //Rectify the signal fff = zzz*0.0036+zzz1*0.0072+zzz2*0.0036-fff1*-1.8227-fff2*0.8372; // low pass filter at 5Hz + FFF = fff; zzz1 = zzz; // Store older values of variables zzz2 = zzz1; @@ -241,6 +243,7 @@ zzzz = yyyy*0.3913+yyyy1*-0.7827+yyyy2*0.3913-zzzz1*-0.3695-zzzz2*0.1958; // Formula for low pass filter at 40Hz instead of a Notch filter zzzz = abs(zzzz); //Rectify the signal ffff = zzzz*0.0036+zzzz1*0.0072+zzzz2*0.0036-ffff1*-1.8227-ffff2*0.8372; // low pass filter at 5Hz + FFFF = ffff; zzzz1 = zzzz; // Store older values of variables zzzz2 = zzzz1; @@ -282,7 +285,7 @@ if (f>0.2){ //Defining a threshhold abvoe which theres unlikely to measure any activity of other muscles if (f>h); //Looking for the biggest value of f - h=f; //Storing it in h + h=(f); //Storing it in h if (h1<h) //if h is a value below the set maximum h1=h1+0.001; //the variable of the setpoint will try to narrow it in steps of 0.005 }