This library is an attempt to encapsulate the Pololu motor board MC33926 Motor Driver Carrier.

/media/uploads/buckeyes1997/0j1889.200.jpg

http://www.pololu.com/catalog/product/1213

Dual MC33926 Motor Driver Carrier

This dual brushed DC motor driver, based on Freescale’s MC33926 full H-bridge, has a wide operating range of 5 – 28 V and can deliver almost 3 A continuously (5 A peak) to each of its two motor channels. The MC33926 works with 3 – 5 V logic levels, supports ultrasonic (up to 20 kHz) PWM, and features current feedback, under-voltage protection, over-current protection, and over-temperature protection.

Files at this revision

API Documentation at this revision

Comitter:
buckeyes1997
Date:
Mon Feb 11 19:49:50 2013 +0000
Child:
1:69e4a93b718d
Commit message:
Dual MC33926 Motor Driver Carrier from Pololu.

Changed in this revision

Motor.cpp Show annotated file Show diff for this revision Revisions of this file
Motor.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.cpp	Mon Feb 11 19:49:50 2013 +0000
@@ -0,0 +1,37 @@
+#include "Motor.h"
+#include "mbed.h"
+
+
+Motor::Motor(PinName pwm, PinName dir1, PinName dir2): _pwm(pwm), _dir1(dir1), _dir2(dir2)
+{
+    _direction=1;
+    _pwm.period(0.00005);
+    _pwm = 0;
+    _dir1 = 0;
+    _dir2 = 0;
+
+}
+
+float Motor::speed(float speed, bool direction)
+{
+    if(direction == true) {
+        _dir1=1;
+        _dir2=0;
+    } else {
+        _dir1=0;
+        _dir2=1;
+    }
+    _pwm = abs(speed);
+    return speed;
+}
+
+float Motor::speed(float speed)
+{
+    _pwm = abs(speed);
+    return speed;
+}
+
+Motor& Motor::operator= (float speed) { 
+    _pwm = abs(speed);
+   return *this;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.h	Mon Feb 11 19:49:50 2013 +0000
@@ -0,0 +1,27 @@
+#ifndef MBED_MOTOR_H
+#define MBED_MOTOR_H
+
+#include "mbed.h"
+
+class Motor
+{
+public:
+
+
+    Motor(PinName pwm, PinName dir1, PinName dir2);
+
+    float speed(float speed, bool direction);
+    float speed(float speed);
+    Motor& operator= (float speed);
+
+
+protected:
+    PwmOut _pwm;
+    DigitalOut _dir1;
+    DigitalOut _dir2;
+    bool _direction;
+
+
+};
+
+#endif