codevoor esther

Dependencies:   Encoder MODSERIAL mbed

Files at this revision

API Documentation at this revision

Comitter:
gerjan
Date:
Mon Nov 04 20:29:01 2013 +0000
Parent:
6:bea0424b407c
Child:
8:e3e972c4e249
Commit message:
nieuwe;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Nov 04 19:58:59 2013 +0000
+++ b/main.cpp	Mon Nov 04 20:29:01 2013 +0000
@@ -55,7 +55,8 @@
     looptimer.attach(setlooptimerflag,Ts);
 
     motor1.setPosition(200.0);
-    motor2.setPosition(0);
+    motor2.setPosition(16.32);
+    
     x=0;
     y=0;
 
@@ -72,29 +73,32 @@
         //x = (potmeter1.read()*297.0);
         //y = (potmeter2.read()*210.0);
 
-        x   =   sin(inputsinus)*297;
+        x   =   sin(inputsinus)*297.0;
         y   =   0;
 
-        inputsinus  =   inputsinus + (Ts*1)*pi;
+        inputsinus  =   inputsinus + (Ts*0.1)*pi;
 
         //Binnen berijk blijven
 
-        if (y>210) {
-            y=210
+        if (y>210.0) {
+            y=210.0;
         }
-        if(y<=0) {
-            y=0
+        if(y<=0.0) {
+            y=0.0;
         }
-        if(x>297) {
-            x=297
+        if(x>297.0) {
+            x=297.0;
         }
-        if(x<=0) {
-            x=0
+        if(x<=0.0) {
+            x=0.0;
         }
 
-          // Omzetten hoek en straal
-        theta   = atan(y/x)+0.25*pi;
-        r       = (sqrt(x*x+y*y)) ;// *   (2577/461.335);
+        // Omzetten hoek en straal
+        //theta   = atan(y/x)+0.25*pi;
+        //r       = (sqrt(x*x+y*y)) ;// *   (2577/461.335);
+        
+        theta = atan((y+69.80)/(x+69.80)); 
+        r = (sqrt(x*x+y*y+139.60*x + 139.6*y+784.0));
 
 
         theta_pen   = motor1.getPosition()  *   ((.5*pi)/400.0);