codevoor esther
Dependencies: Encoder MODSERIAL mbed
Diff: main.cpp
- Revision:
- 3:0edffb90e739
- Parent:
- 2:3987ed9570c8
- Child:
- 4:863a52425322
--- a/main.cpp Mon Nov 04 14:54:13 2013 +0000 +++ b/main.cpp Mon Nov 04 16:08:46 2013 +0000 @@ -54,7 +54,7 @@ Ticker looptimer; looptimer.attach(setlooptimerflag,Ts); - motor1.setPosition(200); + motor1.setPosition(200.0); motor2.setPosition(0); x=0; y=0; @@ -67,18 +67,28 @@ looptimerflag = false; - x = (potmeter1.read()*297.0)*-1.0; + x = (potmeter1.read()*297.0); y = (potmeter2.read()*210.0); //x = x*10.0 + 69.8; //y = y*10.0 + 69.8; - theta = atan(y/x) ;// * (400.0/(.5*pi)); - r = (sqrt(x*x+y*y)) ;// * (2577/461.335); + if(x < 30){ + theta = 0.25*pi; + } + if(y < 21){ + theta = 0.25*pi; + } + if(x >= 30 && y >= 21){ + theta = atan(y/x)+(.25*pi);// * (400.0/(.5*pi)); + } + + r = (sqrt(x*x+y*y)) ;// * (2577/461.335); + - theta_pen = motor1.getPosition() * ((.5*pi)/400); - r_pen = motor2.getPosition() * (363.0/2577.0); + theta_pen = motor1.getPosition() * ((.5*pi)/400.0); + r_pen = motor2.getPosition() * (363.0/2196.0); dtheta = (theta - theta_pen);