![](/media/cache/group/9e3cc099b3b04bca937a1cca1da81b19.jpg.50x50_q85.jpg)
Dit is alleen het EMG gedeelte
Dependencies: mbed HIDScope biquadFilter MODSERIAL FXOS8700Q
main.cpp@13:2724d2e747f1, 2019-10-22 (annotated)
- Committer:
- Jellehierck
- Date:
- Tue Oct 22 07:49:24 2019 +0000
- Revision:
- 13:2724d2e747f1
- Parent:
- 12:70f0710400c2
- Child:
- 14:3b6adb5000f1
Cleaned up code and placed comments. Added more scopes to better view filter impact.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IsaRobin | 0:6972d0e91af1 | 1 | //c++ script for filtering of measured EMG signals |
IsaRobin | 0:6972d0e91af1 | 2 | #include "mbed.h" //Base library |
IsaRobin | 0:6972d0e91af1 | 3 | #include "HIDScope.h" // to see if program is working and EMG is filtered properly |
Jellehierck | 2:d3e9788ab1b3 | 4 | // #include "QEI.h"// is needed for the encoder |
Jellehierck | 8:ea3de43c9e8b | 5 | #include "MODSERIAL.h"// in order for connection with the pc |
Jellehierck | 2:d3e9788ab1b3 | 6 | #include "BiQuad.h" |
Jellehierck | 2:d3e9788ab1b3 | 7 | // #include "FastPWM.h" |
Jellehierck | 2:d3e9788ab1b3 | 8 | // #include "Arduino.h" //misschien handig omdat we het EMG arduino board gebruiken (?) |
Jellehierck | 2:d3e9788ab1b3 | 9 | // #include "EMGFilters.h" |
IsaRobin | 0:6972d0e91af1 | 10 | #include <vector> // For easy array management |
Jellehierck | 7:7a088536f1c9 | 11 | #include <numeric> // For manipulating array data |
IsaRobin | 0:6972d0e91af1 | 12 | |
Jellehierck | 13:2724d2e747f1 | 13 | /* |
Jellehierck | 13:2724d2e747f1 | 14 | ------ DEFINE MBED CONNECTIONS ------ |
Jellehierck | 13:2724d2e747f1 | 15 | */ |
IsaRobin | 0:6972d0e91af1 | 16 | |
Jellehierck | 13:2724d2e747f1 | 17 | // PC serial connection |
Jellehierck | 13:2724d2e747f1 | 18 | HIDScope scope( 5 ); |
Jellehierck | 13:2724d2e747f1 | 19 | MODSERIAL pc(USBTX, USBRX); |
IsaRobin | 0:6972d0e91af1 | 20 | |
Jellehierck | 4:09a01d2db8f7 | 21 | // LED |
Jellehierck | 6:5437cc97e1e6 | 22 | DigitalOut led_g(LED_GREEN); |
Jellehierck | 6:5437cc97e1e6 | 23 | DigitalOut led_r(LED_RED); |
Jellehierck | 8:ea3de43c9e8b | 24 | DigitalOut led_b(LED_BLUE); |
Jellehierck | 8:ea3de43c9e8b | 25 | |
Jellehierck | 8:ea3de43c9e8b | 26 | // Buttons |
Jellehierck | 8:ea3de43c9e8b | 27 | InterruptIn button1(D11); |
Jellehierck | 8:ea3de43c9e8b | 28 | InterruptIn button2(D10); |
Jellehierck | 12:70f0710400c2 | 29 | InterruptIn button3(SW3); |
Jellehierck | 4:09a01d2db8f7 | 30 | |
Jellehierck | 13:2724d2e747f1 | 31 | // Global variables for EMG reading |
Jellehierck | 13:2724d2e747f1 | 32 | AnalogIn emg1_in (A1); // Right biceps, x axis |
Jellehierck | 13:2724d2e747f1 | 33 | AnalogIn emg2_in (A2); // Left biceps, y axis |
Jellehierck | 13:2724d2e747f1 | 34 | AnalogIn emg3_in (A3); // Third muscle, TBD |
Jellehierck | 13:2724d2e747f1 | 35 | |
IsaRobin | 0:6972d0e91af1 | 36 | double emg1; |
Jellehierck | 12:70f0710400c2 | 37 | double emg1_MVC; |
Jellehierck | 12:70f0710400c2 | 38 | double emg1_MVC_stdev; |
Jellehierck | 12:70f0710400c2 | 39 | double emg1_rest; |
Jellehierck | 12:70f0710400c2 | 40 | double emg1_rest_stdev; |
Jellehierck | 7:7a088536f1c9 | 41 | vector<double> emg1_cal; |
Jellehierck | 7:7a088536f1c9 | 42 | |
Jellehierck | 13:2724d2e747f1 | 43 | double emg2; |
Jellehierck | 13:2724d2e747f1 | 44 | double emg2_MVC; |
Jellehierck | 13:2724d2e747f1 | 45 | double emg2_MVC_stdev; |
Jellehierck | 13:2724d2e747f1 | 46 | double emg2_rest; |
Jellehierck | 13:2724d2e747f1 | 47 | double emg2_rest_stdev; |
Jellehierck | 13:2724d2e747f1 | 48 | vector<double> emg2_cal; |
IsaRobin | 0:6972d0e91af1 | 49 | |
Jellehierck | 13:2724d2e747f1 | 50 | double emg3; |
Jellehierck | 13:2724d2e747f1 | 51 | double emg3_MVC; |
Jellehierck | 13:2724d2e747f1 | 52 | double emg3_MVC_stdev; |
Jellehierck | 13:2724d2e747f1 | 53 | double emg3_rest; |
Jellehierck | 13:2724d2e747f1 | 54 | double emg3_rest_stdev; |
Jellehierck | 13:2724d2e747f1 | 55 | vector<double> emg3_cal; |
Jellehierck | 13:2724d2e747f1 | 56 | |
Jellehierck | 13:2724d2e747f1 | 57 | // Initialize tickers and timeouts |
Jellehierck | 4:09a01d2db8f7 | 58 | Ticker tickSample; |
Jellehierck | 13:2724d2e747f1 | 59 | Ticker tickSampleCalibration; |
Jellehierck | 7:7a088536f1c9 | 60 | Timeout timeoutCalibrationMVC; |
Jellehierck | 12:70f0710400c2 | 61 | Timeout timeoutCalibrationRest; |
Jellehierck | 4:09a01d2db8f7 | 62 | |
Jellehierck | 13:2724d2e747f1 | 63 | /* |
Jellehierck | 13:2724d2e747f1 | 64 | ------ GLOBAL VARIABLES ------ |
Jellehierck | 13:2724d2e747f1 | 65 | */ |
Jellehierck | 13:2724d2e747f1 | 66 | const int Fs = 500; // Sampling frequency (s) |
Jellehierck | 11:042170a9b93a | 67 | const double Tcal = 10.0f; // Calibration duration (s) |
Jellehierck | 13:2724d2e747f1 | 68 | int trim_cal = 1; // Trim transient behaviour of calibration (s) |
Jellehierck | 4:09a01d2db8f7 | 69 | |
Jellehierck | 13:2724d2e747f1 | 70 | // Calculate global variables |
Jellehierck | 13:2724d2e747f1 | 71 | const double Ts = 1/Fs; // Sampling time (s) |
Jellehierck | 13:2724d2e747f1 | 72 | int trim_cal_i = trim_cal * Fs - 1; // Determine iterator of transient behaviour trim |
Jellehierck | 13:2724d2e747f1 | 73 | |
Jellehierck | 13:2724d2e747f1 | 74 | // Notch biquad filter coefficients (iirnotch Q factor 35 @50Hz) from MATLAB: |
Jellehierck | 13:2724d2e747f1 | 75 | BiQuad bq_notch( 0.995636295063941, -1.89829218816065, 0.995636295063941, 1, -1.89829218816065, 0.991272590127882); // b01 b11 b21 a01 a11 a21 |
Jellehierck | 11:042170a9b93a | 76 | BiQuadChain bqc_notch; |
Jellehierck | 1:059cca298369 | 77 | |
Jellehierck | 13:2724d2e747f1 | 78 | // Highpass biquad filter coefficients (butter 4th order @10Hz cutoff) from MATLAB |
Jellehierck | 13:2724d2e747f1 | 79 | BiQuad bq_H1(0.922946103200875, -1.84589220640175, 0.922946103200875, 1, -1.88920703055163, 0.892769008131025); // b01 b11 b21 a01 a11 a21 |
Jellehierck | 13:2724d2e747f1 | 80 | BiQuad bq_H2(1, -2, 1, 1, -1.95046575793011, 0.954143234875078); // b02 b12 b22 a02 a12 a22 |
Jellehierck | 13:2724d2e747f1 | 81 | BiQuadChain bqc_high; |
IsaRobin | 0:6972d0e91af1 | 82 | |
Jellehierck | 13:2724d2e747f1 | 83 | // Lowpass biquad filter coefficients (butter 4th order @5Hz cutoff) from MATLAB: |
Jellehierck | 13:2724d2e747f1 | 84 | BiQuad bq_L1(5.32116245737504e-08, 1.06423249147501e-07, 5.32116245737504e-08, 1, -1.94396715039462, 0.944882378004138); // b01 b11 b21 a01 a11 a21 |
Jellehierck | 13:2724d2e747f1 | 85 | BiQuad bq_L2(1, 2, 1, 1, -1.97586467534468, 0.976794920438162); // b02 b12 b22 a02 a12 a22 |
Jellehierck | 13:2724d2e747f1 | 86 | BiQuadChain bqc_low; |
Jellehierck | 2:d3e9788ab1b3 | 87 | |
Jellehierck | 13:2724d2e747f1 | 88 | /* |
Jellehierck | 13:2724d2e747f1 | 89 | ------ HELPER FUNCTIONS ------ |
Jellehierck | 13:2724d2e747f1 | 90 | */ |
Jellehierck | 13:2724d2e747f1 | 91 | |
Jellehierck | 13:2724d2e747f1 | 92 | // Return mean of vector |
Jellehierck | 8:ea3de43c9e8b | 93 | double getMean(const vector<double> &vect) |
Jellehierck | 7:7a088536f1c9 | 94 | { |
Jellehierck | 8:ea3de43c9e8b | 95 | double sum = 0.0; |
Jellehierck | 8:ea3de43c9e8b | 96 | int vect_n = vect.size(); |
Jellehierck | 8:ea3de43c9e8b | 97 | |
Jellehierck | 8:ea3de43c9e8b | 98 | for ( int i = 0; i < vect_n; i++ ) { |
Jellehierck | 8:ea3de43c9e8b | 99 | sum += vect[i]; |
Jellehierck | 8:ea3de43c9e8b | 100 | } |
Jellehierck | 8:ea3de43c9e8b | 101 | return sum/vect_n; |
Jellehierck | 8:ea3de43c9e8b | 102 | } |
Jellehierck | 8:ea3de43c9e8b | 103 | |
Jellehierck | 13:2724d2e747f1 | 104 | // Return standard deviation of vector |
Jellehierck | 8:ea3de43c9e8b | 105 | double getStdev(const vector<double> &vect, const double vect_mean) |
Jellehierck | 8:ea3de43c9e8b | 106 | { |
Jellehierck | 8:ea3de43c9e8b | 107 | double sum2 = 0.0; |
Jellehierck | 8:ea3de43c9e8b | 108 | int vect_n = vect.size(); |
Jellehierck | 8:ea3de43c9e8b | 109 | |
Jellehierck | 8:ea3de43c9e8b | 110 | for ( int i = 0; i < vect_n; i++ ) { |
Jellehierck | 8:ea3de43c9e8b | 111 | sum2 += pow( vect[i] - vect_mean, 2 ); |
Jellehierck | 8:ea3de43c9e8b | 112 | } |
Jellehierck | 8:ea3de43c9e8b | 113 | double output = sqrt( sum2 / vect_n ); |
Jellehierck | 8:ea3de43c9e8b | 114 | return output; |
Jellehierck | 7:7a088536f1c9 | 115 | } |
Jellehierck | 7:7a088536f1c9 | 116 | |
Jellehierck | 13:2724d2e747f1 | 117 | // Check filter stability |
Jellehierck | 6:5437cc97e1e6 | 118 | bool checkBQChainStable() |
Jellehierck | 6:5437cc97e1e6 | 119 | { |
Jellehierck | 11:042170a9b93a | 120 | bool n_stable = bqc_notch.stable(); |
Jellehierck | 11:042170a9b93a | 121 | bool hp_stable = bqc_high.stable(); |
Jellehierck | 6:5437cc97e1e6 | 122 | bool l_stable = bqc_low.stable(); |
Jellehierck | 6:5437cc97e1e6 | 123 | |
Jellehierck | 11:042170a9b93a | 124 | if (n_stable && hp_stable && l_stable) { |
Jellehierck | 6:5437cc97e1e6 | 125 | return true; |
Jellehierck | 6:5437cc97e1e6 | 126 | } else { |
Jellehierck | 6:5437cc97e1e6 | 127 | return false; |
Jellehierck | 6:5437cc97e1e6 | 128 | } |
Jellehierck | 6:5437cc97e1e6 | 129 | } |
Jellehierck | 6:5437cc97e1e6 | 130 | |
Jellehierck | 13:2724d2e747f1 | 131 | /* |
Jellehierck | 13:2724d2e747f1 | 132 | ------ TICKER FUNCTIONS ------ |
Jellehierck | 13:2724d2e747f1 | 133 | */ |
Jellehierck | 11:042170a9b93a | 134 | /* |
Jellehierck | 6:5437cc97e1e6 | 135 | // Read samples, filter samples and output to HIDScope |
Jellehierck | 2:d3e9788ab1b3 | 136 | void sample() |
Jellehierck | 2:d3e9788ab1b3 | 137 | { |
Jellehierck | 4:09a01d2db8f7 | 138 | // Read EMG inputs |
Jellehierck | 2:d3e9788ab1b3 | 139 | emg1 = emg1_in.read(); |
Jellehierck | 2:d3e9788ab1b3 | 140 | emg2 = emg2_in.read(); |
Jellehierck | 2:d3e9788ab1b3 | 141 | emg3 = emg3_in.read(); |
Jellehierck | 4:09a01d2db8f7 | 142 | |
Jellehierck | 4:09a01d2db8f7 | 143 | // Output raw EMG input |
Jellehierck | 4:09a01d2db8f7 | 144 | scope.set(0, emg1 ); |
Jellehierck | 6:5437cc97e1e6 | 145 | |
Jellehierck | 5:3d65f89e3755 | 146 | // Filter notch and highpass |
Jellehierck | 5:3d65f89e3755 | 147 | double emg1_n_hp = bqc_notch_high.step( emg1 ); |
Jellehierck | 6:5437cc97e1e6 | 148 | |
Jellehierck | 5:3d65f89e3755 | 149 | // Rectify |
Jellehierck | 5:3d65f89e3755 | 150 | double emg1_rectify = fabs( emg1_n_hp ); |
Jellehierck | 6:5437cc97e1e6 | 151 | |
Jellehierck | 5:3d65f89e3755 | 152 | // Filter lowpass (completes envelope) |
Jellehierck | 5:3d65f89e3755 | 153 | double emg1_env = bqc_low.step( emg1_rectify ); |
Jellehierck | 4:09a01d2db8f7 | 154 | |
Jellehierck | 4:09a01d2db8f7 | 155 | // Output EMG after filters |
Jellehierck | 5:3d65f89e3755 | 156 | scope.set(1, emg1_env ); |
Jellehierck | 4:09a01d2db8f7 | 157 | scope.send(); |
Jellehierck | 2:d3e9788ab1b3 | 158 | } |
Jellehierck | 11:042170a9b93a | 159 | */ |
IsaRobin | 0:6972d0e91af1 | 160 | |
Jellehierck | 7:7a088536f1c9 | 161 | void sampleCalibration() |
Jellehierck | 7:7a088536f1c9 | 162 | { |
Jellehierck | 7:7a088536f1c9 | 163 | // Read EMG inputs |
Jellehierck | 7:7a088536f1c9 | 164 | emg1 = emg1_in.read(); |
Jellehierck | 7:7a088536f1c9 | 165 | emg2 = emg2_in.read(); |
Jellehierck | 7:7a088536f1c9 | 166 | emg3 = emg3_in.read(); |
Jellehierck | 7:7a088536f1c9 | 167 | |
Jellehierck | 7:7a088536f1c9 | 168 | // Output raw EMG input |
Jellehierck | 7:7a088536f1c9 | 169 | scope.set(0, emg1 ); |
Jellehierck | 10:97a79aa10a56 | 170 | |
Jellehierck | 10:97a79aa10a56 | 171 | double emg1_n = bqc_notch.step( emg1 ); // Filter notch |
Jellehierck | 11:042170a9b93a | 172 | scope.set(1, emg1_n); |
Jellehierck | 10:97a79aa10a56 | 173 | double emg1_hp = bqc_high.step( emg1_n ); // Filter highpass |
Jellehierck | 13:2724d2e747f1 | 174 | scope.set(2, emg1_n); |
Jellehierck | 11:042170a9b93a | 175 | double emg1_rectify = fabs( emg1_hp ); // Rectify |
Jellehierck | 13:2724d2e747f1 | 176 | scope.set(3, emg1_n); |
Jellehierck | 7:7a088536f1c9 | 177 | double emg1_env = bqc_low.step( emg1_rectify ); // Filter lowpass (completes envelope) |
Jellehierck | 7:7a088536f1c9 | 178 | |
Jellehierck | 7:7a088536f1c9 | 179 | // Output EMG after filters |
Jellehierck | 13:2724d2e747f1 | 180 | scope.set(4, emg1_env ); |
Jellehierck | 7:7a088536f1c9 | 181 | scope.send(); |
Jellehierck | 7:7a088536f1c9 | 182 | |
Jellehierck | 7:7a088536f1c9 | 183 | emg1_cal.push_back(emg1_env); |
Jellehierck | 7:7a088536f1c9 | 184 | } |
Jellehierck | 7:7a088536f1c9 | 185 | |
Jellehierck | 13:2724d2e747f1 | 186 | /* |
Jellehierck | 13:2724d2e747f1 | 187 | ------ EMG CALIBRATION FUNCTIONS ------ |
Jellehierck | 13:2724d2e747f1 | 188 | */ |
Jellehierck | 13:2724d2e747f1 | 189 | |
Jellehierck | 13:2724d2e747f1 | 190 | // Finish up calibration of MVC |
Jellehierck | 7:7a088536f1c9 | 191 | void calibrationMVCFinished() |
Jellehierck | 7:7a088536f1c9 | 192 | { |
Jellehierck | 13:2724d2e747f1 | 193 | tickSampleCalibration.detach(); // Stop calibration ticker to remove interrupt |
Jellehierck | 13:2724d2e747f1 | 194 | emg1_MVC = getMean(emg1_cal); // Store MVC globally |
Jellehierck | 13:2724d2e747f1 | 195 | emg1_MVC_stdev = getStdev(emg1_cal, emg1_MVC); // Store MVC stde globally |
Jellehierck | 13:2724d2e747f1 | 196 | emg1_cal.clear(); // Empty vector to prevent memory overflow |
Jellehierck | 13:2724d2e747f1 | 197 | led_b = 1; // Turn off calibration led |
Jellehierck | 7:7a088536f1c9 | 198 | } |
Jellehierck | 7:7a088536f1c9 | 199 | |
Jellehierck | 13:2724d2e747f1 | 200 | // Run calibration of MVC |
Jellehierck | 7:7a088536f1c9 | 201 | void calibrationMVC() |
Jellehierck | 7:7a088536f1c9 | 202 | { |
Jellehierck | 13:2724d2e747f1 | 203 | timeoutCalibrationMVC.attach( &calibrationMVCFinished, Tcal); // Stop MVC calibration after interval |
Jellehierck | 13:2724d2e747f1 | 204 | tickSampleCalibration.attach( &sampleCalibration, Ts ); // Start sample ticker |
Jellehierck | 13:2724d2e747f1 | 205 | led_b = 0; // Turn on calibration led |
Jellehierck | 7:7a088536f1c9 | 206 | } |
Jellehierck | 7:7a088536f1c9 | 207 | |
Jellehierck | 13:2724d2e747f1 | 208 | // Finish up calibration in rest |
Jellehierck | 12:70f0710400c2 | 209 | void calibrationRestFinished() |
Jellehierck | 12:70f0710400c2 | 210 | { |
Jellehierck | 13:2724d2e747f1 | 211 | tickSampleCalibration.detach(); // Stop calibration ticker to remove interrupt |
Jellehierck | 13:2724d2e747f1 | 212 | emg1_rest = getMean(emg1_cal); // Store rest globally |
Jellehierck | 13:2724d2e747f1 | 213 | emg1_rest_stdev = getStdev(emg1_cal, emg1_rest);// Store rest stdev globally |
Jellehierck | 13:2724d2e747f1 | 214 | emg1_cal.clear(); // Empty vector to prevent memory overflow |
Jellehierck | 13:2724d2e747f1 | 215 | led_b = 1; // Turn off calibration led |
Jellehierck | 12:70f0710400c2 | 216 | } |
Jellehierck | 12:70f0710400c2 | 217 | |
Jellehierck | 12:70f0710400c2 | 218 | void calibrationRest() |
Jellehierck | 12:70f0710400c2 | 219 | { |
Jellehierck | 13:2724d2e747f1 | 220 | timeoutCalibrationRest.attach( &calibrationRestFinished, Tcal); // Stop rest calibration after interval |
Jellehierck | 13:2724d2e747f1 | 221 | tickSampleCalibration.attach( &sampleCalibration, Ts ); // Start sample ticker |
Jellehierck | 13:2724d2e747f1 | 222 | led_b = 0; // Turn on calibration led |
Jellehierck | 12:70f0710400c2 | 223 | } |
Jellehierck | 12:70f0710400c2 | 224 | |
Jellehierck | 13:2724d2e747f1 | 225 | // Determine scale factors for operation mode |
Jellehierck | 12:70f0710400c2 | 226 | void makeScale() |
Jellehierck | 12:70f0710400c2 | 227 | { |
Jellehierck | 13:2724d2e747f1 | 228 | double margin_percentage = 10; // Set up % margin for rest |
Jellehierck | 13:2724d2e747f1 | 229 | double factor1 = 1 / emg1_MVC; // Factor to normalize MVC |
Jellehierck | 13:2724d2e747f1 | 230 | double emg1_th = emg1_rest * factor1 + margin_percentage/100; // Set normalized rest threshold |
Jellehierck | 12:70f0710400c2 | 231 | |
Jellehierck | 12:70f0710400c2 | 232 | pc.printf("Factor: %f TH: %f\r\n", factor1, emg1_th); |
Jellehierck | 12:70f0710400c2 | 233 | } |
Jellehierck | 7:7a088536f1c9 | 234 | |
Jellehierck | 5:3d65f89e3755 | 235 | void main() |
Jellehierck | 4:09a01d2db8f7 | 236 | { |
Jellehierck | 13:2724d2e747f1 | 237 | pc.baud(115200); // MODSERIAL rate |
Jellehierck | 8:ea3de43c9e8b | 238 | pc.printf("Starting\r\n"); |
Jellehierck | 13:2724d2e747f1 | 239 | |
Jellehierck | 13:2724d2e747f1 | 240 | // tickSample.attach(&sample, Ts); // Initialize sample ticker |
Jellehierck | 6:5437cc97e1e6 | 241 | |
Jellehierck | 6:5437cc97e1e6 | 242 | // Create BQ chains to reduce computations |
Jellehierck | 10:97a79aa10a56 | 243 | bqc_notch.add( &bq_notch ); |
Jellehierck | 10:97a79aa10a56 | 244 | bqc_high.add( &bq_H1 ).add( &bq_H2 ); |
Jellehierck | 5:3d65f89e3755 | 245 | bqc_low.add( &bq_L1 ).add( &bq_L2 ); |
Jellehierck | 4:09a01d2db8f7 | 246 | |
Jellehierck | 13:2724d2e747f1 | 247 | led_b = 1; // Turn blue led off at startup |
Jellehierck | 13:2724d2e747f1 | 248 | led_g = 1; // Turn green led off at startup |
Jellehierck | 13:2724d2e747f1 | 249 | led_r = 1; // Turn red led off at startup |
Jellehierck | 8:ea3de43c9e8b | 250 | |
Jellehierck | 6:5437cc97e1e6 | 251 | // If any filter chain is unstable, red led will light up |
Jellehierck | 6:5437cc97e1e6 | 252 | if (checkBQChainStable) { |
Jellehierck | 6:5437cc97e1e6 | 253 | led_r = 1; // LED off |
Jellehierck | 6:5437cc97e1e6 | 254 | } else { |
Jellehierck | 6:5437cc97e1e6 | 255 | led_r = 0; // LED on |
Jellehierck | 6:5437cc97e1e6 | 256 | } |
Jellehierck | 6:5437cc97e1e6 | 257 | |
Jellehierck | 13:2724d2e747f1 | 258 | button1.fall( &calibrationMVC ); // Run MVC calibration on button press |
Jellehierck | 13:2724d2e747f1 | 259 | button2.fall( &calibrationRest ); // Run rest calibration on button press |
Jellehierck | 13:2724d2e747f1 | 260 | button3.fall( &makeScale ); // Create scale factors and close calibration at button press |
Jellehierck | 8:ea3de43c9e8b | 261 | |
Jellehierck | 4:09a01d2db8f7 | 262 | while(true) { |
Jellehierck | 7:7a088536f1c9 | 263 | |
Jellehierck | 6:5437cc97e1e6 | 264 | // Show that system is running |
Jellehierck | 8:ea3de43c9e8b | 265 | // led_g = !led_g; |
Jellehierck | 12:70f0710400c2 | 266 | pc.printf("EMG MVC: %f stdev: %f\r\nEMG Rest: %f stdev: %f\r\n", emg1_MVC, emg1_MVC_stdev, emg1_rest, emg1_rest_stdev); |
Jellehierck | 4:09a01d2db8f7 | 267 | wait(0.5); |
Jellehierck | 4:09a01d2db8f7 | 268 | } |
Jellehierck | 4:09a01d2db8f7 | 269 | } |