pot controller voor positie, kp handmatig instellen, werkt met motor 1 en 2
Dependencies: MODSERIAL QEI mbed-dsp mbed
Fork of PI_controller_verbeteringen by
main.cpp@2:52b3c0b95388, 2018-09-12 (annotated)
- Committer:
- SimonRez
- Date:
- Wed Sep 12 10:27:38 2018 +0000
- Revision:
- 2:52b3c0b95388
- Parent:
- 1:40470bc517f1
- Child:
- 3:40a25c2c24ba
Kleuren veranderen en juiste interval. Melding als verkeerd karakter is ingevoerd;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsluiter | 0:c8f15874531b | 1 | #include "mbed.h" |
vsluiter | 0:c8f15874531b | 2 | #include "MODSERIAL.h" |
vsluiter | 0:c8f15874531b | 3 | |
SimonRez | 2:52b3c0b95388 | 4 | Ticker Blinker; |
SimonRez | 2:52b3c0b95388 | 5 | |
SimonRez | 2:52b3c0b95388 | 6 | DigitalOut ledr(LED_RED); |
SimonRez | 2:52b3c0b95388 | 7 | DigitalOut ledg(LED_GREEN); |
SimonRez | 2:52b3c0b95388 | 8 | DigitalOut ledb(LED_BLUE); |
SimonRez | 2:52b3c0b95388 | 9 | DigitalIn sw2(PTC6); |
SimonRez | 2:52b3c0b95388 | 10 | |
vsluiter | 0:c8f15874531b | 11 | MODSERIAL pc(USBTX, USBRX); |
vsluiter | 0:c8f15874531b | 12 | |
SimonRez | 2:52b3c0b95388 | 13 | volatile char c; |
SimonRez | 2:52b3c0b95388 | 14 | volatile char color; |
SimonRez | 2:52b3c0b95388 | 15 | |
SimonRez | 2:52b3c0b95388 | 16 | void ButtonpressCheck() |
SimonRez | 2:52b3c0b95388 | 17 | { |
SimonRez | 2:52b3c0b95388 | 18 | if (c == 'r') |
SimonRez | 2:52b3c0b95388 | 19 | { |
SimonRez | 2:52b3c0b95388 | 20 | color = 'r'; |
SimonRez | 2:52b3c0b95388 | 21 | } |
SimonRez | 2:52b3c0b95388 | 22 | else if (c == 'g') |
SimonRez | 2:52b3c0b95388 | 23 | { |
SimonRez | 2:52b3c0b95388 | 24 | color = 'g'; |
SimonRez | 2:52b3c0b95388 | 25 | } |
SimonRez | 2:52b3c0b95388 | 26 | else if (c == 'b') |
SimonRez | 2:52b3c0b95388 | 27 | { |
SimonRez | 2:52b3c0b95388 | 28 | color = 'b'; |
SimonRez | 2:52b3c0b95388 | 29 | } |
SimonRez | 2:52b3c0b95388 | 30 | else |
SimonRez | 2:52b3c0b95388 | 31 | { |
SimonRez | 2:52b3c0b95388 | 32 | pc.printf("Character %c is not valid \r\n",c); |
SimonRez | 2:52b3c0b95388 | 33 | c = color; |
SimonRez | 2:52b3c0b95388 | 34 | } |
SimonRez | 2:52b3c0b95388 | 35 | |
SimonRez | 2:52b3c0b95388 | 36 | if (color == 'r') |
SimonRez | 2:52b3c0b95388 | 37 | { |
SimonRez | 2:52b3c0b95388 | 38 | ledr = !ledr; |
SimonRez | 2:52b3c0b95388 | 39 | ledg = 1; |
SimonRez | 2:52b3c0b95388 | 40 | ledb = 1; |
SimonRez | 2:52b3c0b95388 | 41 | } |
SimonRez | 2:52b3c0b95388 | 42 | else if (color == 'g') |
SimonRez | 2:52b3c0b95388 | 43 | { |
SimonRez | 2:52b3c0b95388 | 44 | ledr = 1; |
SimonRez | 2:52b3c0b95388 | 45 | ledg = !ledg; |
SimonRez | 2:52b3c0b95388 | 46 | ledb = 1; |
SimonRez | 2:52b3c0b95388 | 47 | } |
SimonRez | 2:52b3c0b95388 | 48 | else if (color == 'b') |
SimonRez | 2:52b3c0b95388 | 49 | { |
SimonRez | 2:52b3c0b95388 | 50 | ledr = 1; |
SimonRez | 2:52b3c0b95388 | 51 | ledg = 1; |
SimonRez | 2:52b3c0b95388 | 52 | ledb = !ledb; |
SimonRez | 2:52b3c0b95388 | 53 | } |
SimonRez | 2:52b3c0b95388 | 54 | wait(0.25f); |
SimonRez | 2:52b3c0b95388 | 55 | ledr = 1; |
SimonRez | 2:52b3c0b95388 | 56 | ledg = 1; |
SimonRez | 2:52b3c0b95388 | 57 | ledb = 1; |
SimonRez | 2:52b3c0b95388 | 58 | |
SimonRez | 2:52b3c0b95388 | 59 | } |
SimonRez | 2:52b3c0b95388 | 60 | |
vsluiter | 0:c8f15874531b | 61 | int main() |
vsluiter | 0:c8f15874531b | 62 | { |
SimonRez | 2:52b3c0b95388 | 63 | ledr = 1; |
SimonRez | 2:52b3c0b95388 | 64 | ledg = 1; |
SimonRez | 2:52b3c0b95388 | 65 | ledb = 1; |
SimonRez | 2:52b3c0b95388 | 66 | |
SimonRez | 2:52b3c0b95388 | 67 | pc.printf("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ~~~Pu$$Y~~~ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"); |
SimonRez | 2:52b3c0b95388 | 68 | |
vsluiter | 0:c8f15874531b | 69 | pc.baud(115200); |
SimonRez | 2:52b3c0b95388 | 70 | Blinker.attach(ButtonpressCheck, 0.5); |
SimonRez | 2:52b3c0b95388 | 71 | |
vsluiter | 0:c8f15874531b | 72 | |
SimonRez | 2:52b3c0b95388 | 73 | |
SimonRez | 2:52b3c0b95388 | 74 | while (true) |
SimonRez | 2:52b3c0b95388 | 75 | { |
SimonRez | 2:52b3c0b95388 | 76 | c = pc.getc(); |
vsluiter | 0:c8f15874531b | 77 | } |
SimonRez | 2:52b3c0b95388 | 78 | |
vsluiter | 0:c8f15874531b | 79 | } |
SimonRez | 2:52b3c0b95388 | 80 | |
SimonRez | 2:52b3c0b95388 | 81 |