Patrick Zieverink / Mbed 2 deprecated biorobotics_four_scorers_21_10

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Files at this revision

API Documentation at this revision

Comitter:
PatrickZieverink
Date:
Mon Oct 21 10:14:36 2019 +0000
Parent:
21:bea7c8a08e1d
Commit message:
PID coefficienten erin geknald

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Oct 18 09:05:58 2019 +0000
+++ b/main.cpp	Mon Oct 21 10:14:36 2019 +0000
@@ -68,7 +68,8 @@
 PID PID2;
 
 float dt = 0.001;
-float theta;
+float theta1;
+float theta2;
 float L;
 int enc1_zero = 0;//the zero position of the encoders, to be determined from the
 int enc2_zero = 0;//encoder calibration
@@ -227,9 +228,9 @@
     enc2_value = enc2.getPulses();
     enc1_value -= enc1_zero;
     enc2_value -= enc2_zero;
-    theta = (float)(enc1_value)/(float)(8400*2*PI);
-    L     = (float)(enc2_value)/(float)(8400*2*PI);
-    
+    theta1 = (float)(enc1_value)/(float)(8400)*2*PI;
+    theta2 = (float)(enc2_value)/(float)(8400)*2*PI;
+    L = theta2*0.008*5.05;
 
 }
 
@@ -377,6 +378,16 @@
     pc.printf("Executing main()... \r\n");
     state = s_idle;
 
+    PID1.P = 1;
+    PID1.I = 1;
+    PID1.D = 0;
+    PID1.I_counter = 0;
+    PID2.P = 1;
+    PID2.I = 3;
+    PID2.D = 0;
+    PID2.I_counter = 0;
+
+
     motor2_pwm.period(1/160000);   // 1/frequency van waarop hij draait
     motor1_pwm.period(1/160000);   // 1/frequency van waarop hij draait