Lab 6 code

Dependencies:   mbed

Revision:
1:49d9a5382ca9
Parent:
0:5d2df7452db5
diff -r 5d2df7452db5 -r 49d9a5382ca9 main.cpp
--- a/main.cpp	Fri Oct 10 19:20:07 2014 +0000
+++ b/main.cpp	Mon Oct 13 14:47:58 2014 +0000
@@ -200,7 +200,7 @@
 Timer t;
  
  // Open "results.M" on the local file system for writing
-FILE *fp = fopen("/local/results5.M", "w");
+FILE *fp = fopen("/local/resNL5.M", "w");
  
 float cntr;
 float ang,angp,speed;
@@ -249,12 +249,7 @@
         angp = ang;
         
         // Drive motor for ID
-        if (cntr*Ts <= 0.1) {
-            dc = 0.0;
-        } else if (cntr*Ts <= 0.55) {
-            dc = -0.075;
-            k0 = k;
-        } else if (cntr*Ts < 1.0) {            
+        if (cntr*Ts < 1.0) {            
             dc = -0.35;                        
         }else {
             dc = 0.0;
@@ -275,7 +270,7 @@
         t.stop(); // end measuring comp time
         dt = Ts-t.read();
         //printf("%5.2f\n\r",cntr);
-        pc.printf("%5.2f %5.2f %5.2f \n\r",cntr*Ts,speed,k0);
+        pc.printf("%5.2f %5.2f \n\r",cntr*Ts,speed);
         
         t.reset();
         cntr=cntr+1;
@@ -287,16 +282,11 @@
     // Print out log variables in MATLAB structured variable format.
     pc.printf("Printing log variables to file on mBed           ... ");
     if(1) {
-        for(k=101; k<k0; k++) {
-            fprintf(fp,"t_su(%d,1) = %.5f;\n",k+1-101,etime[k]-etime[101]);
-            fprintf(fp,"est_speed_su(%d,1) = %.5f;\n",k+1-101,est_speed[k]-est_speed[101]);
-            fprintf(fp,"dc_in_su(%d,1) = %.5f;\n",k+1-101,dc_in[k]);
-        }  
-        for(k=k0; k<1000; k++) {
-            fprintf(fp,"t_id(%d,1) = %.5f;\n",k+1-k0,etime[k]-etime[k0]);
-            fprintf(fp,"est_speed_id(%d,1) = %.5f;\n",k+1-k0,est_speed[k]-est_speed[k0]);
-            fprintf(fp,"dc_in_id(%d,1) = %.5f;\n",k+1-k0,dc_in[k]-dc_in[k0-1]);
-        }       
+        for(k=0; k<1000; k++) {
+            fprintf(fp,"t_id(%d,1) = %.5f;\n",k+1,etime[k]);
+            fprintf(fp,"est_speed_id(%d,1) = %.5f;\n",k+1,est_speed[k]);
+            fprintf(fp,"dc_in_id(%d,1) = %.5f;\n",k+1,dc_in[k]);
+        }
     }
     printf("done.\r\n");