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
emgprocessing.cpp
- Committer:
- JornD
- Date:
- 2019-10-16
- Branch:
- Branch2
- Revision:
- 65:6252198c3b67
- Parent:
- 61:4c7de1e2f9fe
- Child:
- 67:5ebb08e337ae
File content as of revision 65:6252198c3b67:
#include "functions.h" #include "structures.h" #include "global.h" float V[5]; float SUM; 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) { //Apply LPF and Notch Filter float Temp = Biquad(Set_LPFEMG, Mem_LPFEMG, X); float Y = Biquad(Set_NOTEMG, Mem_NOTEMG, Temp); //Calculate moving average float Avg = MovingAverage(Y); //Subtract moving average Y = Y - Avg; return Y; }