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 Feb 20 18:55:04 2014 +0000
Parent:
0:e77a0edb9878
Child:
2:968338353aef
Commit message:
Added pacers.

Changed in this revision

Pacer.lib Show annotated file Show diff for this revision Revisions of this file
PololuEncoder.lib 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Pacer.lib	Thu Feb 20 18:55:04 2014 +0000
@@ -0,0 +1,1 @@
+Pacer#ffaf699a4eea
--- a/PololuEncoder.lib	Thu Feb 20 02:11:09 2014 +0000
+++ b/PololuEncoder.lib	Thu Feb 20 18:55:04 2014 +0000
@@ -1,1 +1,1 @@
-PololuEncoder#82ccff71d12a
+PololuEncoder#138f5421c287
--- a/main.cpp	Thu Feb 20 02:11:09 2014 +0000
+++ b/main.cpp	Thu Feb 20 18:55:04 2014 +0000
@@ -1,7 +1,8 @@
 #include <mbed.h>
 #include "PololuEncoder.h"
+#include "Pacer.h"
 
-DigitalOut myled(LED1);
+DigitalOut led1(LED1), led2(LED2);
 
 Serial pc(USBTX, USBRX);
 
@@ -9,19 +10,27 @@
 
 PololuEncoderBuffer encoderBuffer;
 PololuEncoder encoder1(p6, p7, &encoderBuffer, ENCODER1);
-//PololuEncoder encoder1(p6, p7, ENCODER1);
 
 int main() {
+    Pacer reportPacer(250000);
+    Pacer blinkPacer(200000);
+    uint32_t eventCount = 0;    
     while(1) {
-        //pc.printf("Encoder: %d\n", encoder1.getCounts());          
         while(encoderBuffer.hasEvents())
         {
             PololuEncoderEvent event = encoderBuffer.readEvent();
-            pc.printf("%x\n", event);
+            eventCount += 1;
+            pc.printf("e %x\n", event);
         }
-        myled = 1;
-        wait(0.1);
-        myled = 0;
-        wait(0.1);
+        if(reportPacer.pace())
+        {
+            led2 = 1;
+            pc.printf("%8x %8x\n", encoder1.getCount(), eventCount);
+            led2 = 0;
+        }
+        if (blinkPacer.pace())
+        {
+            led1 = !led1;
+        }
     }
 }