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
Revision 6:bfd24400e9d0, committed 2015-10-22
- Comitter:
- Zeekat
- Date:
- Thu Oct 22 12:21:06 2015 +0000
- Parent:
- 5:867fe891b990
- Child:
- 7:84abed2f376c
- Commit message:
- last version
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 22 11:34:39 2015 +0000
+++ b/main.cpp Thu Oct 22 12:21:06 2015 +0000
@@ -123,10 +123,10 @@
double m2_prev_err = 0;
// EMG calibration variables
-double emg_gain1 = 1; // set to one for unamplified signal
-double emg_gain2 = 1;
+double emg_gain1 = 7; // set to one for unamplified signal
+double emg_gain2 = 7;
-double cal_samples = 25;
+double cal_samples = 125;
double normalize_emg_value = 1; // set te desired value to calibrate the signal to
//// FILTER VARIABLES
@@ -319,8 +319,10 @@
output2 = y5t;
output2_amp = y5t*emg_gain2;
- scope.set(0,output1_amp);
- scope.set(1,output2_amp);
+ scope.set(0,output1);
+ scope.set(1,output2);
+ scope.set(2,output1_amp);
+ scope.set(3,output2_amp);
scope.send();
}
@@ -329,17 +331,16 @@
void det_angles()
{
+ if(output1_amp>1) {output1_amp = 1;}
+ if(output2_amp>1) {output2_amp = 1;}
- if(output1>1) {output1 = 1;}
- if(output2>1) {output2 = 1;}
-
- output1 = potright.read();
- output2 = potleft.read();
+ //output1 = potright.read();
+ //output2 = potleft.read();
double xx = 50+output1_amp*20;
- double ymin = - sqrt(4900 - pow(xx,2));
- double ymax = sqrt(4900 - pow(xx,2));
+ double ymin = -16; //- sqrt(4900 - pow(xx,2));
+ double ymax = 16; //sqrt(4900 - pow(xx,2));
double yy = ymin+output2_amp*(ymax-ymin);
double r = sqrt(pow(xx,2)+pow(yy,2)); // vector naar end effector
double alfa = acos((2*pow(L,2)-pow(r,2))/(2*pow(L,2))); // alfa is de hoek tussen upper en lower arm
@@ -432,7 +433,6 @@
{
double total1 = 0;
double total2 = 0;
-
for(int i = 0; i<cal_samples; i++)
{
EMG_filter(); // run filter
@@ -441,7 +441,7 @@
double input2 = output2;
total2 = total2 + input2;
- wait(0.1);
+ wait(0.02);
}
emg_gain1 = normalize_emg_value/(total1/cal_samples); // normalize the amplification so that the maximum signal hits the desired one
emg_gain2 = normalize_emg_value/(total2/cal_samples);