Dependencies: mbed HIDScope biquadFilter
Diff: main.cpp
- Revision:
- 28:4eaf5990a7b3
- Parent:
- 27:c53dd84c38aa
- Child:
- 29:1483fd8674da
--- a/main.cpp Mon Oct 21 08:20:40 2019 +0000 +++ b/main.cpp Mon Oct 21 08:34:37 2019 +0000 @@ -25,25 +25,27 @@ * this function samples the emg and sends it to HIDScope **/ float filter_value; +float emg0_value; +float emg1_value; void sample() { /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */ - float emg0_value = emg0.read(); - float emg1_value = emg1.read(); + emg0_value = emg0.read(); + emg1_value = emg1.read(); - float filter_value = fabs(bq2.step(fabs(bq1.step(emg0_value - emg1_value)))); + filter_value = fabs(bq2.step(fabs(bq1.step(emg0_value-emg1_value)))); - //scope.set(0, emg0.read() ); - //scope.set(1, emg1.read() ); - //scope.set(2, filter_value); + scope.set(0, emg0.read() ); + scope.set(1, emg1.read() ); + scope.set(2, filter_value); /* Repeat the step above if required for more channels of required (channel 0 up to 5 = 6 channels) * Ensure that enough channels are available (HIDScope scope( 2 )) * Finally, send all channels to the PC at once */ - //scope.send(); + scope.send(); /* To indicate that the function is working, the LED is toggled */ led = !led; @@ -60,7 +62,7 @@ sample(); pc.printf("I can reach this point\r\n"); sample_array[i] = filter_value; - pc.printf("The filter_value is %f\r\n",filter_value); + pc.printf("The filter_value is %f\r\nThe EMG0 input is %f\r\nThe EMG1 input is %f\r\n",filter_value, emg0_value, emg1_value); i++; wait(0.001); } @@ -74,7 +76,7 @@ /**Attach the 'sample' function to the timer 'sample_timer'. * this ensures that 'sample' is executed every... 0.002 seconds = 500 Hz */ - + wait(2); calibration(); sample_timer.attach(&sample, 0.001);