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.
main.cpp@0:c37e4d7f1f56, 2014-10-10 (annotated)
- Committer:
- JKleinRot
- Date:
- Fri Oct 10 13:20:35 2014 +0000
- Revision:
- 0:c37e4d7f1f56
- Child:
- 1:7066a6113fbe
2014-10-10 eerste begin
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| JKleinRot | 0:c37e4d7f1f56 | 1 | #include "mbed.h" //Mbed bibliotheek inladen, standaard functies |
| JKleinRot | 0:c37e4d7f1f56 | 2 | #include "MODSERIAL.h" //MODSERIAL bibliotheek inladen, communicatie met PC |
| JKleinRot | 0:c37e4d7f1f56 | 3 | #include "encoder.h" //Encoder bibliotheek inladen, communicatie met encoder |
| JKleinRot | 0:c37e4d7f1f56 | 4 | |
| JKleinRot | 0:c37e4d7f1f56 | 5 | #define BLABLA waarde //Constanten definiëren en een waarde toekennen |
| JKleinRot | 0:c37e4d7f1f56 | 6 | |
| JKleinRot | 0:c37e4d7f1f56 | 7 | //Pinverdeling |
| JKleinRot | 0:c37e4d7f1f56 | 8 | Encoder motor_arm1( |
| JKleinRot | 0:c37e4d7f1f56 | 9 | Encoder motor_arm2( // |
| JKleinRot | 0:c37e4d7f1f56 | 10 | |
| JKleinRot | 0:c37e4d7f1f56 | 11 | PwmOut pwm_motor_arm1 |
| JKleinRot | 0:c37e4d7f1f56 | 12 | PwmOut pwm_motor_arm2 |
| JKleinRot | 0:c37e4d7f1f56 | 13 | |
| JKleinRot | 0:c37e4d7f1f56 | 14 | DigitalOut dir_motor_arm1 |
| JKleinRot | 0:c37e4d7f1f56 | 15 | DigitalOut dir_motor_arm2 |
| JKleinRot | 0:c37e4d7f1f56 | 16 | |
| JKleinRot | 0:c37e4d7f1f56 | 17 | AnalogIn emg_bi |
| JKleinRot | 0:c37e4d7f1f56 | 18 | AnalogIn emg_tri |
| JKleinRot | 0:c37e4d7f1f56 | 19 | |
| JKleinRot | 0:c37e4d7f1f56 | 20 | Ticker sample_EMG |
| JKleinRot | 0:c37e4d7f1f56 | 21 | |
| JKleinRot | 0:c37e4d7f1f56 | 22 | //Floats, bools |
| JKleinRot | 0:c37e4d7f1f56 | 23 | bool rust = false |
| JKleinRot | 0:c37e4d7f1f56 | 24 | bool kalibratie_positie = false |
| JKleinRot | 0:c37e4d7f1f56 | 25 | bool kalibratie_EMG = false |
| JKleinRot | 0:c37e4d7f1f56 | 26 | char lcd_r1 = new char[16]; //LCD regel 1, 16 karakters |
| JKleinRot | 0:c37e4d7f1f56 | 27 | char lcd_r2 = new char[16]; //LCD regel 2, 16 karakters |
| JKleinRot | 0:c37e4d7f1f56 | 28 | |
| JKleinRot | 0:c37e4d7f1f56 | 29 | //Beginwaarden voor variabelen |
| JKleinRot | 0:c37e4d7f1f56 | 30 | |
| JKleinRot | 0:c37e4d7f1f56 | 31 | int main{ |
| JKleinRot | 0:c37e4d7f1f56 | 32 | //pc baudrate |
| JKleinRot | 0:c37e4d7f1f56 | 33 | pc.baud(//opzoeken!!) |
| JKleinRot | 0:c37e4d7f1f56 | 34 | |
| JKleinRot | 0:c37e4d7f1f56 | 35 | //ticker maken die iedere zoveel seconden de EMG data inlaadt |
| JKleinRot | 0:c37e4d7f1f56 | 36 | sample_EMG.attach(setsample_EMGflag,0.005); |
| JKleinRot | 0:c37e4d7f1f56 | 37 | |
| JKleinRot | 0:c37e4d7f1f56 | 38 | while (1){ |
| JKleinRot | 0:c37e4d7f1f56 | 39 | if (rust = false && kalibratie_positie = false && kalibratie_EMG = false){ |
| JKleinRot | 0:c37e4d7f1f56 | 40 | lcd_r1 = " BMT M9 GR. 4 "; |
| JKleinRot | 0:c37e4d7f1f56 | 41 | lcd_r2 = "Hoi! Ik ben PIPO"; |
| JKleinRot | 0:c37e4d7f1f56 | 42 | wait(2); |
| JKleinRot | 0:c37e4d7f1f56 | 43 | rust = true |
| JKleinRot | 0:c37e4d7f1f56 | 44 | } |
| JKleinRot | 0:c37e4d7f1f56 | 45 | |
| JKleinRot | 0:c37e4d7f1f56 | 46 | |
| JKleinRot | 0:c37e4d7f1f56 | 47 | if (rust = true && kalibratie_positie = false && kalibratie_EMG = false){ |
| JKleinRot | 0:c37e4d7f1f56 | 48 | wait(1); |
| JKleinRot | 0:c37e4d7f1f56 | 49 | |
| JKleinRot | 0:c37e4d7f1f56 | 50 | pwm_motor_arm1 = 0.02036 |
| JKleinRot | 0:c37e4d7f1f56 | 51 | dir_motor_arm1 = // 1 of 0 |
| JKleinRot | 0:c37e4d7f1f56 | 52 | |
| JKleinRot | 0:c37e4d7f1f56 | 53 | while(motor_arm1 < 363){ |
| JKleinRot | 0:c37e4d7f1f56 | 54 | pwm_motor_arm1 = 0.02036 |
| JKleinRot | 0:c37e4d7f1f56 | 55 | } |
| JKleinRot | 0:c37e4d7f1f56 | 56 | |
| JKleinRot | 0:c37e4d7f1f56 | 57 | pwm_motor_arm1 = 0 |
| JKleinRot | 0:c37e4d7f1f56 | 58 | motor_arm1 = 0 |
| JKleinRot | 0:c37e4d7f1f56 | 59 | |
| JKleinRot | 0:c37e4d7f1f56 | 60 | pwm_motor_arm2 = 0.02398 |
| JKleinRot | 0:c37e4d7f1f56 | 61 | dir_motor_arm2 = // 1 of 0 |
| JKleinRot | 0:c37e4d7f1f56 | 62 | |
| JKleinRot | 0:c37e4d7f1f56 | 63 | while(motor_arm_2 < 787){ |
| JKleinRot | 0:c37e4d7f1f56 | 64 | pwm_motor_arm2 = 0.02398 |
| JKleinRot | 0:c37e4d7f1f56 | 65 | } |
| JKleinRot | 0:c37e4d7f1f56 | 66 | |
| JKleinRot | 0:c37e4d7f1f56 | 67 | pwm_motor_arm2 = 0 |
| JKleinRot | 0:c37e4d7f1f56 | 68 | motor_arm2 = 0 |
| JKleinRot | 0:c37e4d7f1f56 | 69 | |
| JKleinRot | 0:c37e4d7f1f56 | 70 | lcd_r1 = " Beginpositie " |
| JKleinRot | 0:c37e4d7f1f56 | 71 | lcd_r2 = " ingesteld " |
| JKleinRot | 0:c37e4d7f1f56 | 72 | wait(2); |
| JKleinRot | 0:c37e4d7f1f56 | 73 | kalibratie_positie = true |
| JKleinRot | 0:c37e4d7f1f56 | 74 | } |
| JKleinRot | 0:c37e4d7f1f56 | 75 | |
| JKleinRot | 0:c37e4d7f1f56 | 76 | if (rust = true && kalibratie_positie = true && kalibratie_EMG = false){ |
| JKleinRot | 0:c37e4d7f1f56 | 77 | wait(1); |
| JKleinRot | 0:c37e4d7f1f56 | 78 | |
| JKleinRot | 0:c37e4d7f1f56 | 79 | ybk = emg_bi.read(); |
| JKleinRot | 0:c37e4d7f1f56 | 80 | ytk = emg_tri.read(); |
| JKleinRot | 0:c37e4d7f1f56 | 81 | |
| JKleinRot | 0:c37e4d7f1f56 | 82 | //detrend |
| JKleinRot | 0:c37e4d7f1f56 | 83 | |
| JKleinRot | 0:c37e4d7f1f56 | 84 | |
| JKleinRot | 0:c37e4d7f1f56 | 85 | //hoogdoorlaatfilter |
| JKleinRot | 0:c37e4d7f1f56 | 86 | |
| JKleinRot | 0:c37e4d7f1f56 | 87 | |
| JKleinRot | 0:c37e4d7f1f56 | 88 | |
| JKleinRot | 0:c37e4d7f1f56 | 89 | |
| JKleinRot | 0:c37e4d7f1f56 | 90 |