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

Revision:
9:9734347b5756
Parent:
8:78b1ff957cba
Child:
12:835a4d24ae3b
diff -r 78b1ff957cba -r 9734347b5756 encoders.cpp
--- a/encoders.cpp	Sat Feb 22 02:23:21 2014 +0000
+++ b/encoders.cpp	Sat Feb 22 03:03:37 2014 +0000
@@ -1,21 +1,21 @@
 #include "encoders.h"
 
-const PinName encoderPin1A = p6,
-              encoderPin1B = p7,
-              encoderPin2A = p8,
-              encoderPin2B = p9;
+const PinName encoderPinLeftA = p6,   // Gray wire
+              encoderPinLeftB = p7,   // White wire
+              encoderPinRightA = p30,  // White wire
+              encoderPinRightB = p29;  // Gray wire
 
 PololuEncoderBuffer encoderBuffer;
-PololuEncoder encoder1(encoderPin1A, encoderPin1B, &encoderBuffer, ENCODER1);
-PololuEncoder encoder2(encoderPin2A, encoderPin2B, &encoderBuffer, ENCODER2);
+PololuEncoder encoderLeft(encoderPinLeftA, encoderPinLeftB, &encoderBuffer, ENCODER1);
+PololuEncoder encoderRight(encoderPinRightA, encoderPinRightB, &encoderBuffer, ENCODER2);
 
-void encoders_init()
+void encodersInit()
 {
-    DigitalIn(encoderPin1A).mode(PullUp);
-    DigitalIn(encoderPin1B).mode(PullUp);
-    DigitalIn(encoderPin2A).mode(PullUp);
-    DigitalIn(encoderPin2B).mode(PullUp);
+    DigitalIn(encoderPinLeftA).mode(PullNone);
+    DigitalIn(encoderPinLeftB).mode(PullNone);
+    DigitalIn(encoderPinRightA).mode(PullNone);
+    DigitalIn(encoderPinRightB).mode(PullNone);
     wait_us(50);
-    encoder1.init();
-    encoder2.init();   
+    encoderLeft.init();
+    encoderRight.init();   
 }
\ No newline at end of file