PI controller to make the motor follow pot1

Dependencies:   HIDScope MODSERIAL QEI mbed

Fork of PI_control_pot by Jasper Gerth

Revision:
2:d0076e9d0a7f
Parent:
1:b75c4b9f1c98
--- a/main.cpp	Thu Sep 24 15:58:55 2015 +0000
+++ b/main.cpp	Thu Sep 24 16:27:40 2015 +0000
@@ -22,8 +22,8 @@
 
 //frequencies
 //const float pwm_frequency=1000;
-const double hidscope_frequency=100;
-const double pi_control_frequency=5;
+const double hidscope_frequency=100;//frequentie waarop data naar HIDScope wordt gestuurd
+const double pi_control_frequency=5;//frequentie waarop er een control actie wordt uitgevoerd. kan hoger, voorzichtig bij ruis!
 
 //tickers
 Ticker hidscope_ticker;
@@ -84,10 +84,11 @@
     pi_control_ticker.attach(&pi_control_activate,1.0/pi_control_frequency);
 
     while(1) {
-        //control motor 1 with a p controller
+        //control motor 1 with a pi controller
         if (pi_control_go==true) {
             double error=2*PI*pot1.read()-counttorad*encoder1.getPulses();
-            float signal_motor1=pi_control(error,motor1_pi_kp,motor1_pi_ki,1/pi_control_frequency,motor1_error_int);//send error to p controller
+            double signal_motor1=pi_control(error,motor1_pi_kp,motor1_pi_ki,
+                                            1/pi_control_frequency,motor1_error_int);//send error to p controller
             if (signal_motor1>=0) {//determine CW or CCW rotation
                 motor1_direction.write(CW);
             } else {