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 MODSERIAL QEI biquadFilter mbed Servo
help_functions/processing_chain_emg.h@46:9b60a3c1acab, 2018-11-01 (annotated)
- Committer:
- Spekdon
- Date:
- Thu Nov 01 20:54:51 2018 +0000
- Revision:
- 46:9b60a3c1acab
- Parent:
- 41:e9d6fdf02074
Presentation code
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MaikOvermars | 17:1f93c83e211f | 1 | #include "mbed.h" |
| MaikOvermars | 17:1f93c83e211f | 2 | #include "BiQuad.h" |
| MaikOvermars | 17:1f93c83e211f | 3 | |
| MaikOvermars | 17:1f93c83e211f | 4 | //Define objects |
| MaikOvermars | 17:1f93c83e211f | 5 | |
| MaikOvermars | 17:1f93c83e211f | 6 | // filter chains for high pass, low pass and notch filters |
| MaikOvermars | 25:734a26538711 | 7 | BiQuadChain bqc0; |
| MaikOvermars | 25:734a26538711 | 8 | BiQuadChain bqc1; |
| MaikOvermars | 41:e9d6fdf02074 | 9 | BiQuadChain bqc2; |
| MaikOvermars | 41:e9d6fdf02074 | 10 | BiQuadChain bqc3; |
| MaikOvermars | 17:1f93c83e211f | 11 | |
| MaikOvermars | 41:e9d6fdf02074 | 12 | // Filters for sampling frequency 1000 Hz |
| MaikOvermars | 25:734a26538711 | 13 | |
| MaikOvermars | 41:e9d6fdf02074 | 14 | // emg signal 0 filters |
| MaikOvermars | 41:e9d6fdf02074 | 15 | //BiQuad bq0low( 0.3913/10000.0, 0.7826/10000.0, 0.3913/10000.0, -1.9822, 0.9824); // 2 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 16 | BiQuad bq0low( 0.0877/1000.0, 0.1753/1000.0, 0.0877/1000.0, -1.9733, 0.9737); // 3 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 17 | //BiQuad bq0low( 0.3460/1000.0, 0.6921/1000.0, 0.3460/1000.0, -1.9467, 0.9481); // 6 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 18 | BiQuad bq0high( 0.9150, -1.8299, 0.9150, -1.8227, 0.8372); //cutoff at 20 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 19 | BiQuad bq0notch( 0.9695, -1.8442, 0.9695, -1.8442, 0.9391); //notch 50 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 20 | BiQuad bq0notch2( 0.9695, -1.5687, 0.9695, -1.5687, 0.9391);//notch 100 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 21 | BiQuad bq0notch3( 0.9695, -1.1398, 0.9695, -1.1398, 0.9391);//notch 150 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 22 | BiQuad bq0notch4( 0.9695, -0.5992, 0.9695, -0.5992, 0.9391);//notch 200 Hz |
| MaikOvermars | 17:1f93c83e211f | 23 | |
| MaikOvermars | 41:e9d6fdf02074 | 24 | // emg signal 1 filters |
| MaikOvermars | 41:e9d6fdf02074 | 25 | //BiQuad bq1low( 0.3913/10000.0, 0.7826/10000.0, 0.3913/10000.0, -1.9822, 0.9824); // 2 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 26 | BiQuad bq1low( 0.0877/1000.0, 0.1753/1000.0, 0.0877/1000.0, -1.9733, 0.9737); // 3 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 27 | //BiQuad bq1low( 0.3460/1000.0, 0.6921/1000.0, 0.3460/1000.0, -1.9467, 0.9481); // 6 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 28 | BiQuad bq1high( 0.9150, -1.8299, 0.9150, -1.8227, 0.8372); //cutoff at 20 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 29 | BiQuad bq1notch( 0.9695, -1.8442, 0.9695, -1.8442, 0.9391); //notch 50 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 30 | BiQuad bq1notch2( 0.9695, -1.5687, 0.9695, -1.5687, 0.9391);//notch 100 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 31 | BiQuad bq1notch3( 0.9695, -1.1398, 0.9695, -1.1398, 0.9391);//notch 150 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 32 | BiQuad bq1notch4( 0.9695, -0.5992, 0.9695, -0.5992, 0.9391);//notch 200 Hz |
| MaikOvermars | 17:1f93c83e211f | 33 | |
| MaikOvermars | 41:e9d6fdf02074 | 34 | // emg signal 2 filters |
| MaikOvermars | 41:e9d6fdf02074 | 35 | //BiQuad bq2low( 0.3913/10000.0, 0.7826/10000.0, 0.3913/10000.0, -1.9822, 0.9824); // 2 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 36 | BiQuad bq2low( 0.0877/1000.0, 0.1753/1000.0, 0.0877/1000.0, -1.9733, 0.9737); // 3 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 37 | //BiQuad bq2low( 0.3460/1000.0, 0.6921/1000.0, 0.3460/1000.0, -1.9467, 0.9481); // 6 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 38 | BiQuad bq2high( 0.9150, -1.8299, 0.9150, -1.8227, 0.8372); //cutoff at 20 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 39 | BiQuad bq2notch( 0.9695, -1.8442, 0.9695, -1.8442, 0.9391); //notch 50 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 40 | BiQuad bq2notch2( 0.9695, -1.5687, 0.9695, -1.5687, 0.9391);//notch 100 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 41 | BiQuad bq2notch3( 0.9695, -1.1398, 0.9695, -1.1398, 0.9391);//notch 150 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 42 | BiQuad bq2notch4( 0.9695, -0.5992, 0.9695, -0.5992, 0.9391);//notch 200 Hz |
| MaikOvermars | 17:1f93c83e211f | 43 | |
| MaikOvermars | 41:e9d6fdf02074 | 44 | // emg signal 3 filters |
| MaikOvermars | 41:e9d6fdf02074 | 45 | //BiQuad bq3low( 0.3913/10000.0, 0.7826/10000.0, 0.3913/10000.0, -1.9822, 0.9824); // 2 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 46 | BiQuad bq3low( 0.0877/1000.0, 0.1753/1000.0, 0.0877/1000.0, -1.9733, 0.9737); // 3 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 47 | //BiQuad bq3low( 0.3460/1000.0, 0.6921/1000.0, 0.3460/1000.0, -1.9467, 0.9481); // 6 Hz cutoff |
| MaikOvermars | 41:e9d6fdf02074 | 48 | BiQuad bq3high( 0.9150, -1.8299, 0.9150, -1.8227, 0.8372); //cutoff at 20 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 49 | BiQuad bq3notch( 0.9695, -1.8442, 0.9695, -1.8442, 0.9391); //notch 50 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 50 | BiQuad bq3notch2( 0.9695, -1.5687, 0.9695, -1.5687, 0.9391);//notch 100 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 51 | BiQuad bq3notch3( 0.9695, -1.1398, 0.9695, -1.1398, 0.9391);//notch 150 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 52 | BiQuad bq3notch4( 0.9695, -0.5992, 0.9695, -0.5992, 0.9391);//notch 200 Hz |
| MaikOvermars | 41:e9d6fdf02074 | 53 | |
| MaikOvermars | 41:e9d6fdf02074 | 54 | |
| MaikOvermars | 41:e9d6fdf02074 | 55 | void processing_chain_emg(double &raw_emg_0, double &raw_emg_1, double &raw_emg_2, double &raw_emg_3, double &process_emg_0, double &process_emg_1, double &process_emg_2, double &process_emg_3) { |
| MaikOvermars | 17:1f93c83e211f | 56 | |
| MaikOvermars | 17:1f93c83e211f | 57 | // we first filter high pass and notch, then rectifier and after that low pass |
| MaikOvermars | 41:e9d6fdf02074 | 58 | process_emg_0 = bq0low.step(fabs(bqc0.step( raw_emg_0 ))); |
| MaikOvermars | 41:e9d6fdf02074 | 59 | process_emg_1 = bq1low.step(fabs(bqc1.step( raw_emg_1 ))); |
| MaikOvermars | 41:e9d6fdf02074 | 60 | process_emg_2 = bq2low.step(fabs(bqc2.step( raw_emg_2 ))); |
| MaikOvermars | 41:e9d6fdf02074 | 61 | process_emg_3 = bq3low.step(fabs(bqc3.step( raw_emg_3 ))); |
| MaikOvermars | 17:1f93c83e211f | 62 | |
| MaikOvermars | 17:1f93c83e211f | 63 | } |
| MaikOvermars | 17:1f93c83e211f | 64 |