Updated

Dependencies:   Adafruit_GFX GPS QEI mbed

Files at this revision

API Documentation at this revision

Comitter:
canterol
Date:
Tue Nov 18 03:04:58 2014 +0000
Commit message:
Updated

Changed in this revision

Adafruit_GFX.lib Show annotated file Show diff for this revision Revisions of this file
FatFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
GPS.lib Show annotated file Show diff for this revision Revisions of this file
LSM303D.lib Show annotated file Show diff for this revision Revisions of this file
MSCFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
PololuQik2.lib Show annotated file Show diff for this revision Revisions of this file
QEI.lib Show annotated file Show diff for this revision Revisions of this file
SDHCFileSystem.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Adafruit_GFX.lib	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/canterol/code/Adafruit_GFX/#c3e0f8165538
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FatFileSystem.lib	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/DrCoyle/code/FatFileSystem/#88f22c32a456
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPS.lib	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/canterol/code/GPS/#233e5e68fbfb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM303D.lib	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/DrCoyle/code/LSM303D/#f186dd92c836
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MSCFileSystem.lib	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/DrCoyle/code/MSCFileSystem/#49f6277bdead
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PololuQik2.lib	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/DrCoyle/code/PololuQik2/#a87506b24191
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/aberk/code/QEI/#5c2ad81551aa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDHCFileSystem.lib	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/DrCoyle/code/SDHCFileSystem/#248d03543f5f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,99 @@
+/*
+ME503 Unmanned Autonomous Vehicle Systems
+Dr. E. Coyle
+Wall Following Assignment
+L. Cantero, B. Wallace
+*/
+
+#include "mbed.h"
+#include "Adafruit_SSD1306.h"
+#include "LSM303D.h"
+#include "QEI.h"
+#include "MSCFileSystem.h"
+#include "SDHCFileSystem.h"
+#include "GPS.h"
+#include "PololuQik2.h"
+#include <math.h>
+
+// an SPI sub-class that provides a constructed default format and frequency
+class SPI2 : public SPI
+{
+public:
+    SPI2(PinName mosi, PinName miso, PinName clk) : SPI(mosi,miso,clk)
+    {
+        format(8,3);
+        frequency(2000000);
+    };
+};
+
+Serial pc(USBTX,USBRX);
+SPI2 gSpi(p5,p6,p7);
+Adafruit_SSD1306 gOled(gSpi,p8,p11,p12);
+LSM303D comp(gSpi,p15);
+QEI Left(p30,p29,NC,48,QEI::X4_ENCODING);  // encoder object for Left wheel
+QEI Right(p17,p16,NC,48,QEI::X4_ENCODING);  // encoder object for Left wheel
+SDFileSystem sd(p5, p6, p7, p26, "sd"); // mosi, miso, sclk, cs
+PololuQik2 motors(p13,NC);
+Serial computer(p28, p27); // tx, rx read from bluetooth module
+//GPS gpsAda(NC,p14,9600);
+
+// Function prototypes
+void splash(); 
+void move(int speed0, int speed1);
+        
+int main()
+{   
+    computer.baud(230400);
+    int i=0, speed0 = 60, speed1 = 60, read;
+    double percent0 = 1.00, percent1 = 1.00;
+    
+    motors.begin();                // Initiate motor control
+    splash();                      // Display splash screen
+    
+    move(speed0, speed1);
+            
+    while(1)
+    {
+        if(computer.readable())
+        {
+            read=computer.getc();
+            
+            if(read != 255)
+            {
+                
+                percent0 = (read / 100.00);
+                percent1 = (2 - percent0);
+                
+                move(floor(percent0*speed0), floor(percent1*speed1));
+            }
+            
+            else
+            {
+                move(0,0);
+            }
+        }
+        
+        gOled.clearDisplay();
+        gOled.setCursor(0,0);   
+        gOled.printf("Left Motor: %.2f%%\nRight Motor: %.2f%%\nTime: %d",percent0*100, percent1*100,i);
+        gOled.display();  
+        i++;
+    } 
+}
+
+
+// FUNCTIONS______________________________________________________
+
+void splash() // Displays splash screen for 3 seconds, then clears buffer and resets cursor
+{
+    gOled.display();
+    wait(3.0);
+    gOled.clearDisplay();
+    gOled.setCursor(0,0); // Splash screen stays until next display call
+}
+
+void move(int speed0, int speed1) // Move robot using defined wheel speeds (corrects for wiring-polarity issue and mirroring of right motor)
+{
+    motors.setMotor0Speed(speed0);
+    motors.setMotor1Speed(-speed1);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 18 03:04:58 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file