BE@R lab / motion_control

Dependencies:   motor_relay

Dependents:   dog_V3_3_testmotor

motion_control.h

Committer:
soulx
Date:
2015-07-17
Revision:
3:4fa191f2194d
Parent:
2:2cadf29245f4
Child:
4:6509fec6a6fb

File content as of revision 3:4fa191f2194d:

#ifndef MBED_MOTOR_RE_H
#define MBED_MOTOR_RE_H

#include "mbed.h"
#include "motor_relay.h"

class MOTION_CONTROL
{
public:
    MOTION_CONTROL(PinName dirA, PinName dirB, PinName limitUp, PinName limitDown, PinName vr );

    int8_t limit_motor(uint8_t dirction);
    int8_t position_control(uint16_t current, uint16_t target);
    void calibration();
    
    int GetLimitUp();
    int GetLimitDown();
    
    void SetMargin(int16_t data);
    int16_t GetMargin();
    
    uint16_t GetMaxPosition();
    uint16_t GetMinPosition();
    
    
    

private:

    MOTOR_RELAY *motor;

    DigitalIn _limit_up;
    DigitalIn _limit_down;
    AnalogIn _position;
    
    int16_t error;
    int16_t MARGIN;
    
    uint16_t MAX_POSITION;
    uint16_t MIN_POSITION;
    
    const uint16_t scale= 1000;
    
    
    float Kp;
    float Ki;
    float Kd;
    float margin_pid;

};

#endif