Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Encoder HIDScope MODSERIAL mbed QEI biquadFilter
Revision 46:c88e0d2daf15, committed 2015-10-21
- Comitter:
- sigert
- Date:
- Wed Oct 21 13:15:54 2015 +0000
- Parent:
- 45:10ba78d97d75
- Child:
- 48:a0cc7ac1856f
- Child:
- 50:c4c9daf7b74c
- Commit message:
- untested: lights <-> pwm_average (EMG)
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 21 13:04:09 2015 +0000 +++ b/main.cpp Wed Oct 21 13:15:54 2015 +0000 @@ -3,6 +3,17 @@ #include "MODSERIAL.h" #include "biquadFilter.h" //Filter direct form II #include "QEI.h" +const double ledon = 1; +const double ledoff = 0; + +DigitalOut ledgreen1(D0); +DigitalOut ledgreen2(D1); +DigitalOut ledyellow1(D2); +DigitalOut ledyellow2(D3); +DigitalOut ledred1(D9); +DigitalOut ledred2(D10); + +void leduit() { ledgreen1 = ledoff; ledgreen2 = ledoff; ledyellow1 = ledoff; ledyellow2 = ledoff; ledred1 = ledoff; ledred2 = ledoff; } // [DEFINE INPUTS] // DigitalOut debug_led_red (LED_RED); // Debug LED @@ -147,12 +158,21 @@ double max_signal=(EMG_L_max); //(EMG_R_max-Threshold_Bicep_Right_1)+ pwm_strike=signal_above_threshold/max_signal; keep_in_range(&pwm_strike, 0,1); - pc.printf("Pwm=%f \n\r", pwm_strike); pwm_strike=pwm_strike*pwm_strike; pwm_average=pwm_strike+pwm_average/f; f++; smp++; + pc.printf("Pwm=%f \n\r", pwm_average); + +if (pwm_average < 0.1) { leduit(); } +if (pwm_average > 0.1) { ledgreen1 = ledon; } +if (pwm_average > 0.2) { ledgreen2 = ledon; } +if (pwm_average > 0.3) { ledyellow1 = ledon; } +if (pwm_average > 0.5) { ledyellow2 = ledon; } +if (pwm_average > 0.7) { ledred1 = ledon; } +if (pwm_average > 0.9) { ledred2 = ledon; } + if(smp>512) { pwm_motor_strike=fabs(pwm_strike);