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: Encoder HIDScope MODSERIAL mbed
Fork of TEST by
main.cpp
- Committer:
- Daanmk
- Date:
- 2014-10-08
- Revision:
- 2:902c38ab4f5a
- Parent:
- 1:c66edcd91108
- Child:
- 3:ef4d1423db92
File content as of revision 2:902c38ab4f5a:
/***************************************/ /* */ /* BRONCODE GROEP 5, MODULE 9, 2014 */ /* *****-THE SLAP-****** */ /* */ /* -Dominique Clevers */ /* -Rianne van Dommelen */ /* -Daan de Muinck Keizer */ /* -David den Houting */ /* -Marjolein Thijssen */ /***************************************/ #include "mbed.h" #include "MODSERIAL.h" #include "encoder.h" #include "HIDScope.h" //Define objects #define A1 0.807313721035803 #define A2 -0.263720649619515 #define B1 -1.721118336253692 #define B2 0.721118336253692 HIDScope scope(2); AnalogIn emgbc(PTB0); //Onderste bordje biceps meting AnalogIn emgtr(PTB1); //Tweede bordje triceps meting //DigitalOut motordirA(PTD3); //DigitalOut motordirB(PTD1); //Encoder motor1(PTD0,PTC9); //Encoder motor2(PTD5,PTC8); MODSERIAL pc(USBTX,USBRX); float filter(float); int main() { float x,y; while(true) { x = (emgbc.read()-0.5)*2; y=filter(x); scope.set(0,x); scope.set(1,y); scope.send(); } } float filter(float x) { static float y,x1,y1,x2,y2; y = A1*y1+A2*y2+x+B1*x1+B2*x2; x2=x1; x1=x; y2=y1; y1=y; return y; }