script dat de twee motoren los van elkaar laat draaien
Dependencies: mbed Encoder MODSERIAL
Revision 3:4db5e8ed9657, committed 2013-11-05
- Comitter:
- jaccoton
- Date:
- Tue Nov 05 11:27:38 2013 +0000
- Parent:
- 2:5f175018d1ff
- Child:
- 4:3f2f48dad1ff
- Commit message:
- potmeter hulp
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Nov 05 11:01:57 2013 +0000 +++ b/main.cpp Tue Nov 05 11:27:38 2013 +0000 @@ -161,11 +161,12 @@ /*while loop voor de emg*/ /* EMG Filter 1*/ - //x = emg0.read(); //Reading EMG value - y = 0.6389*x+1.2779*x1+0.6389*x2-y1*1.143-y2*0.4128; //Formula for highpass filter at 20Hz as given in slides - 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 + //* EMG Filter 1*/ + x = emg0.read(); //Reading EMG value + y = 0.638945525159022*x+1.277891050318045*x1+0.638945525159022*x2-y1*1.142980502539901-y2*0.412801598096189; //Formula for highpass filter at 20Hz as given in slides + z = y*0.391335772501769+y1*-0.782671545003537+y2*0.391335772501769-z1*-0.369527377351241-z2*0.195815712655833; // 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 = z*0.003621681514929+z1*0.007243363029857+z2*0.003621681514929-f1*-1.822694925196308-f2*0.837181651256023; // low pass filter at 2Hz @@ -180,15 +181,14 @@ if (f<0.1) f=0; - //pc.printf("%f \n \r",(s1*f)); /* EMG Filter 2*/ - //xx = emg1.read(); //Reading EMG value - yy = 0.6389*xx+1.2779*xx1+0.6389*xx2-yy1*1.143-yy2*0.4128; //Formula for highpass filter at 20Hz as given in slides - 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 + xx = emg1.read(); //Reading EMG value + yy = 0.638945525159022*xx+1.277891050318045*xx1+0.638945525159022*xx2-yy1*1.142980502539901-yy2*0.412801598096189; //Formula for highpass filter at 20Hz as given in slides + zz = yy*0.391335772501769+yy1*-0.782671545003537+yy2*0.391335772501769-zz1*-0.369527377351241-zz2*0.195815712655833; // 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 = zz*0.003621681514929+zz1*0.007243363029857+zz2*0.003621681514929-ff1*-1.822694925196308-ff2*0.837181651256023; // low pass filter at 2Hz zz1 = zz; // Store older values of variables zz2 = zz1; @@ -201,11 +201,11 @@ if (ff<0.1) ff=0; /* 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 + xxx = emg2.read(); //Reading EMG value + yyy = 0.638945525159022*xxx+1.277891050318045*xxx1+0.638945525159022*xxx2-yyy1*1.142980502539901-yyy2*0.412801598096189; //Formula for highpass filter at 20Hz as given in slides + zzz = yyy*0.391335772501769+yyy1*-0.782671545003537+yyy2*0.391335772501769-zzz1*-0.369527377351241-zzz2*0.195815712655833; // 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 = zzz*0.003621681514929+zzz1*0.007243363029857+zzz2*0.003621681514929-fff1*-1.822694925196308-fff2*0.837181651256023; // low pass filter at 2Hz zzz1 = zzz; // Store older values of variables zzz2 = zzz1; @@ -218,11 +218,11 @@ if (fff<0.1) fff=0; /* EMG Filter 4*/ - //xxxx = emg3.read(); //Reading EMG value - yyyy = 0.6389*xxxx+1.2779*xxxx1+0.6389*xxxx2-yyyy1*1.143-yyyy2*0.4128; //Formula for highpass filter at 20Hz as given in slides - 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 + xxxx = emg3.read(); //Reading EMG value + yyyy = 0.638945525159022*xxxx+1.277891050318045*xxxx1+0.638945525159022*xxxx2-yyyy1*1.142980502539901-yyyy2*0.412801598096189; //Formula for highpass filter at 20Hz as given in slides + zzzz = yyyy*0.391335772501769+yyyy1*-0.782671545003537+yyyy2*0.391335772501769-zzzz1*-0.369527377351241-zzzz2*0.195815712655833; // 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 = zzzz*0.003621681514929+zzzz1*0.007243363029857+zzzz2*0.003621681514929-ffff1*-1.822694925196308-ffff2*0.837181651256023; // low pass filter at 2Hz zzzz1 = zzzz; // Store older values of variables zzzz2 = zzzz1; @@ -234,6 +234,7 @@ ffff2 = ffff1; if (ffff<0.1) ffff=0; + //Printing the Filtered singnal //pc.printf("%f \n \r",f);