Fährt 4*2 Kurven und stoppt dann
Dependencies: mbed
Fork of _B16_T3_Motor by
main.cpp@4:2bf2ab6a1163, 2016-05-13 (annotated)
- Committer:
- PatrickMarterer
- Date:
- Fri May 13 13:17:34 2016 +0000
- Revision:
- 4:2bf2ab6a1163
- Parent:
- 3:acd2b6fdcd7f
Bertl f?hrt 4*2 Kurven und bleibt dann stehen + LED's aus
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Enenkel | 0:a8a0195ed7dc | 1 | /*********************************** |
Enenkel | 3:acd2b6fdcd7f | 2 | name: BERTL_16_MOTOR_TEST 8.1.2016 |
Enenkel | 1:0f7c167a4f97 | 3 | author: Gottfried Enenkel HTL BULME |
Enenkel | 1:0f7c167a4f97 | 4 | email: ene@bulme.at |
Enenkel | 0:a8a0195ed7dc | 5 | description: |
PatrickMarterer | 4:2bf2ab6a1163 | 6 | Der BERTL fährt 1 sec lang VORWÄRTS! |
Enenkel | 1:0f7c167a4f97 | 7 | Danach steht er für 1 sec |
PatrickMarterer | 4:2bf2ab6a1163 | 8 | |
PatrickMarterer | 4:2bf2ab6a1163 | 9 | Wenn der Motor richtig eingebaut ist, |
Enenkel | 1:0f7c167a4f97 | 10 | steht über dem Linken Anschluß ein PLUS |
PatrickMarterer | 4:2bf2ab6a1163 | 11 | Wenn sich der BERTL dreht, ist ein Motor verkehrt eingebaut. |
PatrickMarterer | 4:2bf2ab6a1163 | 12 | |
Enenkel | 1:0f7c167a4f97 | 13 | ***********************************/ |
Enenkel | 1:0f7c167a4f97 | 14 | #include "mbed.h" |
Enenkel | 1:0f7c167a4f97 | 15 | |
Enenkel | 1:0f7c167a4f97 | 16 | // ************ DEKLARATIONEN ************** |
Enenkel | 3:acd2b6fdcd7f | 17 | DigitalOut Von (P2_13); // Motor Spannung ab BERTL15 nötig ! |
PatrickMarterer | 4:2bf2ab6a1163 | 18 | DigitalOut MotorL_EN(P1_19); // Enable OB DIE LINKS ODER RECHTS IST NOCH NICHT KLAR ! |
PatrickMarterer | 4:2bf2ab6a1163 | 19 | DigitalOut MotorL_FORWARD(P2_15); // Forwerts |
PatrickMarterer | 4:2bf2ab6a1163 | 20 | DigitalOut MotorL_REVERSE(P2_14); // Rückwerts |
Enenkel | 1:0f7c167a4f97 | 21 | |
Enenkel | 3:acd2b6fdcd7f | 22 | DigitalOut MotorR_EN(P2_19); //Die Leitung führt zum Pin PO_21 am Prozessor |
PatrickMarterer | 4:2bf2ab6a1163 | 23 | DigitalOut MotorR_FORWARD(P2_20); //Die Leitung führt zum Pin P1_3 am Prozessor |
PatrickMarterer | 4:2bf2ab6a1163 | 24 | DigitalOut MotorR_REVERSE(P2_21); |
PatrickMarterer | 4:2bf2ab6a1163 | 25 | |
Enenkel | 0:a8a0195ed7dc | 26 | |
Enenkel | 1:0f7c167a4f97 | 27 | // ************* Hauptprogramm ************ |
PatrickMarterer | 4:2bf2ab6a1163 | 28 | int main() |
PatrickMarterer | 4:2bf2ab6a1163 | 29 | { |
PatrickMarterer | 4:2bf2ab6a1163 | 30 | DigitalOut LED1 (P1_10); |
PatrickMarterer | 4:2bf2ab6a1163 | 31 | DigitalOut LED2 (P1_11); |
PatrickMarterer | 4:2bf2ab6a1163 | 32 | DigitalOut LED3 (P1_12); |
PatrickMarterer | 4:2bf2ab6a1163 | 33 | DigitalOut LED4 (P1_12); |
PatrickMarterer | 4:2bf2ab6a1163 | 34 | DigitalOut LED5 (P1_13); |
PatrickMarterer | 4:2bf2ab6a1163 | 35 | DigitalOut LED6 (P1_14); |
PatrickMarterer | 4:2bf2ab6a1163 | 36 | DigitalOut LED7 (P1_15); |
PatrickMarterer | 4:2bf2ab6a1163 | 37 | DigitalOut LED8 (P1_16); |
PatrickMarterer | 4:2bf2ab6a1163 | 38 | DigitalOut LED9 (P1_17); |
PatrickMarterer | 4:2bf2ab6a1163 | 39 | DigitalOut LED10 (P1_18); |
PatrickMarterer | 4:2bf2ab6a1163 | 40 | DigitalOut LED11 (P2_16); |
PatrickMarterer | 4:2bf2ab6a1163 | 41 | DigitalOut LED12 (P1_20); |
PatrickMarterer | 4:2bf2ab6a1163 | 42 | DigitalOut LED13 (P1_21); |
PatrickMarterer | 4:2bf2ab6a1163 | 43 | DigitalOut LED20 (P1_5); |
PatrickMarterer | 4:2bf2ab6a1163 | 44 | DigitalOut LED24 (P1_5); |
PatrickMarterer | 4:2bf2ab6a1163 | 45 | DigitalOut LED25 (P1_6); |
PatrickMarterer | 4:2bf2ab6a1163 | 46 | DigitalOut TA1 (P1_23); |
PatrickMarterer | 4:2bf2ab6a1163 | 47 | Von=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 48 | MotorR_EN=MotorL_EN=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 49 | int a; |
PatrickMarterer | 4:2bf2ab6a1163 | 50 | a=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 51 | while(a<4) { |
PatrickMarterer | 4:2bf2ab6a1163 | 52 | |
PatrickMarterer | 4:2bf2ab6a1163 | 53 | |
PatrickMarterer | 4:2bf2ab6a1163 | 54 | |
PatrickMarterer | 4:2bf2ab6a1163 | 55 | |
PatrickMarterer | 4:2bf2ab6a1163 | 56 | int b; |
PatrickMarterer | 4:2bf2ab6a1163 | 57 | //int c; |
PatrickMarterer | 4:2bf2ab6a1163 | 58 | int d; |
PatrickMarterer | 4:2bf2ab6a1163 | 59 | |
PatrickMarterer | 4:2bf2ab6a1163 | 60 | LED1=LED2=LED4=LED5=LED6=LED7=LED8=LED9=LED10=LED11=LED12=LED13=LED20=LED24=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 61 | LED1=LED4=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 62 | LED20=LED24=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 63 | MotorL_FORWARD = 1; |
PatrickMarterer | 4:2bf2ab6a1163 | 64 | MotorR_FORWARD = 1; |
PatrickMarterer | 4:2bf2ab6a1163 | 65 | |
PatrickMarterer | 4:2bf2ab6a1163 | 66 | wait (7.0); |
PatrickMarterer | 4:2bf2ab6a1163 | 67 | |
PatrickMarterer | 4:2bf2ab6a1163 | 68 | MotorL_FORWARD = 0; |
PatrickMarterer | 4:2bf2ab6a1163 | 69 | MotorR_FORWARD = 0; |
Enenkel | 1:0f7c167a4f97 | 70 | |
PatrickMarterer | 4:2bf2ab6a1163 | 71 | LED1=LED4=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 72 | LED7=LED9=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 73 | b=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 74 | while (b<2) { |
PatrickMarterer | 4:2bf2ab6a1163 | 75 | LED8=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 76 | LED5=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 77 | wait (0.5); |
PatrickMarterer | 4:2bf2ab6a1163 | 78 | LED5=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 79 | LED8=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 80 | wait (0.5); |
PatrickMarterer | 4:2bf2ab6a1163 | 81 | b=b++; |
PatrickMarterer | 4:2bf2ab6a1163 | 82 | } |
PatrickMarterer | 4:2bf2ab6a1163 | 83 | |
PatrickMarterer | 4:2bf2ab6a1163 | 84 | |
PatrickMarterer | 4:2bf2ab6a1163 | 85 | |
PatrickMarterer | 4:2bf2ab6a1163 | 86 | MotorL_FORWARD =1; |
PatrickMarterer | 4:2bf2ab6a1163 | 87 | MotorR_REVERSE =1; |
PatrickMarterer | 4:2bf2ab6a1163 | 88 | wait (0.25); |
PatrickMarterer | 4:2bf2ab6a1163 | 89 | MotorL_FORWARD = 0; |
PatrickMarterer | 4:2bf2ab6a1163 | 90 | MotorR_REVERSE = 0; |
PatrickMarterer | 4:2bf2ab6a1163 | 91 | wait (2.0); |
PatrickMarterer | 4:2bf2ab6a1163 | 92 | LED7=LED9= 1; |
PatrickMarterer | 4:2bf2ab6a1163 | 93 | |
PatrickMarterer | 4:2bf2ab6a1163 | 94 | LED1=LED4=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 95 | MotorL_FORWARD=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 96 | MotorR_FORWARD=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 97 | wait (4.0); |
PatrickMarterer | 4:2bf2ab6a1163 | 98 | MotorL_FORWARD=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 99 | MotorR_FORWARD=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 100 | wait (0.0); |
PatrickMarterer | 4:2bf2ab6a1163 | 101 | LED1=LED4=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 102 | |
PatrickMarterer | 4:2bf2ab6a1163 | 103 | LED7=LED9=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 104 | |
PatrickMarterer | 4:2bf2ab6a1163 | 105 | d=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 106 | while(d<2) { |
PatrickMarterer | 4:2bf2ab6a1163 | 107 | LED8=LED5=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 108 | wait (0.5); |
PatrickMarterer | 4:2bf2ab6a1163 | 109 | LED8=LED5=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 110 | wait (0.5); |
PatrickMarterer | 4:2bf2ab6a1163 | 111 | d=d++; |
PatrickMarterer | 4:2bf2ab6a1163 | 112 | } |
PatrickMarterer | 4:2bf2ab6a1163 | 113 | MotorL_FORWARD=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 114 | MotorR_REVERSE=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 115 | wait (0.25); |
PatrickMarterer | 4:2bf2ab6a1163 | 116 | MotorL_FORWARD=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 117 | MotorR_REVERSE=0; |
PatrickMarterer | 4:2bf2ab6a1163 | 118 | wait (0.5); |
PatrickMarterer | 4:2bf2ab6a1163 | 119 | LED7=LED9=1; |
PatrickMarterer | 4:2bf2ab6a1163 | 120 | LED1=LED4=LED20=LED24=0; |
Enenkel | 1:0f7c167a4f97 | 121 | |
Enenkel | 1:0f7c167a4f97 | 122 | |
Enenkel | 1:0f7c167a4f97 | 123 | |
Enenkel | 1:0f7c167a4f97 | 124 | |
PatrickMarterer | 4:2bf2ab6a1163 | 125 | a=a++; |
Enenkel | 1:0f7c167a4f97 | 126 | |
PatrickMarterer | 4:2bf2ab6a1163 | 127 | } |
PatrickMarterer | 4:2bf2ab6a1163 | 128 | } |
PatrickMarterer | 4:2bf2ab6a1163 | 129 | // ************** ENDE ************* |
Enenkel | 1:0f7c167a4f97 | 130 |