David's dead reckoning code for the LVBots competition on March 6th. Uses the mbed LPC1768, DRV8835, QTR-3RC, and two DC motors with encoders.
Dependencies: PololuEncoder Pacer mbed GeneralDebouncer
motors.cpp@4:1b20a11765c8, 2014-02-20 (annotated)
- Committer:
- DavidEGrayson
- Date:
- Thu Feb 20 22:59:28 2014 +0000
- Revision:
- 4:1b20a11765c8
- Child:
- 5:01ad080dc4fa
Succeeded in generating basic PWM signals with PwmOut.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DavidEGrayson | 4:1b20a11765c8 | 1 | #include <mbed.h> |
DavidEGrayson | 4:1b20a11765c8 | 2 | |
DavidEGrayson | 4:1b20a11765c8 | 3 | static PwmOut motor1Pwm(p26); |
DavidEGrayson | 4:1b20a11765c8 | 4 | DigitalOut motor1Dir(p25); |
DavidEGrayson | 4:1b20a11765c8 | 5 | |
DavidEGrayson | 4:1b20a11765c8 | 6 | static PwmOut motor2Pwm(p24); |
DavidEGrayson | 4:1b20a11765c8 | 7 | DigitalOut motor2Dir(p23); |
DavidEGrayson | 4:1b20a11765c8 | 8 | |
DavidEGrayson | 4:1b20a11765c8 | 9 | |
DavidEGrayson | 4:1b20a11765c8 | 10 | void motors_init() |
DavidEGrayson | 4:1b20a11765c8 | 11 | { |
DavidEGrayson | 4:1b20a11765c8 | 12 | motor1Pwm.period_us(50); |
DavidEGrayson | 4:1b20a11765c8 | 13 | motor2Pwm.period_us(50); |
DavidEGrayson | 4:1b20a11765c8 | 14 | } |
DavidEGrayson | 4:1b20a11765c8 | 15 | |
DavidEGrayson | 4:1b20a11765c8 | 16 | void motors_speed_set(int16_t motor1_speed, int16_t motor2_speed) |
DavidEGrayson | 4:1b20a11765c8 | 17 | { |
DavidEGrayson | 4:1b20a11765c8 | 18 | motor1Pwm.pulsewidth_us(motor1_speed); |
DavidEGrayson | 4:1b20a11765c8 | 19 | motor2Pwm.pulsewidth_us(motor2_speed); |
DavidEGrayson | 4:1b20a11765c8 | 20 | } |