Motor current controller

Fork of CURRENT_CONTROL by LDSC_Robotics_TAs

CURRENT_CONTROL.h

Committer:
adam_z
Date:
2016-04-22
Revision:
2:562bd14dfd3a
Parent:
1:c5973a56d474
Child:
3:c787d1c5ad6a

File content as of revision 2:562bd14dfd3a:

#ifndef __CURRENT_CONTROL_H__
#define __CURRENT_CONTROL_H__

#include "mbed.h"
#include "PID.h"


class CURRENT_CONTROL
{
public:
    typedef enum {
        PWM1,
        PWM2
    } PWMIndex;

    CURRENT_CONTROL(PinName curChannel, PinName PwmChannel1, PinName PwmChannel2, PWMIndex pwmIndex, float Kp, float Ki, float Kd, float samplingTime);
    void Control(float curRef);
    void SetAnalog2Cur(float ratio);
    //functions for test////////
    void ChangePwmPeriod(float microSeconds);
    void SetPWMDuty(float ratio);
    float GetAnalogIn(void);
    float GetCurrent(void);
    //////////////////////////
    PWMIndex pwmIndex_;
    PID pid;
    PwmOut MotorPlus;
    PwmOut MotorMinus;
    float controlOutput;

    float currentOffset;
    float curFeedBack;
    float analog2Cur;
    AnalogIn currentAnalogIn;
    float analogInValue;
    
private:

    float Ts;
    

};































#endif