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
encoders.cpp@27:2456f68be679, 2014-03-01 (annotated)
- Committer:
- DavidEGrayson
- Date:
- Sat Mar 01 01:46:35 2014 +0000
- Revision:
- 27:2456f68be679
- Parent:
- 12:835a4d24ae3b
- Child:
- 39:b19dfc5d4d4b
Fixed a major bug in the line following (reduceSpeed return value was not used). Made finalSettleIn better by adding an integral term and increasing the settleSpeed from 200 to 300.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DavidEGrayson | 8:78b1ff957cba | 1 | #include "encoders.h" |
DavidEGrayson | 8:78b1ff957cba | 2 | |
DavidEGrayson | 9:9734347b5756 | 3 | const PinName encoderPinLeftA = p6, // Gray wire |
DavidEGrayson | 9:9734347b5756 | 4 | encoderPinLeftB = p7, // White wire |
DavidEGrayson | 9:9734347b5756 | 5 | encoderPinRightA = p30, // White wire |
DavidEGrayson | 9:9734347b5756 | 6 | encoderPinRightB = p29; // Gray wire |
DavidEGrayson | 8:78b1ff957cba | 7 | |
DavidEGrayson | 8:78b1ff957cba | 8 | PololuEncoderBuffer encoderBuffer; |
DavidEGrayson | 12:835a4d24ae3b | 9 | PololuEncoder encoderLeft(encoderPinLeftA, encoderPinLeftB, &encoderBuffer, ENCODER_LEFT); |
DavidEGrayson | 12:835a4d24ae3b | 10 | PololuEncoder encoderRight(encoderPinRightA, encoderPinRightB, &encoderBuffer, ENCODER_RIGHT); |
DavidEGrayson | 8:78b1ff957cba | 11 | |
DavidEGrayson | 9:9734347b5756 | 12 | void encodersInit() |
DavidEGrayson | 8:78b1ff957cba | 13 | { |
DavidEGrayson | 9:9734347b5756 | 14 | DigitalIn(encoderPinLeftA).mode(PullNone); |
DavidEGrayson | 9:9734347b5756 | 15 | DigitalIn(encoderPinLeftB).mode(PullNone); |
DavidEGrayson | 9:9734347b5756 | 16 | DigitalIn(encoderPinRightA).mode(PullNone); |
DavidEGrayson | 9:9734347b5756 | 17 | DigitalIn(encoderPinRightB).mode(PullNone); |
DavidEGrayson | 8:78b1ff957cba | 18 | wait_us(50); |
DavidEGrayson | 9:9734347b5756 | 19 | encoderLeft.init(); |
DavidEGrayson | 9:9734347b5756 | 20 | encoderRight.init(); |
DavidEGrayson | 8:78b1ff957cba | 21 | } |