PI controller met potmeters om de Kp en Ki in te stellen
Dependencies: MODSERIAL QEI mbed-dsp mbed
Fork of Motorcode by
main.cpp@5:f07bafaf11d7, 2018-09-24 (annotated)
- Committer:
- SimonRez
- Date:
- Mon Sep 24 14:15:12 2018 +0000
- Revision:
- 5:f07bafaf11d7
- Parent:
- 4:651d06e860e7
- Child:
- 6:1ee8795b7578
Motor met analog input
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 | 4:651d06e860e7 | 9 | |
SimonRez | 5:f07bafaf11d7 | 10 | PwmOut pwmpin(PTA2); |
SimonRez | 5:f07bafaf11d7 | 11 | DigitalOut direct(PTB23); |
SimonRez | 5:f07bafaf11d7 | 12 | AnalogIn enc1(A0); |
SimonRez | 5:f07bafaf11d7 | 13 | |
SimonRez | 4:651d06e860e7 | 14 | InterruptIn sw2(SW2); |
SimonRez | 4:651d06e860e7 | 15 | InterruptIn sw3(SW3); |
SimonRez | 2:52b3c0b95388 | 16 | |
vsluiter | 0:c8f15874531b | 17 | MODSERIAL pc(USBTX, USBRX); |
vsluiter | 0:c8f15874531b | 18 | |
SimonRez | 4:651d06e860e7 | 19 | |
vsluiter | 0:c8f15874531b | 20 | int main() |
vsluiter | 0:c8f15874531b | 21 | { |
SimonRez | 2:52b3c0b95388 | 22 | ledr = 1; |
SimonRez | 2:52b3c0b95388 | 23 | ledg = 1; |
SimonRez | 2:52b3c0b95388 | 24 | ledb = 1; |
SimonRez | 2:52b3c0b95388 | 25 | |
SimonRez | 4:651d06e860e7 | 26 | 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 ~~~A$$De$troyer69~~~ \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 | 27 | |
SimonRez | 5:f07bafaf11d7 | 28 | pwmpin.period_us(60); |
SimonRez | 5:f07bafaf11d7 | 29 | pwmpin = 0; |
SimonRez | 5:f07bafaf11d7 | 30 | |
SimonRez | 2:52b3c0b95388 | 31 | while (true) |
SimonRez | 2:52b3c0b95388 | 32 | { |
SimonRez | 5:f07bafaf11d7 | 33 | pwmpin.write(enc1.read()); |
SimonRez | 5:f07bafaf11d7 | 34 | direct = 1; |
SimonRez | 5:f07bafaf11d7 | 35 | pc.printf("%f \r\n", enc1.read()); |
SimonRez | 5:f07bafaf11d7 | 36 | wait(0.2f); |
vsluiter | 0:c8f15874531b | 37 | } |
vsluiter | 0:c8f15874531b | 38 | } |
SimonRez | 2:52b3c0b95388 | 39 | |
SimonRez | 2:52b3c0b95388 | 40 |