Werkend voor onze motor

Dependencies:   Encoder MODSERIAL QEI mbed

Fork of feed_forward_PI_copy by Dion de Greef

Files at this revision

API Documentation at this revision

Comitter:
RoyvZ
Date:
Wed Nov 01 15:09:54 2017 +0000
Parent:
3:91e4ed7b6748
Commit message:
Prima;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Oct 20 10:20:59 2017 +0000
+++ b/main.cpp	Wed Nov 01 15:09:54 2017 +0000
@@ -10,7 +10,7 @@
 InterruptIn button(D11);
 Ticker m1_Ticker;
 Ticker SP_m1_Ticker;
-Encoder encoder1(D13,D12);
+Encoder encoder1(D9,D8);
 float M1_KP = 2.5;
 float M1_KI = 1.0;
 const float M1_TS = 0.01;
@@ -62,7 +62,14 @@
     outOfEncod = encoder1.getPosition();
     position = RAD_PER_PULSE * outOfEncod;
     float ref_pos = reference - position;                                          // Don’t use magic numbers!
-    motor1 = PI(ref_pos, M1_KP, M1_KI, M1_TS, m1_err_int );
+    if (ref_pos <= 0)                                                               // Don’t use magic numbers!
+        {
+            motor1 = PI(ref_pos, M1_KP, M1_KI, M1_TS, m1_err_int );
+        }
+        else
+        {
+            motor1 = PI(ref_pos, M1_KP, M1_KI, M1_TS, m1_err_int );
+        }
     if (ref_pos <= 0) 
         {
             //float motor1DirectionPin1 = 1;