Carlo Collodi / kangaroo

Dependencies:   QEI mbed

Revision:
23:112c0be5a7f3
Child:
26:53b793b7a82f
diff -r 4d85d989af08 -r 112c0be5a7f3 include/motor.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/motor.hpp	Tue Nov 19 19:07:35 2013 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#include "QEI.h"
+
+#ifndef MOTOR_HPP
+#define MOTOR_HPP
+
+class Motor {
+
+    public:
+        Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, PinName encA, PinName encB);
+        
+        void start();
+        void stop();
+        void setTorque(float t);
+        void Control();
+        float getMotorPos();
+        float getCurrent();
+        static float filterLowPass(float old, float currentIn, float alphar);
+        void setPos(float pos);
+        void setVel(float vel);
+        void setPosVel(float pos, float vel);
+        void zero();
+        
+        float kp;
+        float kd;
+        
+    private:
+        Ticker t;
+        AnalogIn aIn;
+        DigitalOut Forward;
+        DigitalOut Backward;
+        PwmOut pwmOut;
+        QEI encoder;
+        
+        float speed;
+        float freq;
+        float pos;
+        float angle;
+        float voltage;
+        int mode;
+        
+        float dAngularVelocity;
+        float dAngle;
+        float dTorque;
+};
+
+#endif
\ No newline at end of file