Carlo Collodi / kangaroo

Dependencies:   QEI mbed

Revision:
37:bf257a0154db
Parent:
35:a4e89e78d034
Child:
38:922f2584bdfd
Child:
43:68faf056ed5c
--- a/src/motor.cpp	Sun Nov 24 20:18:17 2013 +0000
+++ b/src/motor.cpp	Sun Nov 24 20:38:59 2013 +0000
@@ -1,8 +1,8 @@
 #include "mbed.h"
 #include "include/motor.hpp"
 
-Motor::Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, PinName encA, PinName encB):aIn(aPin),Forward(fPin),Backward(bPin),pwmOut(pwmPin),encoder(encA, encB, NC, 1200, QEI::X4_ENCODING){ //15,17,18,21,25,26 and 16,19,20,22,23,24
-    
+Motor::Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, QEI &enc):aIn(aPin),Forward(fPin),Backward(bPin),pwmOut(pwmPin),encoder(enc){ 
+//15,17,18,21,qei25,26 and 16,19,20,22,qei23,24
     freq =.001;
     voltage = 12.0;
     mode=0;
@@ -20,6 +20,8 @@
 void Motor::stop(){
     t.detach();
     pwmOut.write(0);
+    dAngle=0;
+    dAngularVelocity=0;
 }
 
 void Motor::zero(){
@@ -67,7 +69,7 @@
     return (1/.140)*3.3 * aIn;
 }
 
-float Motor::getMotorPos()
+int Motor::getPos()
 {
     return encoder.getPulses();
 }