View unanswered posts | View active topics It is currently Mon Mar 25, 2019 2:23 pm

Reply to topic  [ 2 posts ] 
Turning in a defined degree 
Author Message

Joined: Tue Oct 04, 2011 6:22 am
Posts: 7
Post Turning in a defined degree
Hi again,

after my first steps I would like to reach that my robot (I still reached that the robot stop about 20 cm before it reach a wall, even I noticed a blanket does not work), go backwards (no problem) and turn than so long that he reach a 90 degree position from its last.

I read a bit about that it is not so easy to do that because the timer and so on don't work perfect. Is there a explaination how you can calculate with timer so for example it will turn 90 degrees?

Thanks and regards


Sun Aug 12, 2012 9:14 am
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Turning in a defined degree
You should take a look at nMotorEncoderTarget. Search for that keyword in the help and you'll find this little snippet:

nMotorEncoder[motorB] = 0;                // Reset the Motor Encoder of Motor B.
nMotorEncoderTarget[motorB] = 360;        // Set the  target for Motor Encoder of Motor B to 360.
motor[motorB] = 75;                       // Motor B is run at a power level of 75.
motor[motorC] = 75;                       // Motor C is run at a power level of 75.

while(nMotorRunState[motorB] != runStateIdle)  // While Motor B is still running:
  // Do not continue.
motor[motorB] = 0;                       // Motor B is stopped at a power level of 0.
motor[motorC] = 0;

Now you need to calculate how many degrees your motors needs to turn in order turn the robot 90 degrees. I'll leave as an exercise for the reader :)

- Xander

| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]

Sun Aug 12, 2012 9:30 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.