Test two motors using pwm with an LMD18200 H-Bridge Driver. Ramps both motors in either direction with a pwm frequency of 20kHz.

Fork of Motor by Simon Ford

Revision:
3:bab4eebbf1a0
Parent:
2:f265e441bcd9
diff -r f265e441bcd9 -r bab4eebbf1a0 Motor.cpp
--- a/Motor.cpp	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.cpp	Thu Nov 08 15:52:42 2012 +0000
@@ -24,21 +24,21 @@
 
 #include "mbed.h"
 
-Motor::Motor(PinName pwm, PinName fwd, PinName rev):
-        _pwm(pwm), _fwd(fwd), _rev(rev) {
+Motor::Motor(PinName pwm, PinName dir):
+        _pwm(pwm), _dir(dir) {
 
     // Set initial condition of PWM
-    _pwm.period(0.001);
+    _pwm.period(0.00005);   //20kHz
     _pwm = 0;
 
     // Initial condition of output enables
-    _fwd = 0;
-    _rev = 0;
+    _dir = 1;
+//    _rev = 0;
 }
 
 void Motor::speed(float speed) {
-    _fwd = (speed > 0.0);
-    _rev = (speed < 0.0);
+    _dir = (speed > 0.0);
+//    _rev = (speed < 0.0);
     _pwm = abs(speed);
 }