motor drive libary to use speed control, coasting and dynamic braking. NOTE, dynamic braking my result in large currents. this may or may not set the motor driver on fire/break it/other undesired effects. so read the data sheet folks.

Dependents:   motordrivertestprogram Initialmbedrobotprogram mbedrobot ipod ... more

Revision:
2:2dc873322032
Parent:
1:3da7302dc9ae
Child:
4:5fb1296c0d60
diff -r 3da7302dc9ae -r 2dc873322032 motordriver.h
--- a/motordriver.h	Thu Nov 11 15:32:55 2010 +0000
+++ b/motordriver.h	Fri Nov 19 12:32:06 2010 +0000
@@ -42,35 +42,38 @@
 * @param pwm A PwmOut pin, driving the H-bridge enable line to control the speed
 * @param fwd A DigitalOut, set high when the motor should go forward
 * @param rev A DigitalOut, set high when the motor should go backwards
-* @param set if the motor driver is able to do braking 0 false 1 true. (addition)
+* @param set if the motor driver is able to do braking 0 false 1 true.
 */
         Motor(PinName pwm, PinName fwd, PinName rev, int brakeable);
   
-/** Set the speed of the motor (addition)
+/** Set the speed of the motor 
 * 
-* @param speed The speed of the motor as a normalised value between -1.0 and 1.0
+* @param speed The speed of the motor as a normalised value between -1.0 and 1.0.
+* @return the applied speed to the motor after checking to ensure motor doesn't switch from forward to reverse without stopping.
 */
-        void speed(float speed);
+        float speed(float speed);
         
 /** Set the the motor to coast
 * 
-* @param void motor coasts until another instruction is recived
+* @param void 
+* @return motor coasts until another instruction is recived.
 */        
   
         void coast(void);
 
-/** Set the motor to dynamicaly brake (addition)
+/** Set the motor to dynamicaly brake
 * 
-* @param void motor dynamicaly brakes until another instruction is recived
+* @param float 0 - 1.0 provides some control over how hard the motor brakes. 
+* @return duty applied to motor driver. -1 is error, motor driver can't brake.
 */
 
-        void stop(void);
+        float stop(float duty);
         
     protected:
         PwmOut _pwm;
         DigitalOut _fwd;
         DigitalOut _rev;
-        int Brakeable; // (addition)
+        int Brakeable; // cna the motor driver break
         int sign; //prevents throwing the motor from full foward to full reverse and stuff melting.
  
 };