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
Diff: EMG.h
- Revision:
- 1:b73e3dc74d7c
- Parent:
- 0:b5f7b64b0fe4
- Child:
- 2:84ff5b0f5406
diff -r b5f7b64b0fe4 -r b73e3dc74d7c EMG.h --- a/EMG.h Mon Oct 12 08:47:41 2015 +0000 +++ b/EMG.h Mon Oct 12 09:04:24 2015 +0000 @@ -34,10 +34,12 @@ Ticker T1; volatile bool sample_go; +DigitalOut led(LED_RED); InterruptIn cali_button(PTA4); // initialize interrupt button for calibration stuff -double cali_fact = 8; // calibration factor to normalize filter output to a scale of 0 - 1 -double cali_array[2560] = {}; // array to store values in - +double cali_fact1 = 8; +double cali_fact2 = 8; // calibration factor to normalize filter output to a scale of 0 - 1 +double cali_array1[2560] = {}; // array to store values in for channel 1 +double cali_array2[2560] = {}; // array to store values in for channel 2 void sample_filter() { @@ -54,20 +56,32 @@ 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. { - double cali_max = 0; // declare max - cali_fact = 1; + 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(); - cali_array[cali_index] = y1; + cali_array1[cali_index] = y1; + cali_array2[cali_index] = y2; wait((float)1/Fs); } for(int cali_index2 = 0; cali_index2<2560; cali_index2++) { - if(cali_array[cali_index2] > cali_max) - cali_max = cali_array[cali_index2]; + if(cali_array1[cali_index2] > cali_max1) + { + cali_max1 = cali_array1[cali_index2]; + } + if(cali_array2[cali_index2] > cali_max2) + { + cali_max2 = cali_array2[cali_index2]; + } } - cali_fact = (double)1/cali_max; + 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); } /*