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 QEI TextLCD mbed
Fork of TotalControlEmg2 by
Diff: main.cpp
- Revision:
- 22:c1811e60bfce
- Parent:
- 21:8fe8419de3e9
- Child:
- 23:855c4bcb2284
diff -r 8fe8419de3e9 -r c1811e60bfce main.cpp --- a/main.cpp Wed Oct 14 14:49:47 2015 +0000 +++ b/main.cpp Thu Oct 15 10:00:54 2015 +0000 @@ -10,10 +10,10 @@ Ticker EMGticker; MODSERIAL pc(USBTX, USBRX); //bugfix DigitalOut LedBlue(LED3); -DigitalIn button(PTA4); +DigitalIn button(PTA4); //Sample frequentie -double Fs = 500; //Hz +double Fs = 200; //Hz double t = 1/ Fs; // voor EMGticker bool readymax = 0; @@ -23,6 +23,7 @@ double thresholdlow; double thresholdmid; double thresholdhigh; +bool go_flag = 0; void EMGkalibratie() { @@ -33,9 +34,11 @@ ymax = KalibratieMax(readymax); // bepalen van thresholds voor aan/uit - thresholdlow = 10 * ymin; // standaardwaarde + thresholdlow = 8 * ymin; // standaardwaarde thresholdmid = 0.5 * ymax; // afhankelijk van max output gebruiker thresholdhigh = 0.8 * ymax; + + pc.printf("ymax = %f en ymin = %f \n",ymax, ymin); //bugfix } void EMGfilter() @@ -52,18 +55,26 @@ scope.send(); //stuur de waardes naar HIDscope } +void Go_flag(){ + go_flag = 1; + } + int main() { + //pc.baud(115200); + EMGticker.attach(&Go_flag, t); //500H while(1) { - if(readymax == 0 || readymin == 0) { - EMGkalibratie(); - pc.printf("ymax = %f en ymin = %f \n",ymax, ymin); //bugfix - } - EMGticker.attach(&EMGfilter, t); //500H - while(readymax == 1 && readymin == 1) { + if(go_flag) { + go_flag = 0; if(button == 0) { readymax = 0; readymin = 0; + } + else if(readymax == 0 || readymin == 0) { + EMGkalibratie(); + } + else if(readymax == 1 && readymin == 1) { + EMGfilter(); } } }