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
Revision 6:27a4e8d9ddac, committed 2013-10-18
- Comitter:
- Socrates
- Date:
- Fri Oct 18 09:32:49 2013 +0000
- Parent:
- 5:1a1ce2f5cb66
- Child:
- 7:4d2edb5b0164
- Commit message:
- Filters en envellope werken. 35HZ/1, 2Hz/2;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 16 15:26:28 2013 +0000
+++ b/main.cpp Fri Oct 18 09:32:49 2013 +0000
@@ -35,10 +35,13 @@
yabs1b=0;
yabs2b=0;
- numh1=0.996868235770807;
- numh2=-0.996868235770807;
+ //High pass, 35Hz, 1e
+ numh1=0.900575535279376;
+ numh2=-0.900575535279376;
//denh1=1;
- denh2=-0.993736471541615;
+ denh2=-0.801151070558751;
+
+ //Low pass, 2 Hz, 2e orde
numl1=0.391302053991682*pow(10.0,-4.0);
numl2=0.782604107983365*pow(10.0,-4.0);
numl3=0.391302053991682*pow(10.0,-4.0);
@@ -50,21 +53,22 @@
while(1) {
while(looptimerflag != true);
looptimerflag = false;
+
//Triceps
kt=emgt.read();
xt=(kt-0.5)*2.0;
- //High pass, 1 Hz
+ //High pass
//1e orde
yt=xt*numh1+x1t*numh2-y1t*denh2;
-
+
//Rectify
yabst=abs(yt);
- //Low pass, 2 Hz
+ //Low pass
//2e orde
zt=yabst*numl1+yabs1t*numl2+yabs2t*numl3-z1t*denl2-z2t*denl3;
-
+
x1t=xt;
y2t=y1t;
y1t=yt;
@@ -72,22 +76,22 @@
z1t=zt;
yabs2t=yabs1t;
yabs1t=yabst;
-
+
//Biceps
kb=emgb.read();
xb=(kb-0.5)*2.0;
- //High pass, 1 Hz
+ //High pass
//1e orde
yb=xb*numh1+x1b*numh2-y1b*denh2;
-
+
//Rectify
yabsb=abs(yb);
- //Low pass, 2 Hz
+ //Low pass
//2e orde
zb=yabsb*numl1+yabs1b*numl2+yabs2b*numl3-z1b*denl2-z2b*denl3;
-
+
x1b=xb;
y2b=y1b;
y1b=yb;
@@ -95,16 +99,16 @@
z1b=zb;
yabs2b=yabs1b;
yabs1b=yabsb;
-
- if (zb>zt)
- {
- z=zb;
+
+ if (zb>zt) {
+ z=zb;
+ } else {
+ z=zt;
}
- else
- {
- z=zt;
+
+ if (z>1.0) {
+ z=1.0;
}
-
- pc.printf("%f\n\r",z);
+ pc.printf("%f\n\r",z*5.0);
}
}
\ No newline at end of file
