Updates error values

Dependents:   locomotion_pid_action_refactor_EMG

Revision:
1:9e2c9237d88b
Parent:
0:cb9eda46a58c
Child:
2:d22c458a8a78
--- a/errorFetch.cpp	Fri Oct 20 12:24:03 2017 +0000
+++ b/errorFetch.cpp	Fri Oct 20 16:29:30 2017 +0000
@@ -1,20 +1,20 @@
 #include "errorFetch.h"
+
 #include "mbed.h"
 #include "QEI.h"
 #include "refGen.h"
 
 // Member function definitions
-errorFetch::errorFetch(QEI Encoder, float N, float TS, refGen REF):motorEncoder(Encoder), gearRatio(N), Ts(TS), e_pos(0), e_int(0), e_der(0), e_prev(0), ref(REF){
+errorFetch::errorFetch(refGen REF, float N, float Ts):ref(REF), gearRatio(N), Ts(Ts), e_pos(0), e_int(0), e_der(0), e_prev(0){
 
     }
     
-void errorFetch::getError(){
-    // Getting encoder counts and calculating motor position
-    int counts = motorEncoder.getPulses();
+void errorFetch::fetchError(int counts){
+    // Calculating motor position based on encoder counts
     double motorPosition = 2*3.14*(counts/(gearRatio*64.0f));
 
     // Computing position error
-    e_pos = ref.getReferencePosition(ref.maxAngle, ref.r_direction) - motorPosition;
+    e_pos = ref.getReferencePosition() - motorPosition;
     
     // Limiting the integral error to prevent integrator saturation
     if(fabs(e_int) <= 5){