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

Files at this revision

API Documentation at this revision

Comitter:
DavidEGrayson
Date:
Thu Jul 25 02:11:25 2019 +0000
Parent:
38:5e93a479c244
Child:
40:6fa672be85ec
Commit message:
New motors! 100:1 HP.

Changed in this revision

encoders.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
test.cpp Show annotated file Show diff for this revision Revisions of this file
test.h Show annotated file Show diff for this revision Revisions of this file
--- a/encoders.cpp	Thu Mar 13 17:49:43 2014 +0000
+++ b/encoders.cpp	Thu Jul 25 02:11:25 2019 +0000
@@ -1,9 +1,9 @@
 #include "encoders.h"
 
-const PinName encoderPinLeftA = p6,   // Gray wire
-              encoderPinLeftB = p7,   // White wire
-              encoderPinRightA = p30,  // White wire
-              encoderPinRightB = p29;  // Gray wire
+const PinName encoderPinLeftA = p6,   // White wire
+              encoderPinLeftB = p7,   // Yellow wire
+              encoderPinRightA = p30,  // Yellow wire
+              encoderPinRightB = p29;  // White wire
 
 PololuEncoderBuffer encoderBuffer;
 PololuEncoder encoderLeft(encoderPinLeftA, encoderPinLeftB, &encoderBuffer, ENCODER_LEFT);
--- a/main.cpp	Thu Mar 13 17:49:43 2014 +0000
+++ b/main.cpp	Thu Jul 25 02:11:25 2019 +0000
@@ -40,6 +40,7 @@
     // Test routines
     //testMotors();
     //testEncoders();
+    //testMotorSpeed();
     //testLineSensors();
     //testReckoner();
     //testButtons();
--- a/mbed.bld	Thu Mar 13 17:49:43 2014 +0000
+++ b/mbed.bld	Thu Jul 25 02:11:25 2019 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
--- a/test.cpp	Thu Mar 13 17:49:43 2014 +0000
+++ b/test.cpp	Thu Jul 25 02:11:25 2019 +0000
@@ -404,6 +404,26 @@
     }
 }
 
+void testMotorSpeed()
+{
+    led1 = 1;
+    motorsSpeedSet(400, 400);
+    wait_ms(4000);
+    uint32_t left = encoderLeft.getCount();
+    uint32_t right = encoderRight.getCount();
+    motorsSpeedSet(0, 0);
+    Pacer reportPacer(500000);
+    while (1)
+    {
+        if (reportPacer.pace())
+        {
+            led2 = 1;
+            pc.printf("%8d %8d\r\n", left, right);
+            led2 = 0;
+        }    
+    }
+}
+
 void testEncoders()
 {
     Pacer reportPacer(500000);
--- a/test.h	Thu Mar 13 17:49:43 2014 +0000
+++ b/test.h	Thu Jul 25 02:11:25 2019 +0000
@@ -2,6 +2,7 @@
 
 void __attribute__((noreturn)) testEncoders();
 void __attribute__((noreturn)) testMotors();
+void __attribute__((noreturn)) testMotorSpeed();
 void __attribute__((noreturn)) testLineSensors();
 void __attribute__((noreturn)) testReckoner();
 void __attribute__((noreturn)) testButtons();