Jorn Dokter / Mbed 2 deprecated TEB_branch2

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Committer:
JornD
Date:
Wed Oct 16 12:37:02 2019 +0000
Branch:
Branch2
Revision:
65:6252198c3b67
Parent:
61:4c7de1e2f9fe
Child:
67:5ebb08e337ae
WORKING - Started coding the EMG signal processing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JornD 61:4c7de1e2f9fe 1 #include "functions.h"
JornD 61:4c7de1e2f9fe 2 #include "structures.h"
JornD 65:6252198c3b67 3 #include "global.h"
JornD 61:4c7de1e2f9fe 4
JornD 65:6252198c3b67 5 float V[5];
JornD 65:6252198c3b67 6 float SUM;
JornD 61:4c7de1e2f9fe 7
JornD 65:6252198c3b67 8 float MovingAverage(float X)
JornD 65:6252198c3b67 9 {
JornD 65:6252198c3b67 10 for(int i = 1; i < 5; i ++)
JornD 65:6252198c3b67 11 {
JornD 65:6252198c3b67 12 V[i] = V[i-1];
JornD 65:6252198c3b67 13 }
JornD 65:6252198c3b67 14 V[0] = X;
JornD 65:6252198c3b67 15 for(int j = 0; j < 5; j ++)
JornD 65:6252198c3b67 16 {
JornD 65:6252198c3b67 17 float SUM = SUM + V[j];
JornD 65:6252198c3b67 18 }
JornD 65:6252198c3b67 19 float Avg = SUM/5;
JornD 65:6252198c3b67 20
JornD 65:6252198c3b67 21 return Avg;
JornD 65:6252198c3b67 22 }
JornD 61:4c7de1e2f9fe 23
JornD 43:9579a1afe9cb 24 float ProcessEMG(float X)
JornD 23:767911637f3a 25 {
JornD 65:6252198c3b67 26 //Apply LPF and Notch Filter
JornD 65:6252198c3b67 27 float Temp = Biquad(Set_LPFEMG, Mem_LPFEMG, X);
JornD 65:6252198c3b67 28 float Y = Biquad(Set_NOTEMG, Mem_NOTEMG, Temp);
JornD 61:4c7de1e2f9fe 29
JornD 65:6252198c3b67 30 //Calculate moving average
JornD 65:6252198c3b67 31 float Avg = MovingAverage(Y);
JornD 65:6252198c3b67 32 //Subtract moving average
JornD 65:6252198c3b67 33 Y = Y - Avg;
JornD 65:6252198c3b67 34
JornD 23:767911637f3a 35 return Y;
JornD 61:4c7de1e2f9fe 36 }