![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Motor programma
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of frdm_Motor_V2_3 by
main.cpp@0:284ed397e046, 2015-09-28 (annotated)
- Committer:
- Margreeth95
- Date:
- Mon Sep 28 10:25:52 2015 +0000
- Revision:
- 0:284ed397e046
- Child:
- 1:48aba8d5610a
Motor gaat aan, maar verandert niet van richting/snelheid;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Margreeth95 | 0:284ed397e046 | 1 | #include "mbed.h" |
Margreeth95 | 0:284ed397e046 | 2 | #include "MODSERIAL.h" |
Margreeth95 | 0:284ed397e046 | 3 | #include "HIDScope.h" |
Margreeth95 | 0:284ed397e046 | 4 | #include "QEI.h" |
Margreeth95 | 0:284ed397e046 | 5 | |
Margreeth95 | 0:284ed397e046 | 6 | Serial pc(USBTX, USBRX); // tx, rx |
Margreeth95 | 0:284ed397e046 | 7 | DigitalOut led(LED_RED); |
Margreeth95 | 0:284ed397e046 | 8 | DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield) |
Margreeth95 | 0:284ed397e046 | 9 | PwmOut motor2speed(D5); |
Margreeth95 | 0:284ed397e046 | 10 | DigitalIn button1(SW3); |
Margreeth95 | 0:284ed397e046 | 11 | DigitalIn EncoderA(D3); |
Margreeth95 | 0:284ed397e046 | 12 | DigitalIn EncoderB(D2); |
Margreeth95 | 0:284ed397e046 | 13 | HIDScope scope(2); |
Margreeth95 | 0:284ed397e046 | 14 | Ticker ScopeTime; |
Margreeth95 | 0:284ed397e046 | 15 | |
Margreeth95 | 0:284ed397e046 | 16 | void ScopeSend()//Functie die de gegevens voor de scope uitleest en doorstuurt |
Margreeth95 | 0:284ed397e046 | 17 | { |
Margreeth95 | 0:284ed397e046 | 18 | scope.set(0, motor2direction.read()); |
Margreeth95 | 0:284ed397e046 | 19 | scope.set(1, motor2speed.read()); |
Margreeth95 | 0:284ed397e046 | 20 | scope.send(); |
Margreeth95 | 0:284ed397e046 | 21 | } |
Margreeth95 | 0:284ed397e046 | 22 | |
Margreeth95 | 0:284ed397e046 | 23 | int main() |
Margreeth95 | 0:284ed397e046 | 24 | { |
Margreeth95 | 0:284ed397e046 | 25 | motor2direction = 0; |
Margreeth95 | 0:284ed397e046 | 26 | motor2speed = 0; |
Margreeth95 | 0:284ed397e046 | 27 | wait(2); |
Margreeth95 | 0:284ed397e046 | 28 | led = 1; |
Margreeth95 | 0:284ed397e046 | 29 | pc.baud(115200); |
Margreeth95 | 0:284ed397e046 | 30 | pc.printf("Tot aan loop werkt"); |
Margreeth95 | 0:284ed397e046 | 31 | ScopeTime.attach_us(&ScopeSend, 10e4); |
Margreeth95 | 0:284ed397e046 | 32 | |
Margreeth95 | 0:284ed397e046 | 33 | |
Margreeth95 | 0:284ed397e046 | 34 | while (true) |
Margreeth95 | 0:284ed397e046 | 35 | { |
Margreeth95 | 0:284ed397e046 | 36 | motor2direction = 1; |
Margreeth95 | 0:284ed397e046 | 37 | motor2speed = 0.5f; |
Margreeth95 | 0:284ed397e046 | 38 | pc.printf("1\n"); |
Margreeth95 | 0:284ed397e046 | 39 | wait(0.1); |
Margreeth95 | 0:284ed397e046 | 40 | pc.printf("2222222222\n"); |
Margreeth95 | 0:284ed397e046 | 41 | motor2direction = 0; |
Margreeth95 | 0:284ed397e046 | 42 | motor2speed = 0.3f; |
Margreeth95 | 0:284ed397e046 | 43 | pc.printf("333\n"); |
Margreeth95 | 0:284ed397e046 | 44 | |
Margreeth95 | 0:284ed397e046 | 45 | } |
Margreeth95 | 0:284ed397e046 | 46 | } |