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: HIDScope mbed MODSERIAL QEI
main.cpp@6:452e301a105a, 2017-10-16 (annotated)
- Committer:
- Alex_Kyrl
- Date:
- Mon Oct 16 13:07:53 2017 +0000
- Revision:
- 6:452e301a105a
- Parent:
- 5:4c27dea81e4c
- Child:
- 7:c17f5473f4e1
using class for emg and added motor class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Alex_Kyrl | 6:452e301a105a | 1 | #include "EMG.h" |
Alex_Kyrl | 6:452e301a105a | 2 | #include "Motor.h" |
poephoofd | 0:2d9dae739559 | 3 | #include "HIDScope.h" |
poephoofd | 2:a08bff88216d | 4 | #include "MODSERIAL.h" |
poephoofd | 0:2d9dae739559 | 5 | |
poephoofd | 0:2d9dae739559 | 6 | //Initialize Analog EMG inputs |
Alex_Kyrl | 6:452e301a105a | 7 | EMG EMG_bi_r(A0); |
Alex_Kyrl | 6:452e301a105a | 8 | EMG EMG_bi_l(A1); |
Alex_Kyrl | 6:452e301a105a | 9 | EMG EMG_tri_r(A2); |
Alex_Kyrl | 6:452e301a105a | 10 | EMG EMG_tri_l(A3); |
poephoofd | 0:2d9dae739559 | 11 | |
Alex_Kyrl | 6:452e301a105a | 12 | |
Alex_Kyrl | 6:452e301a105a | 13 | |
Alex_Kyrl | 6:452e301a105a | 14 | HIDScope scope(1); // 4 channels of data |
poephoofd | 0:2d9dae739559 | 15 | Ticker MainTicker; |
poephoofd | 0:2d9dae739559 | 16 | MODSERIAL pc(USBTX, USBRX); |
poephoofd | 0:2d9dae739559 | 17 | |
Alex_Kyrl | 6:452e301a105a | 18 | const double sample_time= 0.002; //fs = 500Hz |
poephoofd | 3:9c5aea210f1d | 19 | |
poephoofd | 0:2d9dae739559 | 20 | |
poephoofd | 0:2d9dae739559 | 21 | |
poephoofd | 0:2d9dae739559 | 22 | void ReadAndFilterEMG() |
poephoofd | 0:2d9dae739559 | 23 | { |
poephoofd | 0:2d9dae739559 | 24 | |
poephoofd | 0:2d9dae739559 | 25 | |
poephoofd | 0:2d9dae739559 | 26 | //Send scope data |
Alex_Kyrl | 6:452e301a105a | 27 | scope.set(0, EMG_bi_r.filter()); //Raw Data |
Alex_Kyrl | 6:452e301a105a | 28 | //scope.set(1, EMG_Filtered_1); //Notch and High Pass Filtered |
Alex_Kyrl | 6:452e301a105a | 29 | //scope.set(2, EMG_Abs_1); //Absolute value |
Alex_Kyrl | 6:452e301a105a | 30 | //scope.set(3, EMG_Envelope_1); //Envelope Detected output |
poephoofd | 0:2d9dae739559 | 31 | |
poephoofd | 0:2d9dae739559 | 32 | scope.send(); |
poephoofd | 2:a08bff88216d | 33 | /*****/ |
poephoofd | 2:a08bff88216d | 34 | } |
poephoofd | 2:a08bff88216d | 35 | |
poephoofd | 2:a08bff88216d | 36 | int main(void) |
poephoofd | 2:a08bff88216d | 37 | { |
poephoofd | 2:a08bff88216d | 38 | pc.baud(115200); //Set Baud rate for Serial communication |
Alex_Kyrl | 6:452e301a105a | 39 | MainTicker.attach(&ReadAndFilterEMG, sample_time); //Attach time based interrupt |
poephoofd | 0:2d9dae739559 | 40 | |
poephoofd | 2:a08bff88216d | 41 | /* |
poephoofd | 2:a08bff88216d | 42 | while(true) |
poephoofd | 2:a08bff88216d | 43 | { |
poephoofd | 2:a08bff88216d | 44 | |
poephoofd | 2:a08bff88216d | 45 | } |
poephoofd | 2:a08bff88216d | 46 | */ |
poephoofd | 2:a08bff88216d | 47 | |
poephoofd | 2:a08bff88216d | 48 | return 0; |
poephoofd | 0:2d9dae739559 | 49 | } |