Tests the motor by having the speed follow a sine wave.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jmar11
Date:
Mon Oct 06 14:56:56 2014 +0000
Commit message:
Tested the motor driver

Changed in this revision

mbed.bld Show annotated file Show diff for this revision Revisions of this file
motor_test.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Oct 06 14:56:56 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motor_test.cpp	Mon Oct 06 14:56:56 2014 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+
+PwmOut speed = PTE21;       //speed
+DigitalOut direct = PTE20;  //direction
+
+int main() {
+    float t = 0;
+    float val;
+          
+    while(1){
+        val = sin(t)/4;     //motor speed follows a sine wave
+        t += 0.00314f;
+        
+        if(val < 0){        //when val is negative switch direction
+            direct = 1;
+            speed = val * -1f;
+        }
+        else{
+            direct = 0;
+            speed = val;
+        }
+        
+        wait_us(2500);
+    }
+}
\ No newline at end of file