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.
Dependents: PID_VelocityExample TheProgram Passief_stuurprogramma Actief_stuurprogramma
Revision 2:84ff5b0f5406, committed 2015-10-12
- Comitter:
- ewoud
- Date:
- Mon Oct 12 09:33:07 2015 +0000
- Parent:
- 1:b73e3dc74d7c
- Child:
- 3:0662d78d9092
- Commit message:
- output user info to serial
Changed in this revision
| EMG.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/EMG.h Mon Oct 12 09:04:24 2015 +0000
+++ b/EMG.h Mon Oct 12 09:33:07 2015 +0000
@@ -46,7 +46,7 @@
u1 = input1; u2 = input2; u3 = input3; u4 = input4; // sample
y1 = highpass1.step(u1); y2 = highpass2.step(u2); y3 = highpass3.step(u3); y4 = highpass4.step(u4); // filter order is: high-pass --> rectify --> low-pass
y1 = fabs(y1); y2 = fabs(y2); y3 = fabs(y3); y4 = fabs(y4);
- y1 = lowpass1.step(y1)*cali_fact; y2 = lowpass2.step(y2)*cali_fact; y3 = lowpass3.step(y3)*cali_fact; y4 = lowpass4.step(y4)*cali_fact; // roughly normalize to a scale of 0 - 1, where 0 is minimum and 1 is roughly the maximum output of dennis.
+ y1 = lowpass1.step(y1)*cali_fact1; y2 = lowpass2.step(y2)*cali_fact2; y3 = lowpass3.step(y3)*cali_fact1; y4 = lowpass4.step(y4)*cali_fact1; // roughly normalize to a scale of 0 - 1, where 0 is minimum and 1 is roughly the maximum output of dennis.
}
void samplego() // ticker function, set flag to true every sample interval
@@ -56,10 +56,11 @@
void calibrate() // function to calibrate the emg signals from the user. It takes 5 seconds of measurements of maximum output, then takes the max and normalizes to that.
{
+ pc.printf("Calibration starting \n\r");
double cali_max1 = 0; // declare max
double cali_max2 = 0;
cali_fact1 = 1; cali_fact2 = 1;
- led = 1;
+
for(int cali_index = 0; cali_index < 2560; cali_index++)
{
sample_filter();
@@ -80,8 +81,9 @@
}
cali_fact1 = (double)1/cali_max1;
cali_fact2 = (double)1/cali_max2;
- led = 0;
- pc.printf("Calibration factor 1: %f\nCalibration factor 2: %f\n", cali_fact1, cali_fact2);
+ delete[] &cali_array1;
+ delete[] &cali_array2;
+ pc.printf("Calibration factor 1: %f\n\rCalibration factor 2: %f\n\r", cali_fact1, cali_fact2);
}
/*