Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp@7:99ac79d04dda, 2019-10-02 (annotated)
- Committer:
- s1932896
- Date:
- Wed Oct 02 08:39:16 2019 +0000
- Revision:
- 7:99ac79d04dda
- Parent:
- 6:211eab80755c
- Child:
- 8:05e1109a26fc
Test for motor control
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobertoO | 0:67c50348f842 | 1 | #include "mbed.h" |
RobertoO | 0:67c50348f842 | 2 | //#include "HIDScope.h" |
RobertoO | 0:67c50348f842 | 3 | //#include "QEI.h" |
RobertoO | 1:b862262a9d14 | 4 | #include "MODSERIAL.h" |
RobertoO | 0:67c50348f842 | 5 | //#include "BiQuad.h" |
s1932896 | 5:78a5043b6658 | 6 | #include "FastPWM.h" |
RobertoO | 0:67c50348f842 | 7 | |
s1932896 | 7:99ac79d04dda | 8 | DigitalOut motor1(D4); |
s1932896 | 7:99ac79d04dda | 9 | PwmOut e1(D5); |
s1932896 | 7:99ac79d04dda | 10 | PwmOut e2(D6); |
s1932896 | 7:99ac79d04dda | 11 | DigitalOut motor2(D7); |
s1932896 | 7:99ac79d04dda | 12 | |
RobertoO | 0:67c50348f842 | 13 | |
RobertoO | 1:b862262a9d14 | 14 | MODSERIAL pc(USBTX, USBRX); |
RobertoO | 0:67c50348f842 | 15 | |
s1932896 | 7:99ac79d04dda | 16 | |
s1932896 | 7:99ac79d04dda | 17 | void loop() |
RobertoO | 0:67c50348f842 | 18 | { |
s1932896 | 7:99ac79d04dda | 19 | pc.baud(115200); |
s1932896 | 7:99ac79d04dda | 20 | pc.printf("\r\nStarting...\r\n\r\n"); |
s1932896 | 7:99ac79d04dda | 21 | int value; |
s1932896 | 7:99ac79d04dda | 22 | int HIGH = 1; |
s1932896 | 7:99ac79d04dda | 23 | for(value = 0 ; value <= 255; value+=5) //speed test |
s1932896 | 7:99ac79d04dda | 24 | { |
s1932896 | 7:99ac79d04dda | 25 | motor1.write(HIGH); //Direction |
s1932896 | 7:99ac79d04dda | 26 | motor2.write(HIGH); //Direction |
s1932896 | 7:99ac79d04dda | 27 | e1.write(value); //PWM Speed Control |
s1932896 | 7:99ac79d04dda | 28 | e2.write(value); //PWM Speed Control |
s1932896 | 7:99ac79d04dda | 29 | wait_ms(30); |
s1932896 | 7:99ac79d04dda | 30 | pc.printf("%f",value); |
s1932896 | 7:99ac79d04dda | 31 | |
s1932896 | 7:99ac79d04dda | 32 | } |
RobertoO | 0:67c50348f842 | 33 | } |
s1932896 | 7:99ac79d04dda | 34 |