Decoupled position and current control working.

Dependencies:   QEI mbed-src

Committer:
benkatz
Date:
Fri Jul 12 00:13:37 2013 +0000
Revision:
3:cae0b305d54c
Parent:
2:89bb6272869b
Child:
4:5ae9f8b3a16f
now with current control;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benkatz 2:89bb6272869b 1 //Ben Katz, 2013
benkatz 2:89bb6272869b 2 //PID Controller class
benkatz 2:89bb6272869b 3
benkatz 2:89bb6272869b 4 #include "mbed.h"
benkatz 2:89bb6272869b 5 #ifndef PID_H
benkatz 2:89bb6272869b 6 #define PID_H
benkatz 2:89bb6272869b 7
benkatz 2:89bb6272869b 8 class PIDController{
benkatz 2:89bb6272869b 9 public:
benkatz 2:89bb6272869b 10
benkatz 3:cae0b305d54c 11 PIDController(float desired_position, float desired_torque, float p_gainp, float d_gainp, float i_gain_p, float p_gain_c, float i_gain_c);
benkatz 2:89bb6272869b 12 ~PIDController();
benkatz 2:89bb6272869b 13
benkatz 2:89bb6272869b 14 float goal_position;
benkatz 3:cae0b305d54c 15 float current_position;
benkatz 2:89bb6272869b 16
benkatz 3:cae0b305d54c 17 float kp_p;
benkatz 3:cae0b305d54c 18 float kd_p;
benkatz 3:cae0b305d54c 19 float ki_p;
benkatz 3:cae0b305d54c 20
benkatz 3:cae0b305d54c 21 float kp_c;
benkatz 3:cae0b305d54c 22 float ki_c;
benkatz 3:cae0b305d54c 23 float c_error;
benkatz 3:cae0b305d54c 24 float error_sum;
benkatz 3:cae0b305d54c 25 float command;
benkatz 3:cae0b305d54c 26 float torque_command;
benkatz 3:cae0b305d54c 27 float c_torque;
benkatz 2:89bb6272869b 28
benkatz 2:89bb6272869b 29 float error;
benkatz 2:89bb6272869b 30 float old_error;
benkatz 2:89bb6272869b 31 float integral_error;
benkatz 2:89bb6272869b 32
benkatz 3:cae0b305d54c 33
benkatz 3:cae0b305d54c 34 int counter;
benkatz 3:cae0b305d54c 35
benkatz 3:cae0b305d54c 36 Timer timer;
benkatz 2:89bb6272869b 37
benkatz 3:cae0b305d54c 38 float torque;
benkatz 3:cae0b305d54c 39 float direction;
benkatz 3:cae0b305d54c 40
benkatz 3:cae0b305d54c 41 float past_currents [5];
benkatz 3:cae0b305d54c 42
benkatz 3:cae0b305d54c 43 float command_position(void);
benkatz 3:cae0b305d54c 44 float command_torque(void);
benkatz 3:cae0b305d54c 45 float command_position_tm(void);
benkatz 2:89bb6272869b 46 private:
benkatz 2:89bb6272869b 47
benkatz 2:89bb6272869b 48
benkatz 2:89bb6272869b 49
benkatz 2:89bb6272869b 50
benkatz 2:89bb6272869b 51
benkatz 2:89bb6272869b 52
benkatz 2:89bb6272869b 53 };
benkatz 2:89bb6272869b 54 #endif