mit

Dependencies:   QEI mbed-src

Revision:
4:5ae9f8b3a16f
Parent:
3:cae0b305d54c
diff -r cae0b305d54c -r 5ae9f8b3a16f PID.h
--- a/PID.h	Fri Jul 12 00:13:37 2013 +0000
+++ b/PID.h	Tue Nov 24 03:56:22 2015 +0000
@@ -2,53 +2,41 @@
 //PID Controller class
 
 #include "mbed.h"
-#ifndef PID_H
-#define PID_H
 
-class PIDController{
-public:
-
-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);
-~PIDController();
-
-float goal_position;
-float current_position;
-
-float kp_p;
-float kd_p;
-float ki_p;
-
-float kp_c;
-float ki_c;
-float c_error;
-float error_sum;
-float command;
-float torque_command;
-float c_torque;
+#ifndef PID_CONTROLLER_H
+#define PID_CONTROLLER_H
 
-float error;
-float old_error;
-float integral_error;
-
-
-int counter;
-
-Timer timer;
-
-float torque;
-float direction;
+class PIDController {
+    public:
+        PIDController(float p_gain, float d_gain, float i_gain);
+    
+        float command_position(float current_position);
+        float command_torque(float current_current);
+        float command_position_tm(float current_position, float current_current);
+        
+        // Process variable commanded value
+        float command;
+        float current_torque;
+        
+        void set_command(float command);
+    
+    private:
+        float kp;
+        float kd;
+        float ki;
+        
+        // State for process variable (position for now)
+        float error;
+        float old_error;
+        float integral_error;
+        
+        // Current command (fuse with command?)
+        float torque_command;
+        float torque_error;
+        float torque_integral_error;
+        float torque_history[5];
+        
+        float direction;
+};
 
-float past_currents [5];
-
-float command_position(void);
-float command_torque(void);
-float command_position_tm(void);
-private:
-
-
-
-
-
-
-};
 #endif