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 23:33:45 2014 +0000
Parent:
5:01ad080dc4fa
Child:
7:85b8b5acfb22
Commit message:
Got high-resolution 20 kHz PWM.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
motors.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Feb 20 23:30:53 2014 +0000
+++ b/main.cpp	Thu Feb 20 23:33:45 2014 +0000
@@ -34,7 +34,7 @@
     
     motors_init();
 
-    motors_speed_set(5, 45);
+    motors_speed_set(600, 5);
 
     Pacer reportPacer(500000);
     Pacer blinkPacer(200000);
--- a/motors.cpp	Thu Feb 20 23:30:53 2014 +0000
+++ b/motors.cpp	Thu Feb 20 23:33:45 2014 +0000
@@ -6,7 +6,6 @@
 static PwmOut motor2Pwm(p24);
 DigitalOut motor2Dir(p23);
 
-
 void motors_init()
 {
     motor1Pwm.period_us(50);
@@ -16,12 +15,10 @@
     
     LPC_PWM1->MR0 = 1200;       // Set the period
     LPC_PWM1->MCR = (1 << 1);   // Reset PWMTC when it is equal to MR0.
-    LPC_PWM1->MR1 = 10;
-    LPC_PWM1->MR3 = 600;
 }
 
 void motors_speed_set(int16_t motor1_speed, int16_t motor2_speed)
 {
-    //LPC_PWM1->MR0 = motor1_speed;
-    //LPC_PWM1->MR2 = motor2_speed;
+    LPC_PWM1->MR1 = motor1_speed;
+    LPC_PWM1->MR3 = motor2_speed;
 }