Draaiende motor op commando van knopje (WERKEND)

Dependencies:   Encoder MODSERIAL mbed

Fork of P_controller_motor by Bouke Scheltinga

Revision:
6:34b39eb3dcb6
Parent:
5:8ea7a765c1f7
Child:
7:961dcef17e08
--- a/main.cpp	Thu Sep 17 11:11:44 2015 +0000
+++ b/main.cpp	Thu Sep 17 11:36:05 2015 +0000
@@ -8,7 +8,7 @@
 
 // Define Encoder
 
-Encoder encoder(PTD0,PTC9,true);
+Encoder encoder1(PTD0,PTC9,true);
 Serial pc(USBTX,USBRX);
 
 // Define Potmeter
@@ -25,25 +25,25 @@
     {
             return Kp*error;
     }
+    
+// Motor function
 
-// encoder1
-// potmeter1
-    
+
 // Error measurement and apply the output to the plant
 void motorP_Controller()
     {
         double reference_position = potmeter1.read();
-        double position = Convert_volt_to_position*encoder.getPosition();
-        motorP=P(reference_position - position, motorP_Kp);
+        double position = Convert_volt_to_position*encoder1.getPosition();
+        return P(reference_position-position, motorP_Kp);
     }
     
 int main()
     {
-        myControllerTicker.attach(&motorP_Controller,0.01f); //100Hz
+        motorP = motorP_Controller()
+        motorP.attach(&motorP_Controller,0.01f); //100Hz
         while(1){}
     }
 
-
 // Read the analog input
 float triangle_signal = 2.05;
  
@@ -54,9 +54,9 @@
     scope.send();
 }
  
-int main()
+int scopeattach()
 {
-    // Attach the data read and send function at 200 Hz
+    // Attach the data read and send function at 100 Hz
     scopeTimer.attach_us(&scopeSend, 2e4);   
     
     while(1) { }