Samenwerking Groep 12

Dependencies:   Encoder MODSERIAL HIDScope mbed

Foo

Revision:
22:d22381fe3b16
Parent:
21:fb17e0b8924e
Child:
23:34e97668550f
--- a/main.cpp	Tue Sep 22 13:47:11 2015 +0000
+++ b/main.cpp	Tue Sep 22 13:59:36 2015 +0000
@@ -10,13 +10,14 @@
 Encoder motor2(D13,D12,true); // The encoder is able to read and set position/speed values
 MODSERIAL pc(USBTX,USBRX); // This input is used to send data to the pc
 Ticker TickerController; // This adds a Ticker to the function +TickerController
+HIDScope scope(2);
 //AnalogIn potmeter2(A0); /NIEUW
 
 // Defining constants
 double counts_per_revolution=4200; 
 double degrees_per_turn=360;
 double counts_per_degree=counts_per_revolution/degrees_per_turn; //11.67 counts/degree
-const double motor2_Kp = 2.5; //controller gain which will be multiplied with the error (*how fast will the error be corrected)
+const double motor2_Kp = 1; //controller gain which will be multiplied with the error (*how fast will the error be corrected)
 const double reference = 400;
 
 // Function P-controller
@@ -53,7 +54,9 @@
         motor2speed=fabs(output_motor);
         motor2direction=0;
         break;}
+            while(1){
             pc.printf("else loop controller");
+            scope.set(0,motor2.getPosition());}
         }
     
 //  while (Error_position > 0) {