Tripple Controller for the TLE5206 H Bridge motor controller

Revision:
1:e6f43157c7db
Parent:
0:e2433ca2ce59
Child:
2:c5fbe0cb8a97
--- a/inc/example1.h	Tue Jul 05 07:43:28 2011 +0000
+++ b/inc/example1.h	Tue Jul 05 09:27:36 2011 +0000
@@ -48,6 +48,8 @@
     myled = !myled;
 }
 
+#define PI 3.14159265
+
 int main() {
     double speed;
     
@@ -56,51 +58,16 @@
     // Just flashes LED1 similar to a normal initial Mbed program.
     myLedFlasher.attach(myLedFlasherCallback, 0.2);
 
-    // The main loop just demos a linear ramp up/ramp down repeatedly.
+    motorA.setSpeed(0);
+    motorB.setSpeed(0);
+        
     while(1) {    
-        motorA.setSpeed(0);
-        motorB.setSpeed(0);
-    
-        wait(2);
-        
-        // Go from zero to +1.0 (+1.0 is full speed)
-        pc.printf("Going from zero to full CW speed...");
-        for(speed = 0.0; speed <= 1.0; speed += 0.005) {
-            if (speed > 1.0)  speed =  1.0; // Never let the speed go over 1!
-            if (speed < -1.0) speed = -1.0; // Never let the speed go below -1!
+        for (double i = 0; i < 360; i++) {
+            speed = sin(i * PI / 180.0);
             motorA.setSpeed(speed);
             motorB.setSpeed(speed);
             wait(0.05);
         }
-        pc.printf(" done.\n");
-    
-        // Hold the motor at full speed for 5seconds.
-        wait(2);
-        
-        // Now slow the motor down to zero and then reverse direction to -1.0 
-        pc.printf("Going from full CW speed to full CCW speed...");
-        for( ; speed >= -1.0; speed -= 0.005) {
-            if (speed > 1.0)  speed =  1.0; // Never let the speed go over 1!
-            if (speed < -1.0) speed = -1.0; // Never let the speed go below -1!
-            motorA.setSpeed(speed);
-            motorB.setSpeed(speed);
-            wait(0.05);
-        }
-        pc.printf(" done.\n");
-    
-        // Hold the motor at full speed in ccw for 5seconds.
-        wait(2);
-        
-        // Now bring the motor to a stop.
-        pc.printf("Bringing the motor to a halt...");
-        for( ; speed <= 0.0; speed += 0.005) {
-            if (speed > 1.0)  speed =  1.0; // Never let the speed go over 1!
-            if (speed < -1.0) speed = -1.0; // Never let the speed go below -1!
-            motorA.setSpeed(speed);
-            motorB.setSpeed(speed);
-            wait(0.05);
-        }
-        pc.printf(" done.\n");
     }
 }