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: MODSERIAL mbed Encoder
main.cpp
- Committer:
- Socrates
- Date:
- 2013-10-15
- Revision:
- 1:34202d107458
- Parent:
- 0:b13a317308d1
- Child:
- 2:3dab90d3aac2
File content as of revision 1:34202d107458:
#include "mbed.h" #include "MODSERIAL.h" AnalogIn emg(PTB0); MODSERIAL pc(USBTX,USBRX); volatile bool looptimerflag; void setlooptimerflag(void) { looptimerflag = true; } int main() { Ticker looptimer; const float ts=0.001; looptimer.attach(setlooptimerflag,ts); float x,y,y1,x1,z1,yabs,z,yabs1,k,numh1,numh2,denh1,denh2,numl1,numl2,denl1,denl2; x1=0; y1=0; z1=0; yabs1=0; numh1=0; numh2=0; denh1=0; denh2=0; numl1=0; numl2=0; denl1=0; denl2=0; pc.baud(115200); while(1) { while(looptimerflag != true); looptimerflag = false; k=emg.read(); x=(k-0.5)*2.0; //High pass, 1 Hz y=(y1/1.000994230391224-(0.996868235770807/1.000994230391224)*x1+(0.997865599482850/1.000994230391224)*x); //Rectify yabs=abs(y); //Low pass, 1 Hz z=(z1/1.000987999680353-(0.006244035046343/1.000987999680353)*yabs1+(0.006237787927252/1.000987999680353)*yabs); pc.printf("%f\n\r",yabs); x1=x; y1=y; z1=z; yabs1=yabs; } }