![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Overzetten
Dependencies: HIDScope MODSERIAL mbed
Diff: main.cpp
- Revision:
- 6:bbef54156775
- Parent:
- 5:0ae4951e9b81
- Child:
- 7:d57eba2aed38
--- a/main.cpp Mon Oct 08 08:25:44 2018 +0000 +++ b/main.cpp Mon Oct 08 10:48:52 2018 +0000 @@ -11,6 +11,23 @@ DigitalIn Knop2(D2); DigitalIn Knop3(PTA4); DigitalIn Knop4(PTC6); +AnalogIn emg0( A0 ); +AnalogIn emg1( A1 ); + +Ticker sample_timer; +HIDScope scope( 2 ); +DigitalOut led(LED1); + + +void sample() +{ + + scope.set(0, emg0.read() ); + scope.set(1, emg1.read() ); + + scope.send(); + led = !led; +} int Turn_Motor1() { @@ -19,14 +36,6 @@ PwmPin1 = fabs(0.0); } - else if (Knop3==false)// We see that Motor2 keeps rotating if we leave out the "else" statement, somehow the signal leaks - { - float u = 0.8f; - DirectionPin1 = u < 0.0f; - PwmPin1 = fabs(u); - PwmPin2 = fabs(0.0); - } - else if (Knop1==false) // Motor 1 rotates CW { float u = 0.8f; //determine useful value, this is not final @@ -36,6 +45,23 @@ PwmPin2 = fabs(0.0); } + else if (Knop3==false)// We see that Motor2 keeps rotating if we leave out the "else" statement, somehow the signal leaks + { + float u = 0.8f; + DirectionPin1 = u < 0.0f; + PwmPin1 = fabs(u); + PwmPin2 = fabs(0.0); + } + /* + else if (Biceps_Rechts > ) + { + float u = 0.8f; //determine useful value, this is not final + DirectionPin1 = u > 0.0f; //either true or false + // True = CW, for False = CW + PwmPin1 = fabs(u); + PwmPin2 = fabs(0.0); + } + */ else { float u = 0.0f; @@ -51,6 +77,14 @@ PwmPin2 = fabs(0.0); } + else if (Knop2==false) + { + float u = 0.8f; + DirectionPin2 = u < 0.0f; + PwmPin1 = fabs(0.0); + PwmPin2 = fabs(u); + } + else if (Knop4==false) { float u = 0.8f; @@ -60,14 +94,6 @@ } - else if (Knop2==false) - { - float u = 0.8f; - DirectionPin2 = u < 0.0f; - PwmPin1 = fabs(0.0); - PwmPin2 = fabs(u); - } - else { float u = 0.0f; @@ -76,31 +102,21 @@ return 0; } -//Define objects -AnalogIn emg0( A0 ); -AnalogIn emg1( A1 ); - -Ticker sample_timer; -HIDScope scope( 2 ); -DigitalOut led(LED1); - -void sample() -{ - - scope.set(0, emg0.read() ); - scope.set(1, emg1.read() ); - - scope.send(); - led = !led; -} - int main() { pc.baud(115200); sample_timer.attach(&sample, 0.002); PwmPin1.period_us(120); //60 microseconds pwm period, 16.7 kHz - + /* + for(;;) + { + double Biceps_Rechts = emg1.read(); + double Biceps_1 = emg0.read(); + pc.printf("%d en %d ", Biceps_Rechts, Biceps_1); + wait(0.8); + } + */ for(;;) { Turn_Motor1();