Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 21:4183ea24a735, committed 2019-10-11
- Comitter:
- MatthewMaat
- Date:
- Fri Oct 11 11:59:59 2019 +0000
- Parent:
- 20:97059009a491
- Commit message:
- RMS output van de EMG
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 22 08:53:50 2016 +0000 +++ b/main.cpp Fri Oct 11 11:59:59 2019 +0000 @@ -1,5 +1,6 @@ #include "mbed.h" #include "HIDScope.h" +#include <math.h> //Define objects AnalogIn emg0( A0 ); @@ -14,9 +15,23 @@ **/ void sample() { + static int count=0; + static float RMS_value=0; + static float HighPass_value=0; + count+=1; + static float RMS[150]; + static float HighPass[30]; + float I1; + float If; + I1=emg0.read(); //read signal + HighPass_value+=(I1-HighPass[count%30])/30.0; + HighPass[count%30]=I1; + If=pow(I1-HighPass_value,2.0f); // Highpass-filtered value squared + RMS_value+=(If-RMS[count%150])/150.0; + RMS[count%150]=If; /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */ - scope.set(0, emg0.read() ); - scope.set(1, emg1.read() ); + scope.set(0, sqrt(RMS_value) ); // send root mean squared + scope.set(1, emg0.read() ); /* Repeat the step above if required for more channels of required (channel 0 up to 5 = 6 channels) * Ensure that enough channels are available (HIDScope scope( 2 )) * Finally, send all channels to the PC at once */
--- a/mbed.bld Thu Sep 22 08:53:50 2016 +0000 +++ b/mbed.bld Fri Oct 11 11:59:59 2019 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/aae6fcc7d9bb \ No newline at end of file