Carlo Collodi / kangaroo

Dependencies:   QEI mbed

include/motor.hpp

Committer:
sherryxy
Date:
2013-12-01
Revision:
49:3aaa790800ad
Parent:
44:3566c5699ba6
Child:
53:978b7fa74080

File content as of revision 49:3aaa790800ad:

#include "mbed.h"
#include "QEI.h"

#ifndef MOTOR_HPP
#define MOTOR_HPP

class Motor {

    public:
        Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, QEI &enc);
        
        void start();
        void stop();
        void setTorque(float t);
        void Control();
        int getPos();
        float getAngle();
        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();
        void calibAngle(float ang);
        
        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;
        volatile int mode;
                
        volatile float dAngularVelocity;
        volatile float dAngle;
        volatile float dTorque;
};

#endif