v1.1 of orig program, slowly speeds up motor to find the poit at witch it gets stuck in the trigger or reaches top speed

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Kaikestu
Date:
Fri Feb 12 13:15:24 2010 +0000
Parent:
1:86868f4b226a
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 86868f4b226a -r 6d5f8ddf1145 main.cpp
--- a/main.cpp	Fri Feb 05 11:48:29 2010 +0000
+++ b/main.cpp	Fri Feb 12 13:15:24 2010 +0000
@@ -9,38 +9,52 @@
 LocalFileSystem local("local");
 Servo serv (p21);
 
-int count,begin,end;
+int begin,end;
+int begin2,end2,ws;
 int single_spin;
-const int wheel = 257; //in mm
-int Tdist=0;
-int i =0;
+int count;
+float i = 0.5;
 
 void trigger() {
-    FILE *fp = fopen("/local/out.csv", "a");
-
-    count = count + 1;
+    
     begin = timer.read_ms();
     single_spin = begin - end;
+    end = timer.read_ms();
+    
+    
+    begin2 = timer.read_ms();
+    FILE *fp = fopen("/local/out.csv", "a");
+    count = count + 1;
     myled2 = !myled2;
-    fprintf(fp, "%d, %d\n", count, single_spin);
-    end = timer.read_ms();
+    fprintf(fp, "%d, %d, %d, %.2f\n", count, single_spin, ws, i);
     fclose(fp);
-
+    
+    end2 = timer.read_ms();       
+    ws = end2 - begin2;
+    end = end - ws;
 }
 
 
 int main() {
     timer.start();
     w.rise(&trigger);
+    FILE *fp = fopen("/local/out.csv", "a");
+    fprintf(fp, "Turn_No, Time(ms), Write_time(ms), servo_setting\n");
+    fclose(fp); 
 
-    while (count < 5 ) // set this so it dont keep smashing in to walls !
-     {
+    while (1) { // set this so it dont keep smashing in to walls !
+
+        serv.write(0.01);
+        wait(0.5);
+        i -= 0.01;
+        myled = !myled;
         
-        serv.write(0.3);
-        myled = !myled;
-        wait(0.1);
+        if (i <= 0 ){
+        break;
+        } 
+        
     }
-  
+
     serv.write(0.5);