checkje

Dependencies:   HIDScope MODSERIAL mbed

Fork of EMG by Tom Tom

Committer:
daniQQue
Date:
Fri Oct 28 08:20:21 2016 +0000
Revision:
23:7de28be57d75
Parent:
22:10f62c4f88eb
hidscope test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vsluiter 0:32bb76391d89 1 #include "mbed.h"
vsluiter 11:ce72ec658a95 2 #include "HIDScope.h"
daniQQue 23:7de28be57d75 3 #include "MODSERIAL.h"
vsluiter 4:8b298dfada81 4 //Define objects
tomlankhorst 19:2bf824669684 5 AnalogIn emg0( A0 );
tomlankhorst 19:2bf824669684 6 AnalogIn emg1( A1 );
tomlankhorst 19:2bf824669684 7
tomlankhorst 14:f83354387756 8 Ticker sample_timer;
tomlankhorst 19:2bf824669684 9 HIDScope scope( 2 );
tomlankhorst 18:21d8e7a81cf5 10 DigitalOut led(LED1);
daniQQue 23:7de28be57d75 11 MODSERIAL pc(USBTX,USBRX);
vsluiter 2:e314bb3b2d99 12
tomlankhorst 14:f83354387756 13 /** Sample function
tomlankhorst 14:f83354387756 14 * this function samples the emg and sends it to HIDScope
tomlankhorst 14:f83354387756 15 **/
tomlankhorst 14:f83354387756 16 void sample()
vsluiter 2:e314bb3b2d99 17 {
tomlankhorst 19:2bf824669684 18 /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */
tomlankhorst 19:2bf824669684 19 scope.set(0, emg0.read() );
tomlankhorst 19:2bf824669684 20 scope.set(1, emg1.read() );
tomlankhorst 19:2bf824669684 21 /* Repeat the step above if required for more channels of required (channel 0 up to 5 = 6 channels)
tomlankhorst 19:2bf824669684 22 * Ensure that enough channels are available (HIDScope scope( 2 ))
tomlankhorst 20:97059009a491 23 * Finally, send all channels to the PC at once */
vsluiter 11:ce72ec658a95 24 scope.send();
tomlankhorst 18:21d8e7a81cf5 25 /* To indicate that the function is working, the LED is toggled */
tomlankhorst 18:21d8e7a81cf5 26 led = !led;
daniQQue 23:7de28be57d75 27 pc.printf("send\r\n");
vsluiter 2:e314bb3b2d99 28 }
vsluiter 0:32bb76391d89 29
vsluiter 0:32bb76391d89 30 int main()
tomlankhorst 19:2bf824669684 31 {
tomlankhorst 14:f83354387756 32 /**Attach the 'sample' function to the timer 'sample_timer'.
tomlankhorst 19:2bf824669684 33 * this ensures that 'sample' is executed every... 0.002 seconds = 500 Hz
vsluiter 4:8b298dfada81 34 */
daniQQue 23:7de28be57d75 35
daniQQue 23:7de28be57d75 36 pc.baud(115200);
daniQQue 21:6152d0c75aa6 37 sample_timer.attach(&sample, 0.001);
daniQQue 23:7de28be57d75 38
tomlankhorst 14:f83354387756 39 /*empty loop, sample() is executed periodically*/
tomlankhorst 15:0da764eea774 40 while(1) {}
vsluiter 0:32bb76391d89 41 }