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
Diff: main.cpp
- Revision:
- 0:b13a317308d1
- Child:
- 1:34202d107458
diff -r 000000000000 -r b13a317308d1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 15 14:08:58 2013 +0000 @@ -0,0 +1,40 @@ +#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; + looptimer.attach(setlooptimerflag,0.001); + float x,y,y1,x1,z1,yabs,z,yabs1; + //const float ts=0.001; + x1=0; + y1=0; + z1=0; + yabs1=0; + pc.baud(115200); + + while(1) { + while(looptimerflag != true); + looptimerflag = false; + x=emg.read(); + y=(y1/1.001-(0.9969/1.001)*x1+(0.9978565/1.001)*x); + yabs=abs(y); + z=(z1/1.001-(0.006244/1.001)*yabs1+(0.006238/1.001)*yabs); + pc.printf("%f\n\r",z); + x1=x; + y1=y; + z1=z; + yabs1=yabs; + } +} \ No newline at end of file