2 motoren

Dependencies:   Encoder mbed

Files at this revision

API Documentation at this revision

Comitter:
DBerendsen
Date:
Wed Oct 11 09:33:32 2017 +0000
Parent:
0:bbd4e22aca8a
Commit message:
beter;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r bbd4e22aca8a -r 5681fcdc22fe main.cpp
--- a/main.cpp	Wed Oct 11 08:50:26 2017 +0000
+++ b/main.cpp	Wed Oct 11 09:33:32 2017 +0000
@@ -68,25 +68,29 @@
     double referenceangle2 = getreferenceangle(PI, potmeter2);
     double position2 = RAD_PER_PULSE * encoder2.getPosition();
     double magnitude2 = PI_controller(referenceangle2-position2, MOTOR2_KP, MOTOR2_KI, CONTROLLER_TS, m2_err_int) / motor2_gain;
-    motor1 = fabs(magnitude2);
+    motor2 = fabs(magnitude2);
     
     if (magnitude2 < 0)
     {
-        motor1DirectionPin = 1;
+        motor2DirectionPin = 1;
     }
     else
     {
-        motor1DirectionPin = 0;
+        motor2DirectionPin = 0;
     }
 }
 
 
 int main()
 {
-    
-    while(1) 
-    {
-        motor1_control(motor1_gain);
-        motor2_control(motor1_gain);
+   while(1) 
+   {
+     motor1_control(motor1_gain);
+     wait(0.005f);
+     motor2_control(motor2_gain);
+     wait(0.005f);
     }
+     
+   
+           
 }
\ No newline at end of file