Rob Griffith / Mbed 2 deprecated rat_code

Dependencies:   mbed QEI

Revision:
1:6f18bb7a77a5
Child:
3:35deb5c21b33
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/headers/pid_controller.h	Thu Nov 15 17:19:20 2018 +0000
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "globals.h"
+
+const float KpX = 1;
+const float KdX = 0;
+
+const float KpW = 1;
+const float KdW = 0;
+
+class PIDController {
+public:
+    PIDController();
+    
+    void reset() volatile;
+    void update() volatile;
+
+    void setXGoal(int counts);
+    void setWGoal(int counts);
+
+    bool isDone() volatile;
+    char* getData();
+private:
+    void getSensorFeedback() volatile;
+    void x_controller() volatile;
+    void w_controller() volatile;
+    void updateMotorPwm() volatile;
+    
+    int m_goalW;
+    int m_goalX;
+    
+    float m_pwmW;
+    float m_pwmX;
+    
+    int m_errorW;
+    int m_errorX;
+    int m_errorW_old;
+    int m_errorX_old;
+    
+    int m_countsW;
+    int m_countsX;
+    
+    char buf[200];
+};