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:
- 0:b13a317308d1
- Child:
- 1:34202d107458
File content as of revision 0:b13a317308d1:
#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; } }