stepper test

Dependencies:   LongRangeSensor R5_StepperDrive mbed scanner

Files at this revision

API Documentation at this revision

Comitter:
j_j205
Date:
Fri Apr 01 22:21:38 2016 +0000
Commit message:
stepper test jj

Changed in this revision

LongRangeSensor.lib Show annotated file Show diff for this revision Revisions of this file
R5_StepperDrive.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
scanner.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LongRangeSensor.lib	Fri Apr 01 22:21:38 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Texas-State-IEEE-Robotics/code/LongRangeSensor/#c8c67fabc804
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/R5_StepperDrive.lib	Fri Apr 01 22:21:38 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Texas-State-IEEE-Robotics/code/R5_StepperDrive/#2657751be34b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 01 22:21:38 2016 +0000
@@ -0,0 +1,123 @@
+#include "scanner.h"
+#include "StepperDrive.h"
+#include "LongRangeSensor.h"
+#include "stdint.h"
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+Serial bluetooth(PTE16,PTE17); // bluetooth
+InterruptIn start(SW1);
+DigitalOut led_red(LED_RED);
+DigitalOut led_green(LED_GREEN);
+bool active = false;
+
+void activate()
+{
+    led_red = 1;
+    led_green = 0;
+    active = true;
+}
+
+int main() 
+{
+    pc.baud(115200);
+    bluetooth.baud(9600);  /* interface via Bluetooth at 9600 */
+    start.mode(PullUp); /* Start/Stop button is active low needing PullUp */
+    start.fall(&activate);
+
+    led_red = 0;
+    led_green = 1;
+
+    StepperDrive drive(pc, PTE19, PTE18, 1, PTE3, PTE2, 0, 10.0625, 8.4800, 650); // 8.375
+              //(serial &, stepPinLeft, dirPinLeft, invertLeft, stepPinRight, dirPinRight, invertRight, wheelCircum, wheelSepar, periodUs)
+
+    LongRangeSensor longRangeL(pc, PTB2);
+    LongRangeSensor longRangeR(pc, PTB3);
+
+    Scanner scanner(pc, drive, PTB0, PTB1, longRangeL, longRangeR, 1.0); // original period = 0.075
+        // (Serial &, PinName servoL, PinName servoR, shortRangeL, shortRangeR, longRangeL, longRangeR, period)
+    
+    pc.printf("\nWaiting for START BUTTON\n");
+    bluetooth.printf("\nWaiting for START BUTTON\n");
+    while(!active) // wait for start_button
+    {
+        wait(1e-6);
+    }
+              
+    pc.printf("\nBegin 1st peg retrieval");
+    bluetooth.printf("\nBegin 1st peg retrieval");
+    
+    drive.move(13.0, 0.0);
+    scanner.setLocalizeRightFlag(0);
+pc.printf("\n    LocalizeRight on");
+bluetooth.printf("\n    LocalizeRight on");
+    scanner.setLocalizeLeftFlag(0);
+    // wait for move to complete
+    while(!drive.isMoveDone())
+    {
+        wait(1e-6);
+    }
+    pc.printf("\nMoved from 0 to 1");
+    bluetooth.printf("\nMoved from 0 to 1");
+    
+    scanner.setLocalizeRightFlag(0);
+pc.printf("\n    LocalizeRight off");
+bluetooth.printf("\n    LocalizeRight off");
+    scanner.setLocalizeLeftFlag(0);
+    drive.move(0.0, (-90.0)*(3.14159 / 180.0));
+    // wait for move to complete
+    while(!drive.isMoveDone())
+    {
+        wait(1e-6);
+    }
+    pc.printf("\nMoved left 90 degrees");
+    bluetooth.printf("\nMoved left 90 degrees");
+    
+    drive.move(15.0, 0.0);
+    scanner.setLocalizeRightFlag(0);
+    scanner.setLocalizeLeftFlag(0);
+    // wait for move to complete
+    while(!drive.isMoveDone())
+    {
+        wait(1e-6);
+    }
+    pc.printf("\nMoved from 1 to 3");
+    bluetooth.printf("\nMoved from 1 to 3");
+    
+    scanner.setLocalizeRightFlag(0);
+    scanner.setLocalizeLeftFlag(0);
+    drive.move(0.0, (90.0)*(3.14159 / 180.0));
+    // wait for move to complete
+    while(!drive.isMoveDone())
+    {
+        wait(1e-6);
+    }
+    pc.printf("\nMoved right 90 degrees");
+    bluetooth.printf("\nMoved right 90 degrees");
+    
+    drive.move(6.0, 0.0);
+    scanner.setLocalizeRightFlag(0);
+    scanner.setLocalizeLeftFlag(0);
+    // wait for move to complete
+    while(!drive.isMoveDone())
+    {
+        wait(1e-6);
+    }
+    pc.printf("\nMoved from 3 to 15");
+    bluetooth.printf("\nMoved from 3 to 15");
+    
+    drive.move(60.0, 0.0);
+    scanner.setLocalizeRightFlag(1);
+pc.printf("\n    LocalizeRight on");
+    scanner.setLocalizeLeftFlag(0);
+    // wait for move to complete
+    while(!drive.isMoveDone())
+    {
+        wait(1e-6);
+    }
+    pc.printf("\nMoved from 15 to 7");
+    bluetooth.printf("\nMoved from 15 to 7");
+    
+    pc.printf("\nExercise Complete");
+    bluetooth.printf("\nExercise Complete");
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 01 22:21:38 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scanner.lib	Fri Apr 01 22:21:38 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Texas-State-IEEE-Robotics/code/scanner/#4e76b53cdef2