software to control a DC motor, preferably interfacing with a motor driver.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kaushalpkk
Date:
Thu Jul 14 23:46:07 2011 +0000
Commit message:
n/a

Changed in this revision

DCMotor.cpp Show annotated file Show diff for this revision Revisions of this file
DCMotor.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 86a53a224bcf DCMotor.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DCMotor.cpp	Thu Jul 14 23:46:07 2011 +0000
@@ -0,0 +1,24 @@
+#include "DCMotor.h"
+#include "mbed.h"
+
+DCMotor::DCMotor(PinName PWMPin, PinName PinA, PinName PinB):
+    _PWMPin(PWMPin), _PinA(PinA), _PinB(PinB) {
+    
+    _PWMPin.period(0.001);
+    _PWMPin = 0;
+    
+    _PinA = 0;
+    _PinB = 0;
+}
+
+void DCMotor::driveIt(float perCent) {
+    if (perCent > 0) {
+        _PinA = 0;
+        _PinB = 1;
+        
+    } else {
+        _PinA = 1;
+        _PinB = 0;
+    }
+    _PWMPin = fabs(perCent/100);    
+}
\ No newline at end of file
diff -r 000000000000 -r 86a53a224bcf DCMotor.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DCMotor.h	Thu Jul 14 23:46:07 2011 +0000
@@ -0,0 +1,18 @@
+#ifndef MBED_DCMOTOR_H
+#define MBED_DCMOTOR_H
+
+#include "mbed.h"
+
+class DCMotor {
+
+public:
+    DCMotor(PinName PWMPin, PinName PinA, PinName PinB);
+    void driveIt(float);
+    
+protected:
+    PwmOut _PWMPin;
+    DigitalOut _PinA;
+    DigitalOut _PinB;
+};
+
+#endif
\ No newline at end of file
diff -r 000000000000 -r 86a53a224bcf main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 14 23:46:07 2011 +0000
@@ -0,0 +1,7 @@
+#include "mbed.h"
+#include "DCMotor.h"
+
+int main() {
+
+
+}
diff -r 000000000000 -r 86a53a224bcf mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jul 14 23:46:07 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912