Dependencies:   mbed

Dependents:   MouseHybridSenseCode

Revision:
5:dfea493f7a12
Child:
6:a652deaae134
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calculateFunc.cpp	Sun Mar 11 13:15:34 2018 +0000
@@ -0,0 +1,20 @@
+#include <mbed.h>
+#include <funcdef.h>
+
+void calculateFunc()
+{
+    //USE ERROR TO CALCULATE PID VALUES
+    Prop = errorVar;
+    //Inte = Inte + errorVar;
+    //Dere = ((errorVar - previousError);
+    
+    //THIS IS CALLED HERE BECAUSE WE NEED TO USE PREVIOUS ERROR BEFORE IT'S OVERWRITTEN
+    //errorAccumulate();
+    
+    //BECAUSE THE CURRENT ERROR IS CALCULATED IN A FUNCTION BEFORE THIS, ON THE NEXT ITERATION WE WANT TO REMEMBER THE PREVIOUS VARIABLE
+    previousError=errorVar;
+    
+    //FORMULATE OFFSET VALUE FROM ERROR, PID VALUES AND CONSTANTS
+    PIDs = (Kp*Prop);// + (Ki*Inte) + (Kd*Dere);     
+    return; 
+}
\ No newline at end of file