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
Fork of another_try_from_scratch_on_emg by
main.cpp@1:30d46f7e5150, 2016-10-21 (annotated)
- Committer:
- daniQQue
- Date:
- Fri Oct 21 12:17:41 2016 +0000
- Revision:
- 1:30d46f7e5150
- Parent:
- 0:34c739fcc3e0
- Child:
- 2:025d9065b25f
nu alleen saved values;
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| daniQQue | 0:34c739fcc3e0 | 1 | //libraries | 
| daniQQue | 0:34c739fcc3e0 | 2 | #include "mbed.h" | 
| daniQQue | 0:34c739fcc3e0 | 3 | #include "HIDScope.h" | 
| daniQQue | 0:34c739fcc3e0 | 4 | #include "biquadFilter.h" | 
| daniQQue | 0:34c739fcc3e0 | 5 | |
| daniQQue | 0:34c739fcc3e0 | 6 | //Define objects | 
| daniQQue | 0:34c739fcc3e0 | 7 | AnalogIn emg0( A0 ); //analog in to get EMG in to c++ | 
| daniQQue | 0:34c739fcc3e0 | 8 | Ticker sample_timer; //ticker | 
| daniQQue | 0:34c739fcc3e0 | 9 | HIDScope scope( 2); //open 3 channels in hidscope | 
| daniQQue | 0:34c739fcc3e0 | 10 | DigitalOut led(LED_GREEN); | 
| daniQQue | 0:34c739fcc3e0 | 11 | |
| daniQQue | 0:34c739fcc3e0 | 12 | //define variables | 
| daniQQue | 0:34c739fcc3e0 | 13 | double emg_0_value; | 
| daniQQue | 0:34c739fcc3e0 | 14 | |
| daniQQue | 0:34c739fcc3e0 | 15 | |
| daniQQue | 0:34c739fcc3e0 | 16 | void filter(){ | 
| daniQQue | 0:34c739fcc3e0 | 17 | emg_0_value=emg0.read(); //read the emg value from the elektrodes | 
| daniQQue | 0:34c739fcc3e0 | 18 | led=!led; | 
| daniQQue | 0:34c739fcc3e0 | 19 | |
| daniQQue | 0:34c739fcc3e0 | 20 | //send signals to scope | 
| daniQQue | 1:30d46f7e5150 | 21 | scope.set(0, emg_0_value ); //set emg signal to scope in channel 1 | 
| daniQQue | 0:34c739fcc3e0 | 22 | scope.set(1, emg_0_value ); | 
| daniQQue | 0:34c739fcc3e0 | 23 | scope.send(); //send all the signals to the scope | 
| daniQQue | 0:34c739fcc3e0 | 24 | } | 
| daniQQue | 0:34c739fcc3e0 | 25 | |
| daniQQue | 0:34c739fcc3e0 | 26 | //program | 
| daniQQue | 0:34c739fcc3e0 | 27 | |
| daniQQue | 0:34c739fcc3e0 | 28 | int main() | 
| daniQQue | 0:34c739fcc3e0 | 29 | { | 
| daniQQue | 0:34c739fcc3e0 | 30 | sample_timer.attach(&filter, 0.001); //continously execute the EMG reader and filter, it ensures that filter and sampling is executed every 1/frequency seconds | 
| daniQQue | 0:34c739fcc3e0 | 31 | |
| daniQQue | 0:34c739fcc3e0 | 32 | //endless loop | 
| daniQQue | 0:34c739fcc3e0 | 33 | |
| daniQQue | 0:34c739fcc3e0 | 34 | while(1) | 
| daniQQue | 0:34c739fcc3e0 | 35 | {} | 
| daniQQue | 0:34c739fcc3e0 | 36 | |
| daniQQue | 0:34c739fcc3e0 | 37 | } | 
