a

Dependencies:   PID QEI USBDevice mbed

Fork of PID_Control_SU by naoto tanaka

Revision:
4:e9aeee8b41e4
Parent:
2:b46f1a4c42fb
--- a/main.cpp	Thu Apr 17 07:14:37 2014 +0000
+++ b/main.cpp	Sat Apr 19 05:08:16 2014 +0000
@@ -56,9 +56,14 @@
     uint8_t i = 0;
     int epls[2] = {0, 0};
     float rps = 0;
+    
+    //IO,DAconverter and PID parameters configuretion.
     initialize();
+    
+    //this block is the demonstration of PID control until BOOT switch is pushed.
     while(SW == 1)
     {
+        //this block is the outputs DAC data and revolution per second of motor.
         if(i == 100)
         {
             i = 0;
@@ -66,14 +71,19 @@
             vcom.printf("DAC.d  :%012d\n", dac.bit.D);
             vcom.printf("rps    :%12.4f", rps);        
         }
+        
+        //led is blinked to display the loop of PID control.
         i++;
         gled = i;
 
+        //calculate rps.
         epls[1] = wheel.getPulses();
         rps = ((float)(epls[1] - epls[0]) / PIDRATE) / 3600;
         epls[0] = epls[1];
         controller.setProcessValue(rps);
         dac.bit.D = (int)controller.compute();
+        
+        //send a command to change output of voltage.
         cs = 0;
         spi.write(dac.command);
         cs = 1;
@@ -85,6 +95,8 @@
     epls[0] = 0;
     timer.reset();
     timer.start();
+    vcom.printf("%d,%d,%f\n" , timer.read_ms(), dac.bit.D, rps);
+    i = 0;
     while(1)
     {
         if(SW == 0)