BE@R lab / motion_control

Dependencies:   motor_relay

Dependents:   dog_V3_3_testmotor

Committer:
soulx
Date:
Fri Jul 17 14:04:47 2015 +0000
Revision:
1:5b313fd2ca6f
Parent:
0:77ab14788110
Child:
2:2cadf29245f4
reversion from test; pin_config

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 0:77ab14788110 12 int8_t limit_motor(uint8_t dirction);
soulx 0:77ab14788110 13 int8_t position_control(uint16_t current, uint16_t target);
soulx 0:77ab14788110 14 void calibration();
soulx 0:77ab14788110 15
soulx 0:77ab14788110 16 int8_t GetLimitUp();
soulx 0:77ab14788110 17 int8_t GetLimitDown();
soulx 0:77ab14788110 18 void SetMargin(int16_t data);
soulx 1:5b313fd2ca6f 19
soulx 0:77ab14788110 20
soulx 0:77ab14788110 21 private:
soulx 0:77ab14788110 22
soulx 0:77ab14788110 23 MOTOR_RELAY *motor;
soulx 0:77ab14788110 24
soulx 0:77ab14788110 25 DigitalIn _limit_up;
soulx 0:77ab14788110 26 DigitalIn _limit_down;
soulx 0:77ab14788110 27 AnalogIn _position;
soulx 0:77ab14788110 28
soulx 0:77ab14788110 29 int16_t error;
soulx 0:77ab14788110 30 int16_t MARGIN;
soulx 0:77ab14788110 31
soulx 0:77ab14788110 32 int16_t MAX_POSITION;
soulx 0:77ab14788110 33 int16_t MIN_POSITION;
soulx 0:77ab14788110 34
soulx 1:5b313fd2ca6f 35 const uint16_t scale= 1000;
soulx 1:5b313fd2ca6f 36
soulx 1:5b313fd2ca6f 37
soulx 0:77ab14788110 38 float Kp;
soulx 0:77ab14788110 39 float Ki;
soulx 0:77ab14788110 40 float Kd;
soulx 0:77ab14788110 41 float margin_pid;
soulx 0:77ab14788110 42
soulx 0:77ab14788110 43 };
soulx 0:77ab14788110 44
soulx 0:77ab14788110 45 #endif