EMG filtering; highpass, notch, abs, moving average
Dependencies: HIDScope MODSERIAL- mbed-dsp mbed
Revision 39:0328b1f16a5a, committed 2014-10-08
- Comitter:
- Hooglugt
- Date:
- Wed Oct 08 12:26:56 2014 +0000
- Parent:
- 38:277ba1c0693c
- Child:
- 40:7e93c2f1c1e9
- Commit message:
- alleen nog floats van emg signaal (bi+tri), error qua lampje kleurtjes zijn verdwenen
Changed in this revision
Project_main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Project_main.cpp Wed Oct 08 11:41:43 2014 +0000 +++ b/Project_main.cpp Wed Oct 08 12:26:56 2014 +0000 @@ -2,21 +2,20 @@ #include "MODSERIAL.h" #include "HIDScope.h" -#define TIMEB4NEXTCHOICE 2 // 1s keuzelampje blijft aan -#define TIMEBETWEENBLINK 20 // 1s voor volgende blink +#define TIMEB4NEXTCHOICE 1 // sec keuzelampje blijft aan +#define TIMEBETWEENBLINK 20 // sec voor volgende blink //Define objects AnalogIn emg0(PTB1); //Analog input biceps -float emg_bifloat; //Float voor EMG-waarde biceps, VRAAG: waarom we hier een PwmOut voor gebruiken - kunnen we geen float gebruiken? +float emg_bifloat; //Float voor EMG-waarde biceps AnalogIn emg1(PTB2); //Analog input triceps float emg_trifloat; //Float voor EMG-waarde triceps -HIDScope scope(4); - Ticker log_timer; Ticker reset_timer; MODSERIAL pc(USBTX,USBRX); +HIDScope scope(2); PwmOut red(LED_RED); PwmOut green(LED_GREEN); @@ -25,19 +24,11 @@ int direction = 0; int force = 0; - - -void looper() //nieuwe looper maken, die om een nog te bepalen tijdseenheid de emgtrifloat checked en anders nieuwe goto maakt naar vorige selectiekeuze +void looper() { - /*put raw emg value of biceps both in emg_bifloat and in emg_bivalue*/ + //put raw emg value of biceps and triceps in emg_bifloat and emg_trifloat, respectively emg_bifloat = emg0.read(); // read float value (0..1 = 0..3.3V) biceps - uint16_t emg_bivalue; - emg_bivalue = emg0.read_u16(); // read direct ADC result (0..4096 = 0..3.3V) biceps - - /*put raw emg value of triceps both in emg_trifloat and in emg_trivalue*/ emg_trifloat = emg1.read(); // read float value (0..1 = 0..3.3V) triceps - uint16_t emg_trivalue; - emg_trivalue = emg1.read_u16(); // read direct ADC result (0..4096 = 0..3.3V) biceps /*send value to PC. Line below is used to prevent buffer overrun */ if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) { //VRAAG: praktisch nut hiervan? print emg value wanneer buffercount groter dan 30 is @@ -46,10 +37,8 @@ /* EMG-singaal van biceps en triceps worden hier gefilterd*/ - scope.set(0,emg_bivalue); - scope.set(1,emg_bifloat); - scope.set(2,emg_trivalue); - scope.set(3,emg_trifloat); + scope.set(0,emg_bifloat); + scope.set(1,emg_trifloat); scope.send(); } @@ -67,8 +56,6 @@ int main() { pc.baud(115200); //baudrate instellen -// emg_bifloat.period_ms(2); //sets period for the PWM to the emgfloat PTD4 -// emg_trifloat.period_ms(2); log_timer.attach(looper, 0.001); // The looper() function will be called every 0.001 seconds (with the ticker object) // reset_timer.attach(resetlooper, 0.1); // @@ -207,34 +194,34 @@ if(direction == 1 && force == 1) { // links zwak - pc.printf("links zwak"); + pc.printf("links zwak "); } if(direction == 1 && force == 2) { // links normaal - pc.printf("links normaal"); + pc.printf("links normaal "); } if(direction == 1 && force == 3) { // links sterk - pc.printf("links sterk"); + pc.printf("links sterk "); } if(direction == 2 && force == 1) { // mid zwak - pc.printf("mid zwak"); + pc.printf("mid zwak "); } if(direction == 2 && force == 2) { // mid normaal - pc.printf("mid normaal"); + pc.printf("mid normaal "); } if(direction == 2 && force == 3) { // mid sterk - pc.printf("mid sterk"); + pc.printf("mid sterk "); } if(direction == 3 && force == 1) { // rechts zwak - pc.printf("rechts zwak"); + pc.printf("rechts zwak "); } if(direction == 3 && force == 2) { // rechts normaal - pc.printf("rechts normaal"); + pc.printf("rechts normaal "); } if(direction == 3 && force == 3) { // rechts sterk - pc.printf("rechts sterk"); + pc.printf("rechts sterk "); } if(direction == 0 || force == 0) { // wanneer de triceps in de korte tijd is aangespannen nadat beide keuzes zijn gemaakt - pc.printf("error"); + pc.printf("error "); // mogelijkheid om een goto te maken naar directionchoice (opzich wel handig) }