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.
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: emgprocessing.cpp
- Branch:
- Branch2
- Revision:
- 65:6252198c3b67
- Parent:
- 61:4c7de1e2f9fe
- Child:
- 67:5ebb08e337ae
--- a/emgprocessing.cpp Wed Oct 16 10:58:23 2019 +0000 +++ b/emgprocessing.cpp Wed Oct 16 12:37:02 2019 +0000 @@ -1,22 +1,36 @@ #include "functions.h" #include "structures.h" +#include "global.h" -/* -#include "controller.cpp" +float V[5]; +float SUM; -extern ControllerSettings Set_LPFEMG; -extern ControllerSettings Set_NOTEMG; -extern MemoryIO Mem_LPFEMG; -extern MemoryIO Mem_NOTEMG; - +float MovingAverage(float X) +{ + for(int i = 1; i < 5; i ++) + { + V[i] = V[i-1]; + } + V[0] = X; + for(int j = 0; j < 5; j ++) + { + float SUM = SUM + V[j]; + } + float Avg = SUM/5; + + return Avg; +} float ProcessEMG(float X) { - float TempOne = Biquad(Set_LPFEMG, Mem_LPFEMG, X); - float TempTwo = Biquad(Set_NOTEMG, Mem_NOTEMG, TempOne); + //Apply LPF and Notch Filter + float Temp = Biquad(Set_LPFEMG, Mem_LPFEMG, X); + float Y = Biquad(Set_NOTEMG, Mem_NOTEMG, Temp); - float Y = TempTwo; - + //Calculate moving average + float Avg = MovingAverage(Y); + //Subtract moving average + Y = Y - Avg; + return Y; } -*/ \ No newline at end of file