BE@R lab / motion_control

Dependencies:   motor_relay

Dependents:   dog_V3_3_testmotor

Revision:
0:77ab14788110
Child:
1:5b313fd2ca6f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motion_control.h	Fri Jul 17 12:07:01 2015 +0000
@@ -0,0 +1,41 @@
+#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();
+    
+    int8_t GetLimitUp();
+    int8_t GetLimitDown();
+    void SetMargin(int16_t data);
+
+private:
+
+    MOTOR_RELAY *motor;
+
+    DigitalIn _limit_up;
+    DigitalIn _limit_down;
+    AnalogIn _position;
+    
+    int16_t error;
+    int16_t MARGIN;
+    
+    int16_t MAX_POSITION;
+    int16_t MIN_POSITION;
+    
+    float Kp;
+    float Ki;
+    float Kd;
+    float margin_pid;
+
+};
+
+#endif
\ No newline at end of file