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@7:e21056555296, 2018-09-25 (annotated)
- Committer:
- SimonRez
- Date:
- Tue Sep 25 11:55:40 2018 +0000
- Revision:
- 7:e21056555296
- Parent:
- 6:1ee8795b7578
- Child:
- 8:9b517db94f49
Skrrrt; Kleine veranderingetjes
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" |
SimonRez | 6:1ee8795b7578 | 3 | #include "QEI.h" |
vsluiter | 0:c8f15874531b | 4 | |
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 | 6:1ee8795b7578 | 12 | AnalogIn pot1(A0); |
SimonRez | 6:1ee8795b7578 | 13 | |
SimonRez | 6:1ee8795b7578 | 14 | QEI encoder(D12,D13,NC,32); |
SimonRez | 5:f07bafaf11d7 | 15 | |
SimonRez | 4:651d06e860e7 | 16 | InterruptIn sw2(SW2); |
SimonRez | 4:651d06e860e7 | 17 | InterruptIn sw3(SW3); |
SimonRez | 2:52b3c0b95388 | 18 | |
vsluiter | 0:c8f15874531b | 19 | MODSERIAL pc(USBTX, USBRX); |
vsluiter | 0:c8f15874531b | 20 | |
SimonRez | 4:651d06e860e7 | 21 | |
vsluiter | 0:c8f15874531b | 22 | int main() |
vsluiter | 0:c8f15874531b | 23 | { |
SimonRez | 2:52b3c0b95388 | 24 | ledr = 1; |
SimonRez | 2:52b3c0b95388 | 25 | ledg = 1; |
SimonRez | 2:52b3c0b95388 | 26 | ledb = 1; |
SimonRez | 2:52b3c0b95388 | 27 | |
SimonRez | 4:651d06e860e7 | 28 | 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 | 29 | |
SimonRez | 5:f07bafaf11d7 | 30 | pwmpin.period_us(60); |
SimonRez | 5:f07bafaf11d7 | 31 | pwmpin = 0; |
SimonRez | 5:f07bafaf11d7 | 32 | |
SimonRez | 2:52b3c0b95388 | 33 | while (true) |
SimonRez | 2:52b3c0b95388 | 34 | { |
SimonRez | 6:1ee8795b7578 | 35 | pwmpin.write(pot1.read()); |
SimonRez | 5:f07bafaf11d7 | 36 | direct = 1; |
SimonRez | 6:1ee8795b7578 | 37 | pc.printf("potmeter: %f, encoder: %i \r\n", pot1.read(), encoder.getPulses()); |
SimonRez | 5:f07bafaf11d7 | 38 | wait(0.2f); |
vsluiter | 0:c8f15874531b | 39 | } |
vsluiter | 0:c8f15874531b | 40 | } |
SimonRez | 2:52b3c0b95388 | 41 | |
SimonRez | 2:52b3c0b95388 | 42 |