BE@R lab / motion_control

Dependencies:   motor_relay

Dependents:   dog_V3_3_testmotor

Committer:
soulx
Date:
Mon Dec 07 09:15:37 2015 +0000
Revision:
9:e3895130e56f
Parent:
7:94518aee126b
??????????????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
soulx 0:77ab14788110 1 #ifndef MBED_MOTOR_RE_H
soulx 0:77ab14788110 2 #define MBED_MOTOR_RE_H
soulx 0:77ab14788110 3
soulx 0:77ab14788110 4 #include "mbed.h"
soulx 0:77ab14788110 5 #include "motor_relay.h"
soulx 0:77ab14788110 6
soulx 0:77ab14788110 7 class MOTION_CONTROL
soulx 0:77ab14788110 8 {
soulx 0:77ab14788110 9 public:
soulx 0:77ab14788110 10 MOTION_CONTROL(PinName dirA, PinName dirB, PinName limitUp, PinName limitDown, PinName vr );
soulx 0:77ab14788110 11
soulx 4:6509fec6a6fb 12 int limit_motor(uint8_t dirction);
soulx 4:6509fec6a6fb 13 int8_t position_control(uint16_t target);
soulx 0:77ab14788110 14 void calibration();
soulx 5:91d905f8bef7 15
soulx 6:41d7cf11fdb1 16 //limit
soulx 9:e3895130e56f 17 // open : '0'
soulx 9:e3895130e56f 18 // shot : '1'
soulx 6:41d7cf11fdb1 19 int GetLimitUp();
soulx 3:4fa191f2194d 20 int GetLimitDown();
soulx 5:91d905f8bef7 21
soulx 0:77ab14788110 22 void SetMargin(int16_t data);
soulx 2:2cadf29245f4 23 int16_t GetMargin();
soulx 5:91d905f8bef7 24
soulx 2:2cadf29245f4 25 uint16_t GetMaxPosition();
soulx 2:2cadf29245f4 26 uint16_t GetMinPosition();
soulx 5:91d905f8bef7 27 void SetMaxPosition(uint16_t value);
soulx 5:91d905f8bef7 28 void SetMinPosition(uint16_t value);
soulx 4:6509fec6a6fb 29
soulx 4:6509fec6a6fb 30 uint16_t GetAnalog();
soulx 4:6509fec6a6fb 31 uint16_t GetPosition();
soulx 5:91d905f8bef7 32
soulx 4:6509fec6a6fb 33 void stop();
soulx 0:77ab14788110 34
soulx 7:94518aee126b 35 void SetMode(uint8_t mode);
soulx 7:94518aee126b 36 uint8_t GetMode();
soulx 7:94518aee126b 37
soulx 7:94518aee126b 38 void SetOffset(uint16_t value);
soulx 7:94518aee126b 39 uint16_t GetOffset();
soulx 7:94518aee126b 40
soulx 7:94518aee126b 41
soulx 0:77ab14788110 42 private:
soulx 0:77ab14788110 43
soulx 4:6509fec6a6fb 44 uint16_t Scale(uint16_t data);
soulx 5:91d905f8bef7 45
soulx 4:6509fec6a6fb 46 MOTOR_RELAY motor;
soulx 0:77ab14788110 47
soulx 0:77ab14788110 48 DigitalIn _limit_up;
soulx 0:77ab14788110 49 DigitalIn _limit_down;
soulx 0:77ab14788110 50 AnalogIn _position;
soulx 5:91d905f8bef7 51
soulx 0:77ab14788110 52 int16_t error;
soulx 0:77ab14788110 53 int16_t MARGIN;
soulx 5:91d905f8bef7 54
soulx 2:2cadf29245f4 55 uint16_t MAX_POSITION;
soulx 2:2cadf29245f4 56 uint16_t MIN_POSITION;
soulx 5:91d905f8bef7 57
soulx 4:6509fec6a6fb 58 const static uint16_t scale = 64;
soulx 5:91d905f8bef7 59 const static uint16_t LOOP = 100;
soulx 7:94518aee126b 60
soulx 7:94518aee126b 61 uint8_t mode_limit;
soulx 7:94518aee126b 62 uint16_t OFFSET_MAX_POSITION;
soulx 5:91d905f8bef7 63 //float Kp;
soulx 5:91d905f8bef7 64 //float Ki;
soulx 5:91d905f8bef7 65 //float Kd;
soulx 5:91d905f8bef7 66 //float margin_pid;
soulx 0:77ab14788110 67
soulx 0:77ab14788110 68 };
soulx 0:77ab14788110 69
soulx 0:77ab14788110 70 #endif