test script for motordriver. correct results are in the comments.

Dependencies:   mbed Motordriver

Files at this revision

API Documentation at this revision

Comitter:
littlexc
Date:
Thu Nov 25 14:53:28 2010 +0000
Commit message:

Changed in this revision

Motordriver.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
diff -r 000000000000 -r 751b3c43eaf5 Motordriver.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motordriver.lib	Thu Nov 25 14:53:28 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/littlexc/code/Motordriver/#3110b9209d3c
diff -r 000000000000 -r 751b3c43eaf5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 25 14:53:28 2010 +0000
@@ -0,0 +1,62 @@
+#include <mbed.h>
+#include <motordriver.h>
+//pc interface
+Serial pc(USBTX, USBRX); // tx, rx
+//declare motors
+Motor A(p22, p6, p5, 1); // pwm, fwd, rev, can break
+Motor B(p21, p7, p8, 1); // pwm, fwd, rev, can break
+//debugging stuff, switches a new led on after each sqeuence.
+DigitalOut led1 (LED1);
+DigitalOut led2 (LED2);
+DigitalOut led3 (LED3);
+DigitalOut led4 (LED4);
+
+int main() {
+    pc.printf("motor A, reverse to foward \n");
+    pc.printf("motor B, reverse to foward \n\n");
+
+    pc.printf("state motor A, %f, state motor B, %f \n\n", A.state(), B.state());
+    //should be 2.
+    led1=1;
+
+    for (float s=-1.0; s < 1.0 ; s += 0.01) {//sweep from reverse to foward
+        pc.printf("A %f %f \n",A.speed(s), s);
+        pc.printf("B %f %f \n\n",B.speed(s), s);
+        //should follow the output of the for loop
+        wait(0.02);
+    }
+    pc.printf("state motor A, %f, state motor B, %f \n\n", A.state(), B.state());
+    //should be 0.99 0.99.
+    
+    led2=1;
+
+    pc.printf("\nmotor A, braking \n");
+    pc.printf("motor B, braking \n\n");
+
+    pc.printf("A %f 0.5 \n",A.stop(0.5));
+    pc.printf("B %f 0.5 \n",B.stop(0.5));
+
+    pc.printf("\nstate motor A, %f, state motor B, %f \n\n", A.state(), B.state());
+    //should be -2 -2.
+    
+        for (float s=-1.0; s < 1.0 ; s += 0.01) {//sweep motors in opposite directions
+        pc.printf("A %f %f \n",A.speed(-s), s);
+        pc.printf("B %f %f \n\n",B.speed(s), s);
+        //should follow the output of the for loop
+        wait(0.02);
+    }
+    pc.printf("state motor A, %f, state motor B, %f \n\n", A.state(), B.state());
+    //should be -1 0.99.
+    
+    led3=1;
+    wait(1);
+
+    pc.printf("motor A, coasting \n");
+    pc.printf("motor B, coasting \n\n");
+
+    A.coast();
+    B.coast();
+    pc.printf("state motor A, %f, state motor B, %f \n end\n end\n", A.state(), B.state());
+    //should be 2 2.
+    led4=1;
+}
\ No newline at end of file
diff -r 000000000000 -r 751b3c43eaf5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 25 14:53:28 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e