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: HIDScope MODSERIAL biquadFilter mbed
Fork of Milestone_sample by
Diff: main.cpp
- Revision:
- 28:4534a096b677
- Parent:
- 27:1885e388b4ce
- Child:
- 29:c72e49a3edbb
diff -r 1885e388b4ce -r 4534a096b677 main.cpp --- a/main.cpp Wed Oct 24 17:39:24 2018 +0000 +++ b/main.cpp Wed Oct 24 17:56:55 2018 +0000 @@ -27,11 +27,12 @@ const float T = 0.002f; //Ticker period //EMG filter -double emgfilt0, emgfilt1, emgfilt2; //Variables for filtered EMG data channel 0, 1 and 2 +double emg0_filt, emg1_filt, emg2_filt; //Variables for filtered EMG data channel 0, 1 and 2 +double emg0_raw, emg1_raw, emg2_raw; const int windowsize = 150; //Size of the array over which the moving average (MovAg) is calculated. (random number) double sum, sum1, sum2, sum3; //variables used to sum elements in array double StoreArray0[windowsize], StoreArray1[windowsize], StoreArray2[windowsize]; //Empty arrays to calculate MoveAg -double movAg0,movAg1,movAg2; //outcome of MovAg (moet dit een array zijn??) +double movAg0, movAg1, movAg2; //outcome of MovAg (moet dit een array zijn??) //Biquad //Variables for the biquad band filters (alle 3 dezelfde maar je kan niet 3x 'emg0band' aanroepen ofzo) @@ -74,22 +75,22 @@ void EMGFilter0() { double emg0_raw = emg0_in.read(); //give name to raw EMG0 data - double emg0filt = emg0filter.step(emg0); //Use biquad chain to filter raw EMG data - double emg0filt = abs(emg0filt); //rectifier. LET OP: volgorde filter: band-notch-rectifier. Eerst band-rect-notch, stel er komt iets raars uit, dan Notch uit de biquad chain halen en aparte chain voor aanmaken. + double emg0_filt_x = emg0filter.step(emg0_raw); //Use biquad chain to filter raw EMG data + double emg0_filt = abs(emg0_filt_x); //rectifier. LET OP: volgorde filter: band-notch-rectifier. Eerst band-rect-notch, stel er komt iets raars uit, dan Notch uit de biquad chain halen en aparte chain voor aanmaken. } void EMGFilter1() { double emg1_raw = emg1_in.read(); //give name to raw EMG1 data - double emg1filt = emg1filter.step(emg1); //Use biquad chain to filter raw EMG data - double emg1filt = abs(emg1filt); //rectifier. LET OP: volgorde filter: band-notch-rectifier. Eerst band-rect-notch. + double emg1_filt_x = emg1filter.step(emg1_raw); //Use biquad chain to filter raw EMG data + double emg1_filt = abs(emg1_filt_x); //rectifier. LET OP: volgorde filter: band-notch-rectifier. Eerst band-rect-notch. } void EMGFilter2() { double emg2_raw = emg2_in.read(); //Give name to raw EMG1 data - double emg2filt = emg2filter.step(emg2); //Use biquad chain to filter raw EMG data - double emg2filt = abs(emg2filt); //Rectifier. LET OP: volgorde filter: band-notch-rectifier. + double emg2_filt_x = emg2filter.step(emg2_raw); //Use biquad chain to filter raw EMG data + double emg2_filt = abs(emg2_filt_x); //Rectifier. LET OP: volgorde filter: band-notch-rectifier. } void MovAg() //Calculate moving average (MovAg), klopt nog niet!! @@ -101,9 +102,9 @@ StoreArray2[i] = StoreArray2[i-1]; } - StoreArray0[0] = emg0filt; //Stores the latest datapoint of the filtered signal in the first element of the array - StoreArray1[0] = emg1filt; - StoreArray2[0] = emg2filt; + StoreArray0[0] = emg0_filt; //Stores the latest datapoint of the filtered signal in the first element of the array + StoreArray1[0] = emg1_filt; + StoreArray2[0] = emg2_filt; sum1 = 0.0; sum2 = 0.0;